Commit 9a7dea0
committed
fix: Correctly handle different invoice types to prevent crashes
Resolved a bug where the `Invoice` class would raise an `AttributeError` when parsing invoice data from payment links. This was due to the rigid expectation of `title`, `description`, and `start_parameter` attributes, which are not always present in the raw `Invoice` object returned by the Telegram API.
- Modified the `Invoice` class in `pyrogram/types/payments/invoice.py` to make `title`, `description`, and `start_parameter` optional.
- Updated the `_parse` method to handle both `raw.types.MessageMediaInvoice` and `raw.types.Invoice` types, ensuring that missing attributes are handled gracefully.1 parent cb38d6a commit 9a7dea0
1 file changed
+24
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
55 | | - | |
56 | | - | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| |||
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
78 | | - | |
| 80 | + | |
79 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
80 | 96 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
89 | 101 | | |
0 commit comments