botapi-py 1.1.0__tar.gz → 1.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: botapi-py
3
- Version: 1.1.0
3
+ Version: 1.2.1
4
4
  Summary: A simple and flexible Python library to conveniently build Telegram bots using the Bot API.
5
5
  Requires-Dist: httpx>=0.28.1
6
6
  Requires-Dist: pydantic>=2.12.0
7
- Requires-Python: >=3.13
8
- Project-URL: TelegramBotAPI, https://core.telegram.org/bots/api
7
+ Requires-Python: >=3.12
8
+ Project-URL: Telegram BotAPI Docs, https://core.telegram.org/bots/api
@@ -1,19 +1,19 @@
1
1
  [project]
2
2
  name = "botapi-py"
3
- version = "1.1.0"
3
+ version = "1.2.1"
4
4
  description = "A simple and flexible Python library to conveniently build Telegram bots using the Bot API."
5
5
  # readme = "README.md"
6
6
  # authors = [
7
7
  # { name = "CalledLuca", email = "me@calledluca.it" }
8
8
  # ]
9
- requires-python = ">=3.13"
9
+ requires-python = ">=3.12"
10
10
  dependencies = [
11
11
  "httpx>=0.28.1",
12
12
  "pydantic>=2.12.0",
13
13
  ]
14
14
 
15
15
  [project.urls]
16
- TelegramBotAPI = "https://core.telegram.org/bots/api"
16
+ "Telegram BotAPI Docs" = "https://core.telegram.org/bots/api"
17
17
 
18
18
  [build-system]
19
19
  requires = ["uv_build>=0.9.0,<0.10.0"]
@@ -1,4 +1,6 @@
1
- # This is an autogenerated file. Do not edit this file directly.
1
+ # WARNING!
2
+ # This is an autogenerated file.
3
+ # Do NOT edit this file directly, your changes will be overwritten.
2
4
 
3
5
  from __future__ import annotations
4
6
 
@@ -15,10 +17,14 @@ from .types import (
15
17
  Message,
16
18
  MessageId,
17
19
  InaccessibleMessage,
20
+ MaybeInaccessibleMessage,
21
+ MaybeInaccessibleMessageAdapter,
18
22
  MessageEntity,
19
23
  TextQuote,
20
24
  ExternalReplyInfo,
21
25
  ReplyParameters,
26
+ MessageOrigin,
27
+ MessageOriginAdapter,
22
28
  MessageOriginUser,
23
29
  MessageOriginHiddenUser,
24
30
  MessageOriginChat,
@@ -32,6 +38,8 @@ from .types import (
32
38
  VideoNote,
33
39
  Voice,
34
40
  PaidMediaInfo,
41
+ PaidMedia,
42
+ PaidMediaAdapter,
35
43
  PaidMediaPreview,
36
44
  PaidMediaPhoto,
37
45
  PaidMediaVideo,
@@ -53,9 +61,13 @@ from .types import (
53
61
  ProximityAlertTriggered,
54
62
  MessageAutoDeleteTimerChanged,
55
63
  ChatBoostAdded,
64
+ BackgroundFill,
65
+ BackgroundFillAdapter,
56
66
  BackgroundFillSolid,
57
67
  BackgroundFillGradient,
58
68
  BackgroundFillFreeformGradient,
69
+ BackgroundType,
70
+ BackgroundTypeAdapter,
59
71
  BackgroundTypeFill,
60
72
  BackgroundTypeWallpaper,
61
73
  BackgroundTypePattern,
@@ -111,6 +123,8 @@ from .types import (
111
123
  ChatInviteLink,
112
124
  ChatAdministratorRights,
113
125
  ChatMemberUpdated,
126
+ ChatMember,
127
+ ChatMemberAdapter,
114
128
  ChatMemberOwner,
115
129
  ChatMemberAdministrator,
116
130
  ChatMemberMember,
@@ -126,6 +140,8 @@ from .types import (
126
140
  BusinessOpeningHours,
127
141
  StoryAreaPosition,
128
142
  LocationAddress,
143
+ StoryAreaType,
144
+ StoryAreaTypeAdapter,
129
145
  StoryAreaTypeLocation,
130
146
  StoryAreaTypeSuggestedReaction,
131
147
  StoryAreaTypeLink,
@@ -133,6 +149,8 @@ from .types import (
133
149
  StoryAreaTypeUniqueGift,
134
150
  StoryArea,
135
151
  ChatLocation,
152
+ ReactionType,
153
+ ReactionTypeAdapter,
136
154
  ReactionTypeEmoji,
137
155
  ReactionTypeCustomEmoji,
138
156
  ReactionTypePaid,
@@ -149,12 +167,16 @@ from .types import (
149
167
  UniqueGift,
150
168
  GiftInfo,
151
169
  UniqueGiftInfo,
170
+ OwnedGift,
171
+ OwnedGiftAdapter,
152
172
  OwnedGiftRegular,
153
173
  OwnedGiftUnique,
154
174
  OwnedGifts,
155
175
  AcceptedGiftTypes,
156
176
  StarAmount,
157
177
  BotCommand,
178
+ BotCommandScope,
179
+ BotCommandScopeAdapter,
158
180
  BotCommandScopeDefault,
159
181
  BotCommandScopeAllPrivateChats,
160
182
  BotCommandScopeAllGroupChats,
@@ -165,9 +187,13 @@ from .types import (
165
187
  BotName,
166
188
  BotDescription,
167
189
  BotShortDescription,
190
+ MenuButton,
191
+ MenuButtonAdapter,
168
192
  MenuButtonCommands,
169
193
  MenuButtonWebApp,
170
194
  MenuButtonDefault,
195
+ ChatBoostSource,
196
+ ChatBoostSourceAdapter,
171
197
  ChatBoostSourcePremium,
172
198
  ChatBoostSourceGiftCode,
173
199
  ChatBoostSourceGiveaway,
@@ -179,16 +205,24 @@ from .types import (
179
205
  BusinessConnection,
180
206
  BusinessMessagesDeleted,
181
207
  ResponseParameters,
208
+ InputMedia,
209
+ InputMediaAdapter,
182
210
  InputMediaPhoto,
183
211
  InputMediaVideo,
184
212
  InputMediaAnimation,
185
213
  InputMediaAudio,
186
214
  InputMediaDocument,
187
215
  InputFile,
216
+ InputPaidMedia,
217
+ InputPaidMediaAdapter,
188
218
  InputPaidMediaPhoto,
189
219
  InputPaidMediaVideo,
220
+ InputProfilePhoto,
221
+ InputProfilePhotoAdapter,
190
222
  InputProfilePhotoStatic,
191
223
  InputProfilePhotoAnimated,
224
+ InputStoryContent,
225
+ InputStoryContentAdapter,
192
226
  InputStoryContentPhoto,
193
227
  InputStoryContentVideo,
194
228
  Sticker,
@@ -197,6 +231,8 @@ from .types import (
197
231
  InputSticker,
198
232
  InlineQuery,
199
233
  InlineQueryResultsButton,
234
+ InlineQueryResult,
235
+ InlineQueryResultAdapter,
200
236
  InlineQueryResultArticle,
201
237
  InlineQueryResultPhoto,
202
238
  InlineQueryResultGif,
@@ -217,6 +253,8 @@ from .types import (
217
253
  InlineQueryResultCachedVideo,
218
254
  InlineQueryResultCachedVoice,
219
255
  InlineQueryResultCachedAudio,
256
+ InputMessageContent,
257
+ InputMessageContentAdapter,
220
258
  InputTextMessageContent,
221
259
  InputLocationMessageContent,
222
260
  InputVenueMessageContent,
@@ -235,10 +273,14 @@ from .types import (
235
273
  ShippingQuery,
236
274
  PreCheckoutQuery,
237
275
  PaidMediaPurchased,
276
+ RevenueWithdrawalState,
277
+ RevenueWithdrawalStateAdapter,
238
278
  RevenueWithdrawalStatePending,
239
279
  RevenueWithdrawalStateSucceeded,
240
280
  RevenueWithdrawalStateFailed,
241
281
  AffiliateInfo,
282
+ TransactionPartner,
283
+ TransactionPartnerAdapter,
242
284
  TransactionPartnerUser,
243
285
  TransactionPartnerChat,
244
286
  TransactionPartnerAffiliateProgram,
@@ -252,6 +294,8 @@ from .types import (
252
294
  PassportFile,
253
295
  EncryptedPassportElement,
254
296
  EncryptedCredentials,
297
+ PassportElementError,
298
+ PassportElementErrorAdapter,
255
299
  PassportElementErrorDataField,
256
300
  PassportElementErrorFrontSide,
257
301
  PassportElementErrorReverseSide,
@@ -264,48 +308,6 @@ from .types import (
264
308
  Game,
265
309
  CallbackGame,
266
310
  GameHighScore,
267
- MaybeInaccessibleMessage,
268
- MaybeInaccessibleMessageAdapter,
269
- MessageOrigin,
270
- MessageOriginAdapter,
271
- PaidMedia,
272
- PaidMediaAdapter,
273
- BackgroundFill,
274
- BackgroundFillAdapter,
275
- BackgroundType,
276
- BackgroundTypeAdapter,
277
- ChatMember,
278
- ChatMemberAdapter,
279
- StoryAreaType,
280
- StoryAreaTypeAdapter,
281
- ReactionType,
282
- ReactionTypeAdapter,
283
- OwnedGift,
284
- OwnedGiftAdapter,
285
- BotCommandScope,
286
- BotCommandScopeAdapter,
287
- MenuButton,
288
- MenuButtonAdapter,
289
- ChatBoostSource,
290
- ChatBoostSourceAdapter,
291
- InputMedia,
292
- InputMediaAdapter,
293
- InputPaidMedia,
294
- InputPaidMediaAdapter,
295
- InputProfilePhoto,
296
- InputProfilePhotoAdapter,
297
- InputStoryContent,
298
- InputStoryContentAdapter,
299
- InlineQueryResult,
300
- InlineQueryResultAdapter,
301
- InputMessageContent,
302
- InputMessageContentAdapter,
303
- RevenueWithdrawalState,
304
- RevenueWithdrawalStateAdapter,
305
- TransactionPartner,
306
- TransactionPartnerAdapter,
307
- PassportElementError,
308
- PassportElementErrorAdapter,
309
311
  IntAdapter,
310
312
  StrAdapter,
311
313
  FloatAdapter,
@@ -0,0 +1,20 @@
1
+ import enum
2
+
3
+ from typing import TypeVar, Callable
4
+
5
+ # Enums
6
+ E = TypeVar('E', bound=enum.Enum)
7
+
8
+ def extend_enum(*sources: type[E]) -> Callable[..., type[E]]:
9
+ '''
10
+ Decorator that extends an Enum class with members
11
+ from one or more source Enum classes.
12
+ '''
13
+ def decorator(target: type[E]) -> type[E]:
14
+ for source in sources:
15
+ for member in source:
16
+ if member.name not in target.__members__:
17
+ target._member_map_[member.name] = member
18
+ return target
19
+ return decorator
20
+
@@ -0,0 +1,164 @@
1
+ import enum
2
+
3
+ from . import boilerplate
4
+
5
+ class ChatType(enum.StrEnum):
6
+ PRIVATE = 'private'
7
+ GROUP = 'group'
8
+ SUPERGROUP = 'supergroup'
9
+ CHANNEL = 'channel'
10
+
11
+ class UpdateType(enum.StrEnum):
12
+ '''
13
+ Types of updates that a bot can receive.
14
+
15
+ You can use these to filter updates, using the `allowed_updates`
16
+ parameter in `getUpdates` and `setWebhook` methods.
17
+ '''
18
+ MESSAGE = 'message'
19
+ EDITED_MESSAGE = 'edited_message'
20
+ CHANNEL_POST = 'channel_post'
21
+ EDITED_CHANNEL_POST = 'edited_channel_post'
22
+ INLINE_QUERY = 'inline_query'
23
+ CHOSEN_INLINE_RESULT = 'chosen_inline_result'
24
+ CALLBACK_QUERY = 'callback_query'
25
+ SHIPPING_QUERY = 'shipping_query'
26
+ PRE_CHECKOUT_QUERY = 'pre_checkout_query'
27
+ POLL = 'poll'
28
+ POLL_ANSWER = 'poll_answer'
29
+ CHAT_MEMBER_UPDATED = 'chat_member_updated'
30
+ CHAT_JOIN_REQUEST = 'chat_join_request'
31
+
32
+ class MediaType(enum.StrEnum):
33
+ '''
34
+ These are messages containing some kind of multimedia/visual content,
35
+ and NOT text-centric content.
36
+ '''
37
+ ANIMATION = 'animation'
38
+ AUDIO = 'audio'
39
+ DOCUMENT = 'document'
40
+ PHOTO = 'photo'
41
+ STICKER = 'sticker'
42
+ VIDEO = 'video'
43
+ VIDEO_NOTE = 'video_note'
44
+ VOICE = 'voice'
45
+ STORY = 'story'
46
+ PAID_MEDIA = 'paid_media'
47
+
48
+ class ServiceMessage(enum.StrEnum):
49
+ '''
50
+ These are special types of messages that convey service information.
51
+
52
+ They are ALL represented as semi-transparent bubbles in Telegram apps UI,
53
+ containing text and/or graphical elements (e.g. gifts, giveaways).
54
+ '''
55
+ NEW_CHAT_MEMBERS = 'new_chat_members'
56
+ LEFT_CHAT_MEMBER = 'left_chat_member'
57
+ NEW_CHAT_TITLE = 'new_chat_title'
58
+ NEW_CHAT_PHOTO = 'new_chat_photo'
59
+ DELETE_CHAT_PHOTO = 'delete_chat_photo'
60
+ GROUP_CHAT_CREATED = 'group_chat_created'
61
+ SUPERGROUP_CHAT_CREATED = 'supergroup_chat_created'
62
+ CHANNEL_CHAT_CREATED = 'channel_chat_created'
63
+ MESSAGE_AUTO_DELETE_TIMER_CHANGED = 'message_auto_delete_timer_changed'
64
+ MIGRATE_TO_CHAT_ID = 'migrate_to_chat_id'
65
+ MIGRATE_FROM_CHAT_ID = 'migrate_from_chat_id'
66
+ PINNED_MESSAGE = 'pinned_message'
67
+ SUCCESSFUL_PAYMENT = 'successful_payment'
68
+ REFUNDED_PAYMENT = 'refunded_payment'
69
+ USERS_SHARED = 'users_shared'
70
+ CHAT_SHARED = 'chat_shared'
71
+ GIFT = 'gift'
72
+ UNIQUE_GIFT = 'unique_gift'
73
+ CONNECTED_WEBSITE = 'connected_website'
74
+ WRITE_ACCESS_ALLOWED = 'write_access_allowed'
75
+ PASSPORT_DATA = 'passport_data'
76
+ PROXIMITY_ALERT_TRIGGERED = 'proximity_alert_triggered'
77
+ BOOST_ADDED = 'boost_added'
78
+ CHAT_BACKGROUND_SET = 'chat_background_set'
79
+ CHECKLIST_TASKS_DONE = 'checklist_tasks_done'
80
+ CHECKLIST_TASKS_ADDED = 'checklist_tasks_added'
81
+ DIRECT_MESSAGE_PRICE_CHANGED = 'direct_message_price_changed'
82
+ FORUM_TOPIC_CREATED = 'forum_topic_created'
83
+ FORUM_TOPIC_EDITED = 'forum_topic_edited'
84
+ FORUM_TOPIC_CLOSED = 'forum_topic_closed'
85
+ FORUM_TOPIC_REOPENED = 'forum_topic_reopened'
86
+ GENERAL_FORUM_TOPIC_HIDDEN = 'general_forum_topic_hidden'
87
+ GENERAL_FORUM_TOPIC_UNHIDDEN = 'general_forum_topic_unhidden'
88
+ GIVEAWAY = 'giveaway'
89
+ GIVEAWAY_CREATED = 'giveaway_created'
90
+ GIVEAWAY_WINNERS = 'giveaway_winners'
91
+ GIVEAWAY_COMPLETED = 'giveaway_completed'
92
+ PAID_MESSAGE_PRICE_CHANGED = 'paid_message_price_changed'
93
+ SUGGESTED_POST_APPROVED = 'suggested_post_approved'
94
+ SUGGESTED_POST_APPROVAL_FAILED = 'suggested_post_approval_failed'
95
+ SUGGESTED_POST_DECLINED = 'suggested_post_declined'
96
+ SUGGESTED_POST_PAID = 'suggested_post_paid'
97
+ SUGGESTED_POST_REFUNDED = 'suggested_post_refunded'
98
+ VIDEO_CHAT_SCHEDULED = 'video_chat_scheduled'
99
+ VIDEO_CHAT_STARTED = 'video_chat_started'
100
+ VIDEO_CHAT_ENDED = 'video_chat_ended'
101
+ VIDEO_CHAT_PARTICIPANTS_INVITED = 'video_chat_participants_invited'
102
+ WEB_APP_DATA = 'web_app_data'
103
+ SUGGESTED_POST = 'suggested_post_info'
104
+
105
+ @boilerplate.extend_enum(MediaType, ServiceMessage)
106
+ class MessageType(enum.StrEnum):
107
+ '''
108
+ The content of this message.
109
+ All of these fields should be mutually exclusive.
110
+ '''
111
+ TEXT = 'text'
112
+ CHECKLIST = 'checklist'
113
+ POLL = 'poll'
114
+ GAME = 'game'
115
+ INVOICE = 'invoice'
116
+ DICE = 'dice'
117
+ VENUE = 'venue'
118
+ LOCATION = 'location'
119
+ CONTACT = 'contact'
120
+
121
+ class ChatMemberStatus(enum.StrEnum):
122
+ '''
123
+ Statuses of a chat member.
124
+
125
+ Note that left members that are also restricted (muted), are represented as
126
+ `RESTRICTED` with the `is_member` flag set to `False`.
127
+
128
+ See: https://core.telegram.org/bots/api#chatmember
129
+ '''
130
+ CREATOR = 'creator'
131
+ ADMINISTRATOR = 'administrator'
132
+ MEMBER = 'member'
133
+ RESTRICTED = 'restricted'
134
+ LEFT = 'left'
135
+ BANNED = 'kicked'
136
+
137
+ class ParseMode(enum.StrEnum):
138
+ '''
139
+ Available parse modes for formatting text messages.
140
+
141
+ See: https://core.telegram.org/bots/api#formatting-options
142
+ '''
143
+ MARKDOWN = 'Markdown'
144
+ MARKDOWN_V2 = 'MarkdownV2'
145
+ HTML = 'HTML'
146
+
147
+ class ChatAction(enum.StrEnum):
148
+ '''
149
+ Types of actions that a bot can send using the `sendChatAction` method.
150
+
151
+ See: https://core.telegram.org/bots/api#sendchataction
152
+ '''
153
+ TYPING = 'typing'
154
+ UPLOAD_PHOTO = 'upload_photo'
155
+ RECORD_VIDEO = 'record_video'
156
+ UPLOAD_VIDEO = 'upload_video'
157
+ RECORD_VOICE = 'record_voice'
158
+ UPLOAD_VOICE = 'upload_voice'
159
+ UPLOAD_DOCUMENT = 'upload_document'
160
+ CHOOSE_STICKER = 'choose_sticker'
161
+ FIND_LOCATION = 'find_location'
162
+ RECORD_VIDEO_NOTE = 'record_video_note'
163
+ UPLOAD_VIDEO_NOTE = 'upload_video_note'
164
+