botapi-py 1.5.9__tar.gz → 1.5.10__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,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: botapi-py
3
- Version: 1.5.9
3
+ Version: 1.5.10
4
4
  Summary: A simple and flexible Python library to conveniently build fast Telegram bots using the Bot API.
5
5
  Requires-Dist: httpx>=0.28.1
6
6
  Requires-Dist: pydantic>=2.12.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "botapi-py"
3
- version = "1.5.9"
3
+ version = "1.5.10"
4
4
  description = "A simple and flexible Python library to conveniently build fast Telegram bots using the Bot API."
5
5
  # readme = "README.md"
6
6
  # authors = [
@@ -133,6 +133,7 @@ class OtherMessageType(enum.StrEnum):
133
133
  multimedia nor service content.
134
134
  '''
135
135
  TEXT = 'text'
136
+ RICH_MESSAGE = 'rich_message'
136
137
  CHECKLIST = 'checklist'
137
138
  POLL = 'poll'
138
139
  GAME = 'game'
@@ -53,6 +53,7 @@ from .types import (
53
53
  PaidMediaVideo,
54
54
  Contact,
55
55
  Dice,
56
+ Link,
56
57
  PollMedia,
57
58
  InputPollMedia,
58
59
  _InputPollMedia,
@@ -251,6 +252,7 @@ from .types import (
251
252
  InputMediaAnimation,
252
253
  InputMediaAudio,
253
254
  InputMediaDocument,
255
+ InputMediaLink,
254
256
  InputMediaLivePhoto,
255
257
  InputMediaLocation,
256
258
  InputMediaPhoto,
@@ -278,6 +280,63 @@ from .types import (
278
280
  StickerSet,
279
281
  MaskPosition,
280
282
  InputSticker,
283
+ RichMessage,
284
+ InputRichMessage,
285
+ RichText,
286
+ _RichText,
287
+ RichTextAdapter,
288
+ RichTextBold,
289
+ RichTextItalic,
290
+ RichTextUnderline,
291
+ RichTextStrikethrough,
292
+ RichTextSpoiler,
293
+ RichTextDateTime,
294
+ RichTextTextMention,
295
+ RichTextSubscript,
296
+ RichTextSuperscript,
297
+ RichTextMarked,
298
+ RichTextCode,
299
+ RichTextCustomEmoji,
300
+ RichTextMathematicalExpression,
301
+ RichTextUrl,
302
+ RichTextEmailAddress,
303
+ RichTextPhoneNumber,
304
+ RichTextBankCardNumber,
305
+ RichTextMention,
306
+ RichTextHashtag,
307
+ RichTextCashtag,
308
+ RichTextBotCommand,
309
+ RichTextAnchor,
310
+ RichTextAnchorLink,
311
+ RichTextReference,
312
+ RichTextReferenceLink,
313
+ RichBlockCaption,
314
+ RichBlockTableCell,
315
+ RichBlockListItem,
316
+ RichBlock,
317
+ _RichBlock,
318
+ RichBlockAdapter,
319
+ RichBlockParagraph,
320
+ RichBlockSectionHeading,
321
+ RichBlockPreformatted,
322
+ RichBlockFooter,
323
+ RichBlockDivider,
324
+ RichBlockMathematicalExpression,
325
+ RichBlockAnchor,
326
+ RichBlockList,
327
+ RichBlockBlockQuotation,
328
+ RichBlockPullQuotation,
329
+ RichBlockCollage,
330
+ RichBlockSlideshow,
331
+ RichBlockTable,
332
+ RichBlockDetails,
333
+ RichBlockMap,
334
+ RichBlockAnimation,
335
+ RichBlockAudio,
336
+ RichBlockPhoto,
337
+ RichBlockVideo,
338
+ RichBlockVoiceNote,
339
+ RichBlockThinking,
281
340
  InlineQuery,
282
341
  InlineQueryResultsButton,
283
342
  InlineQueryResult,
@@ -307,6 +366,7 @@ from .types import (
307
366
  _InputMessageContent,
308
367
  InputMessageContentAdapter,
309
368
  InputTextMessageContent,
369
+ InputRichMessageContent,
310
370
  InputLocationMessageContent,
311
371
  InputVenueMessageContent,
312
372
  InputContactMessageContent,
@@ -2160,6 +2220,44 @@ class Methods(core.BaseBot):
2160
2220
  })
2161
2221
  return BoolAdapter.validate_python(response)
2162
2222
 
2223
+ async def answer_chat_join_request_query(
2224
+ self,
2225
+ chat_join_request_query_id: str,
2226
+ result: str,
2227
+ ) -> bool:
2228
+ '''
2229
+ Use this method to process a received chat
2230
+ join request query. Returns True on success.
2231
+
2232
+ Reference: https://core.telegram.org/bots/api#answerchatjoinrequestquery
2233
+ '''
2234
+
2235
+ response = await self._send_request('answerChatJoinRequestQuery', {
2236
+ 'chat_join_request_query_id': chat_join_request_query_id,
2237
+ 'result': result,
2238
+ })
2239
+ return BoolAdapter.validate_python(response)
2240
+
2241
+ async def send_chat_join_request_web_app(
2242
+ self,
2243
+ chat_join_request_query_id: str,
2244
+ web_app_url: str,
2245
+ ) -> bool:
2246
+ '''
2247
+ Use this method to process a received chat
2248
+ join request query by showing a Mini App
2249
+ to the user before deciding the outcome. Returns
2250
+ True on success.
2251
+
2252
+ Reference: https://core.telegram.org/bots/api#sendchatjoinrequestwebapp
2253
+ '''
2254
+
2255
+ response = await self._send_request('sendChatJoinRequestWebApp', {
2256
+ 'chat_join_request_query_id': chat_join_request_query_id,
2257
+ 'web_app_url': web_app_url,
2258
+ })
2259
+ return BoolAdapter.validate_python(response)
2260
+
2163
2261
  async def set_chat_photo(
2164
2262
  self,
2165
2263
  chat_id: Union[int, str],
@@ -3881,25 +3979,26 @@ class Methods(core.BaseBot):
3881
3979
 
3882
3980
  async def edit_message_text(
3883
3981
  self,
3884
- text: str,
3885
3982
  business_connection_id: Optional[str] = None,
3886
3983
  chat_id: Optional[Union[int, str]] = None,
3887
3984
  message_id: Optional[int] = None,
3888
3985
  inline_message_id: Optional[str] = None,
3986
+ text: Optional[str] = None,
3889
3987
  parse_mode: Optional[Union[str, enums.ParseMode]] = None,
3890
3988
  entities: Optional[List[MessageEntity]] = None,
3891
3989
  link_preview_options: Optional[LinkPreviewOptions] = None,
3990
+ rich_message: Optional[InputRichMessage] = None,
3892
3991
  reply_markup: Optional[InlineKeyboardMarkup] = None,
3893
3992
  ) -> Union[Message, bool]:
3894
3993
  '''
3895
- Use this method to edit text and game
3896
- messages. On success, if the edited message is
3897
- not an inline message, the edited Message is
3898
- returned, otherwise True is returned. Note that business
3899
- messages that were not sent by the bot
3900
- and do not contain an inline keyboard can
3901
- only be edited within 48 hours from the
3902
- time they were sent.
3994
+ Use this method to edit text, rich and
3995
+ game messages. On success, if the edited message
3996
+ is not an inline message, the edited Message
3997
+ is returned, otherwise True is returned. Note that
3998
+ business messages that were not sent by the
3999
+ bot and do not contain an inline keyboard
4000
+ can only be edited within 48 hours from
4001
+ the time they were sent.
3903
4002
 
3904
4003
  Reference: https://core.telegram.org/bots/api#editmessagetext
3905
4004
  '''
@@ -3913,6 +4012,7 @@ class Methods(core.BaseBot):
3913
4012
  'parse_mode': parse_mode,
3914
4013
  'entities': entities,
3915
4014
  'link_preview_options': link_preview_options,
4015
+ 'rich_message': rich_message,
3916
4016
  'reply_markup': reply_markup,
3917
4017
  })
3918
4018
  if isinstance(response, (dict, list)):
@@ -3973,21 +4073,22 @@ class Methods(core.BaseBot):
3973
4073
  '''
3974
4074
  Use this method to edit animation, audio, document,
3975
4075
  live photo, photo, or video messages, or to
3976
- add media to text messages. If a message
3977
- is part of a message album, then it
3978
- can be edited only to an audio for
3979
- audio albums, only to a document for document
3980
- albums and to a photo, a live photo,
3981
- or a video otherwise. When an inline message
3982
- is edited, a new file can't be uploaded;
3983
- use a previously uploaded file via its file_id
3984
- or specify a URL. On success, if the
3985
- edited message is not an inline message, the
3986
- edited Message is returned, otherwise True is returned.
3987
- Note that business messages that were not sent
3988
- by the bot and do not contain an
3989
- inline keyboard can only be edited within 48
3990
- hours from the time they were sent.
4076
+ replace a text or a rich message with
4077
+ a media. If a message is part of
4078
+ a message album, then it can be edited
4079
+ only to an audio for audio albums, only
4080
+ to a document for document albums and to
4081
+ a photo, a live photo, or a video
4082
+ otherwise. When an inline message is edited, a
4083
+ new file can't be uploaded; use a previously
4084
+ uploaded file via its file_id or specify a
4085
+ URL. On success, if the edited message is
4086
+ not an inline message, the edited Message is
4087
+ returned, otherwise True is returned. Note that business
4088
+ messages that were not sent by the bot
4089
+ and do not contain an inline keyboard can
4090
+ only be edited within 48 hours from the
4091
+ time they were sent.
3991
4092
 
3992
4093
  Reference: https://core.telegram.org/bots/api#editmessagemedia
3993
4094
  '''
@@ -4651,6 +4752,75 @@ class Methods(core.BaseBot):
4651
4752
  })
4652
4753
  return BoolAdapter.validate_python(response)
4653
4754
 
4755
+ async def send_rich_message(
4756
+ self,
4757
+ chat_id: Union[int, str],
4758
+ rich_message: InputRichMessage,
4759
+ business_connection_id: Optional[str] = None,
4760
+ message_thread_id: Optional[int] = None,
4761
+ direct_messages_topic_id: Optional[int] = None,
4762
+ disable_notification: Optional[bool] = None,
4763
+ protect_content: Optional[bool] = None,
4764
+ allow_paid_broadcast: Optional[bool] = None,
4765
+ message_effect_id: Optional[str] = None,
4766
+ suggested_post_parameters: Optional[SuggestedPostParameters] = None,
4767
+ reply_parameters: Optional[ReplyParameters] = None,
4768
+ reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None,
4769
+ ) -> Message:
4770
+ '''
4771
+ Use this method to send rich messages. If
4772
+ the message contains a block with a media
4773
+ element, then the bot must have the right
4774
+ to send the media to the chat. On
4775
+ success, the sent Message is returned.
4776
+
4777
+ Reference: https://core.telegram.org/bots/api#sendrichmessage
4778
+ '''
4779
+
4780
+ response = await self._send_request('sendRichMessage', {
4781
+ 'business_connection_id': business_connection_id,
4782
+ 'chat_id': chat_id,
4783
+ 'message_thread_id': message_thread_id,
4784
+ 'direct_messages_topic_id': direct_messages_topic_id,
4785
+ 'rich_message': rich_message,
4786
+ 'disable_notification': disable_notification,
4787
+ 'protect_content': protect_content,
4788
+ 'allow_paid_broadcast': allow_paid_broadcast,
4789
+ 'message_effect_id': message_effect_id,
4790
+ 'suggested_post_parameters': suggested_post_parameters,
4791
+ 'reply_parameters': reply_parameters,
4792
+ 'reply_markup': reply_markup,
4793
+ })
4794
+ return Message.model_validate(response)
4795
+
4796
+ async def send_rich_message_draft(
4797
+ self,
4798
+ chat_id: int,
4799
+ draft_id: int,
4800
+ rich_message: InputRichMessage,
4801
+ message_thread_id: Optional[int] = None,
4802
+ ) -> bool:
4803
+ '''
4804
+ Use this method to stream a partial rich
4805
+ message to a user while the message is
4806
+ being generated. Note that the streamed draft is
4807
+ ephemeral and acts as a temporary 30-second preview
4808
+ - once the output is finalized, you must
4809
+ call sendRichMessage with the complete message to persist
4810
+ it in the user's chat. Returns True on
4811
+ success.
4812
+
4813
+ Reference: https://core.telegram.org/bots/api#sendrichmessagedraft
4814
+ '''
4815
+
4816
+ response = await self._send_request('sendRichMessageDraft', {
4817
+ 'chat_id': chat_id,
4818
+ 'message_thread_id': message_thread_id,
4819
+ 'draft_id': draft_id,
4820
+ 'rich_message': rich_message,
4821
+ })
4822
+ return BoolAdapter.validate_python(response)
4823
+
4654
4824
  async def answer_inline_query(
4655
4825
  self,
4656
4826
  inline_query_id: str,
@@ -63,6 +63,7 @@ class Message(MaybeInaccessibleMessage):
63
63
  link_preview_options: Optional[LinkPreviewOptions] = Field(default=None)
64
64
  suggested_post_info: Optional[SuggestedPostInfo] = Field(default=None)
65
65
  effect_id: Optional[str] = Field(default=None)
66
+ rich_message: Optional[RichMessage] = Field(default=None)
66
67
  animation: Optional[Animation] = Field(default=None)
67
68
  audio: Optional[Audio] = Field(default=None)
68
69
  document: Optional[Document] = Field(default=None)
@@ -318,7 +319,7 @@ class Message(MaybeInaccessibleMessage):
318
319
  reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]] = None,
319
320
  ) -> Message:
320
321
  '''
321
- Replies to this message with a text message.
322
+ Reply to this message with a text message.
322
323
  Shortcut for `bot.send_message`.
323
324
 
324
325
  You can pass **either** `parse_mode` or `entities` to format the message text.
@@ -694,7 +695,17 @@ _InputPollMedia = Union[
694
695
  InputPollMediaAdapter = TypeAdapter[_InputPollMedia](_InputPollMedia)
695
696
 
696
697
  class InputPollOptionMedia(BaseModel):
697
- type: Literal['animation', 'live_photo', 'location', 'photo', 'sticker', 'venue', 'video']
698
+ type: Literal['animation', 'link', 'live_photo', 'location', 'photo', 'sticker', 'venue', 'video']
699
+
700
+ class InputMediaLink(InputPollOptionMedia):
701
+ '''
702
+ Represents an HTTP link to be sent.
703
+
704
+ Reference: https://core.telegram.org/bots/api#inputmedialink
705
+ '''
706
+
707
+ type: Literal['link'] = 'link' # pyright: ignore[reportIncompatibleVariableOverride]
708
+ url: str
698
709
 
699
710
  class InputMediaSticker(InputPollOptionMedia):
700
711
  '''
@@ -709,6 +720,7 @@ class InputMediaSticker(InputPollOptionMedia):
709
720
 
710
721
  _InputPollOptionMedia = Union[
711
722
  InputMediaAnimation,
723
+ InputMediaLink,
712
724
  InputMediaLivePhoto,
713
725
  InputMediaLocation,
714
726
  InputMediaPhoto,
@@ -833,7 +845,7 @@ class ChatMember(BaseModel):
833
845
  @property
834
846
  def is_participant(self) -> bool:
835
847
  '''
836
- Returns a boolean indicating if the user is currently part of of the chat (i.e. not left/banned).
848
+ Boolean indicating if the user is currently part of of the chat (i.e. not left/banned).
837
849
 
838
850
  This function handles special cases, like `ChatMemberRestricted` with the `is_member` flag.
839
851
  '''
@@ -855,7 +867,7 @@ class ChatMember(BaseModel):
855
867
  until_date: Optional[int] = None
856
868
  ) -> bool:
857
869
  '''
858
- Bans this chat member.
870
+ Ban this chat member.
859
871
  '''
860
872
  return await bot.ban_chat_member(
861
873
  chat_id=chat_id,
@@ -871,7 +883,7 @@ class ChatMember(BaseModel):
871
883
  only_if_banned: Optional[bool] = None
872
884
  ) -> bool:
873
885
  '''
874
- Unbans this chat member.
886
+ Unban this chat member.
875
887
  '''
876
888
  return await bot.unban_chat_member(
877
889
  chat_id=chat_id,
@@ -885,7 +897,7 @@ class ChatMember(BaseModel):
885
897
  chat_id: Union[int, str]
886
898
  ) -> bool:
887
899
  '''
888
- Kicks this chat member (bans and immediately unbans).
900
+ Kick this chat member (ban and immediately unban).
889
901
  '''
890
902
  return await bot.unban_chat_member(
891
903
  chat_id=chat_id,
@@ -900,7 +912,7 @@ class ChatMember(BaseModel):
900
912
  until_date: Optional[int] = None
901
913
  ) -> bool:
902
914
  '''
903
- Mutes (restricts) this chat member.
915
+ Mute (restrict) this chat member.
904
916
  '''
905
917
  return await bot.restrict_chat_member(
906
918
  chat_id=chat_id,
@@ -1567,6 +1579,587 @@ _InputStoryContent = Union[
1567
1579
  ]
1568
1580
  InputStoryContentAdapter = TypeAdapter[_InputStoryContent](_InputStoryContent)
1569
1581
 
1582
+ class RichText(BaseModel):
1583
+ type: Literal['bold', 'italic', 'underline', 'strikethrough', 'spoiler', 'date_time', 'text_mention', 'subscript', 'superscript', 'marked', 'code', 'custom_emoji', 'mathematical_expression', 'url', 'email_address', 'phone_number', 'bank_card_number', 'mention', 'hashtag', 'cashtag', 'bot_command', 'anchor', 'anchor_link', 'reference', 'reference_link']
1584
+
1585
+ class RichTextBold(RichText):
1586
+ '''
1587
+ A bold text.
1588
+
1589
+ Reference: https://core.telegram.org/bots/api#richtextbold
1590
+ '''
1591
+
1592
+ type: Literal['bold'] = 'bold' # pyright: ignore[reportIncompatibleVariableOverride]
1593
+ text: _RichText
1594
+
1595
+ class RichTextItalic(RichText):
1596
+ '''
1597
+ An italicized text.
1598
+
1599
+ Reference: https://core.telegram.org/bots/api#richtextitalic
1600
+ '''
1601
+
1602
+ type: Literal['italic'] = 'italic' # pyright: ignore[reportIncompatibleVariableOverride]
1603
+ text: _RichText
1604
+
1605
+ class RichTextUnderline(RichText):
1606
+ '''
1607
+ An underlined text.
1608
+
1609
+ Reference: https://core.telegram.org/bots/api#richtextunderline
1610
+ '''
1611
+
1612
+ type: Literal['underline'] = 'underline' # pyright: ignore[reportIncompatibleVariableOverride]
1613
+ text: _RichText
1614
+
1615
+ class RichTextStrikethrough(RichText):
1616
+ '''
1617
+ A strikethrough text.
1618
+
1619
+ Reference: https://core.telegram.org/bots/api#richtextstrikethrough
1620
+ '''
1621
+
1622
+ type: Literal['strikethrough'] = 'strikethrough' # pyright: ignore[reportIncompatibleVariableOverride]
1623
+ text: _RichText
1624
+
1625
+ class RichTextSpoiler(RichText):
1626
+ '''
1627
+ A text covered by a spoiler.
1628
+
1629
+ Reference: https://core.telegram.org/bots/api#richtextspoiler
1630
+ '''
1631
+
1632
+ type: Literal['spoiler'] = 'spoiler' # pyright: ignore[reportIncompatibleVariableOverride]
1633
+ text: _RichText
1634
+
1635
+ class RichTextDateTime(RichText):
1636
+ '''
1637
+ Formatted date and time.
1638
+
1639
+ Reference: https://core.telegram.org/bots/api#richtextdatetime
1640
+ '''
1641
+
1642
+ type: Literal['date_time'] = 'date_time' # pyright: ignore[reportIncompatibleVariableOverride]
1643
+ text: _RichText
1644
+ unix_time: int
1645
+ date_time_format: str
1646
+
1647
+ class RichTextTextMention(RichText):
1648
+ '''
1649
+ A mention of a Telegram user by their
1650
+ identifier.
1651
+
1652
+ Reference: https://core.telegram.org/bots/api#richtexttextmention
1653
+ '''
1654
+
1655
+ type: Literal['text_mention'] = 'text_mention' # pyright: ignore[reportIncompatibleVariableOverride]
1656
+ text: _RichText
1657
+ user: User
1658
+
1659
+ class RichTextSubscript(RichText):
1660
+ '''
1661
+ A subscript text.
1662
+
1663
+ Reference: https://core.telegram.org/bots/api#richtextsubscript
1664
+ '''
1665
+
1666
+ type: Literal['subscript'] = 'subscript' # pyright: ignore[reportIncompatibleVariableOverride]
1667
+ text: _RichText
1668
+
1669
+ class RichTextSuperscript(RichText):
1670
+ '''
1671
+ A superscript text.
1672
+
1673
+ Reference: https://core.telegram.org/bots/api#richtextsuperscript
1674
+ '''
1675
+
1676
+ type: Literal['superscript'] = 'superscript' # pyright: ignore[reportIncompatibleVariableOverride]
1677
+ text: _RichText
1678
+
1679
+ class RichTextMarked(RichText):
1680
+ '''
1681
+ A marked text.
1682
+
1683
+ Reference: https://core.telegram.org/bots/api#richtextmarked
1684
+ '''
1685
+
1686
+ type: Literal['marked'] = 'marked' # pyright: ignore[reportIncompatibleVariableOverride]
1687
+ text: _RichText
1688
+
1689
+ class RichTextCode(RichText):
1690
+ '''
1691
+ A monowidth text.
1692
+
1693
+ Reference: https://core.telegram.org/bots/api#richtextcode
1694
+ '''
1695
+
1696
+ type: Literal['code'] = 'code' # pyright: ignore[reportIncompatibleVariableOverride]
1697
+ text: _RichText
1698
+
1699
+ class RichTextCustomEmoji(RichText):
1700
+ '''
1701
+ A custom emoji.
1702
+
1703
+ Reference: https://core.telegram.org/bots/api#richtextcustomemoji
1704
+ '''
1705
+
1706
+ type: Literal['custom_emoji'] = 'custom_emoji' # pyright: ignore[reportIncompatibleVariableOverride]
1707
+ custom_emoji_id: str
1708
+ alternative_text: str
1709
+
1710
+ class RichTextMathematicalExpression(RichText):
1711
+ '''
1712
+ A mathematical expression.
1713
+
1714
+ Reference: https://core.telegram.org/bots/api#richtextmathematicalexpression
1715
+ '''
1716
+
1717
+ type: Literal['mathematical_expression'] = 'mathematical_expression' # pyright: ignore[reportIncompatibleVariableOverride]
1718
+ expression: str
1719
+
1720
+ class RichTextUrl(RichText):
1721
+ '''
1722
+ A text with a link.
1723
+
1724
+ Reference: https://core.telegram.org/bots/api#richtexturl
1725
+ '''
1726
+
1727
+ type: Literal['url'] = 'url' # pyright: ignore[reportIncompatibleVariableOverride]
1728
+ text: _RichText
1729
+ url: str
1730
+
1731
+ class RichTextEmailAddress(RichText):
1732
+ '''
1733
+ A text with an email address.
1734
+
1735
+ Reference: https://core.telegram.org/bots/api#richtextemailaddress
1736
+ '''
1737
+
1738
+ type: Literal['email_address'] = 'email_address' # pyright: ignore[reportIncompatibleVariableOverride]
1739
+ text: _RichText
1740
+ email_address: str
1741
+
1742
+ class RichTextPhoneNumber(RichText):
1743
+ '''
1744
+ A text with a phone number.
1745
+
1746
+ Reference: https://core.telegram.org/bots/api#richtextphonenumber
1747
+ '''
1748
+
1749
+ type: Literal['phone_number'] = 'phone_number' # pyright: ignore[reportIncompatibleVariableOverride]
1750
+ text: _RichText
1751
+ phone_number: str
1752
+
1753
+ class RichTextBankCardNumber(RichText):
1754
+ '''
1755
+ A text with a bank card number.
1756
+
1757
+ Reference: https://core.telegram.org/bots/api#richtextbankcardnumber
1758
+ '''
1759
+
1760
+ type: Literal['bank_card_number'] = 'bank_card_number' # pyright: ignore[reportIncompatibleVariableOverride]
1761
+ text: _RichText
1762
+ bank_card_number: str
1763
+
1764
+ class RichTextMention(RichText):
1765
+ '''
1766
+ A mention by a username.
1767
+
1768
+ Reference: https://core.telegram.org/bots/api#richtextmention
1769
+ '''
1770
+
1771
+ type: Literal['mention'] = 'mention' # pyright: ignore[reportIncompatibleVariableOverride]
1772
+ text: _RichText
1773
+ username: str
1774
+
1775
+ class RichTextHashtag(RichText):
1776
+ '''
1777
+ A hashtag.
1778
+
1779
+ Reference: https://core.telegram.org/bots/api#richtexthashtag
1780
+ '''
1781
+
1782
+ type: Literal['hashtag'] = 'hashtag' # pyright: ignore[reportIncompatibleVariableOverride]
1783
+ text: _RichText
1784
+ hashtag: str
1785
+
1786
+ class RichTextCashtag(RichText):
1787
+ '''
1788
+ A cashtag.
1789
+
1790
+ Reference: https://core.telegram.org/bots/api#richtextcashtag
1791
+ '''
1792
+
1793
+ type: Literal['cashtag'] = 'cashtag' # pyright: ignore[reportIncompatibleVariableOverride]
1794
+ text: _RichText
1795
+ cashtag: str
1796
+
1797
+ class RichTextBotCommand(RichText):
1798
+ '''
1799
+ A bot command.
1800
+
1801
+ Reference: https://core.telegram.org/bots/api#richtextbotcommand
1802
+ '''
1803
+
1804
+ type: Literal['bot_command'] = 'bot_command' # pyright: ignore[reportIncompatibleVariableOverride]
1805
+ text: _RichText
1806
+ bot_command: str
1807
+
1808
+ class RichTextAnchor(RichText):
1809
+ '''
1810
+ An anchor.
1811
+
1812
+ Reference: https://core.telegram.org/bots/api#richtextanchor
1813
+ '''
1814
+
1815
+ type: Literal['anchor'] = 'anchor' # pyright: ignore[reportIncompatibleVariableOverride]
1816
+ name: str
1817
+
1818
+ class RichTextAnchorLink(RichText):
1819
+ '''
1820
+ A link to an anchor.
1821
+
1822
+ Reference: https://core.telegram.org/bots/api#richtextanchorlink
1823
+ '''
1824
+
1825
+ type: Literal['anchor_link'] = 'anchor_link' # pyright: ignore[reportIncompatibleVariableOverride]
1826
+ text: _RichText
1827
+ anchor_name: str
1828
+
1829
+ class RichTextReference(RichText):
1830
+ '''
1831
+ A reference.
1832
+
1833
+ Reference: https://core.telegram.org/bots/api#richtextreference
1834
+ '''
1835
+
1836
+ type: Literal['reference'] = 'reference' # pyright: ignore[reportIncompatibleVariableOverride]
1837
+ text: _RichText
1838
+ name: str
1839
+
1840
+ class RichTextReferenceLink(RichText):
1841
+ '''
1842
+ A link to a reference.
1843
+
1844
+ Reference: https://core.telegram.org/bots/api#richtextreferencelink
1845
+ '''
1846
+
1847
+ type: Literal['reference_link'] = 'reference_link' # pyright: ignore[reportIncompatibleVariableOverride]
1848
+ text: _RichText
1849
+ reference_name: str
1850
+
1851
+ _RichText = Union[
1852
+ RichTextBold,
1853
+ RichTextItalic,
1854
+ RichTextUnderline,
1855
+ RichTextStrikethrough,
1856
+ RichTextSpoiler,
1857
+ RichTextDateTime,
1858
+ RichTextTextMention,
1859
+ RichTextSubscript,
1860
+ RichTextSuperscript,
1861
+ RichTextMarked,
1862
+ RichTextCode,
1863
+ RichTextCustomEmoji,
1864
+ RichTextMathematicalExpression,
1865
+ RichTextUrl,
1866
+ RichTextEmailAddress,
1867
+ RichTextPhoneNumber,
1868
+ RichTextBankCardNumber,
1869
+ RichTextMention,
1870
+ RichTextHashtag,
1871
+ RichTextCashtag,
1872
+ RichTextBotCommand,
1873
+ RichTextAnchor,
1874
+ RichTextAnchorLink,
1875
+ RichTextReference,
1876
+ RichTextReferenceLink,
1877
+ ]
1878
+ RichTextAdapter = TypeAdapter[_RichText](_RichText)
1879
+
1880
+ class RichBlock(BaseModel):
1881
+ type: Literal['paragraph', 'heading', 'pre', 'footer', 'divider', 'mathematical_expression', 'anchor', 'list', 'blockquote', 'pullquote', 'collage', 'slideshow', 'table', 'details', 'map', 'animation', 'audio', 'photo', 'video', 'voice_note', 'thinking']
1882
+
1883
+ class RichBlockParagraph(RichBlock):
1884
+ '''
1885
+ A text paragraph, corresponding to the HTML tag
1886
+ <p>.
1887
+
1888
+ Reference: https://core.telegram.org/bots/api#richblockparagraph
1889
+ '''
1890
+
1891
+ type: Literal['paragraph'] = 'paragraph' # pyright: ignore[reportIncompatibleVariableOverride]
1892
+ text: _RichText
1893
+
1894
+ class RichBlockSectionHeading(RichBlock):
1895
+ '''
1896
+ A section heading, corresponding to the HTML tags
1897
+ <h1>, <h2>, <h3>, <h4>, <h5>, or <h6>.
1898
+
1899
+ Reference: https://core.telegram.org/bots/api#richblocksectionheading
1900
+ '''
1901
+
1902
+ type: Literal['heading'] = 'heading' # pyright: ignore[reportIncompatibleVariableOverride]
1903
+ text: _RichText
1904
+ size: int
1905
+
1906
+ class RichBlockPreformatted(RichBlock):
1907
+ '''
1908
+ A preformatted text block, corresponding to the nested
1909
+ HTML tags <pre> and <code>.
1910
+
1911
+ Reference: https://core.telegram.org/bots/api#richblockpreformatted
1912
+ '''
1913
+
1914
+ type: Literal['pre'] = 'pre' # pyright: ignore[reportIncompatibleVariableOverride]
1915
+ text: _RichText
1916
+ language: Optional[str] = Field(default=None)
1917
+
1918
+ class RichBlockFooter(RichBlock):
1919
+ '''
1920
+ A footer, corresponding to the HTML tag <footer>.
1921
+
1922
+ Reference: https://core.telegram.org/bots/api#richblockfooter
1923
+ '''
1924
+
1925
+ type: Literal['footer'] = 'footer' # pyright: ignore[reportIncompatibleVariableOverride]
1926
+ text: _RichText
1927
+
1928
+ class RichBlockDivider(RichBlock):
1929
+ '''
1930
+ A divider, corresponding to the HTML tag <hr/>.
1931
+
1932
+ Reference: https://core.telegram.org/bots/api#richblockdivider
1933
+ '''
1934
+
1935
+ type: Literal['divider'] = 'divider' # pyright: ignore[reportIncompatibleVariableOverride]
1936
+
1937
+ class RichBlockMathematicalExpression(RichBlock):
1938
+ '''
1939
+ A block with a mathematical expression in LaTeX
1940
+ format, corresponding to the custom HTML tag <tg-math-block>.
1941
+
1942
+ Reference: https://core.telegram.org/bots/api#richblockmathematicalexpression
1943
+ '''
1944
+
1945
+ type: Literal['mathematical_expression'] = 'mathematical_expression' # pyright: ignore[reportIncompatibleVariableOverride]
1946
+ expression: str
1947
+
1948
+ class RichBlockAnchor(RichBlock):
1949
+ '''
1950
+ A block with an anchor, corresponding to the
1951
+ HTML tag <a> with the attribute name.
1952
+
1953
+ Reference: https://core.telegram.org/bots/api#richblockanchor
1954
+ '''
1955
+
1956
+ type: Literal['anchor'] = 'anchor' # pyright: ignore[reportIncompatibleVariableOverride]
1957
+ name: str
1958
+
1959
+ class RichBlockList(RichBlock):
1960
+ '''
1961
+ A list of blocks, corresponding to the HTML
1962
+ tag <ul> or <ol> with multiple nested tags
1963
+ <li>.
1964
+
1965
+ Reference: https://core.telegram.org/bots/api#richblocklist
1966
+ '''
1967
+
1968
+ type: Literal['list'] = 'list' # pyright: ignore[reportIncompatibleVariableOverride]
1969
+ items: List[RichBlockListItem]
1970
+
1971
+ class RichBlockBlockQuotation(RichBlock):
1972
+ '''
1973
+ A block quotation, corresponding to the HTML tag
1974
+ <blockquote>.
1975
+
1976
+ Reference: https://core.telegram.org/bots/api#richblockblockquotation
1977
+ '''
1978
+
1979
+ type: Literal['blockquote'] = 'blockquote' # pyright: ignore[reportIncompatibleVariableOverride]
1980
+ blocks: List[_RichBlock]
1981
+ credit: Optional[_RichText] = Field(default=None)
1982
+
1983
+ class RichBlockPullQuotation(RichBlock):
1984
+ '''
1985
+ A quotation with centered text, loosely corresponding to
1986
+ the HTML tag <aside>.
1987
+
1988
+ Reference: https://core.telegram.org/bots/api#richblockpullquotation
1989
+ '''
1990
+
1991
+ type: Literal['pullquote'] = 'pullquote' # pyright: ignore[reportIncompatibleVariableOverride]
1992
+ text: _RichText
1993
+ credit: Optional[_RichText] = Field(default=None)
1994
+
1995
+ class RichBlockCollage(RichBlock):
1996
+ '''
1997
+ A collage, corresponding to the custom HTML tag
1998
+ <tg-collage>.
1999
+
2000
+ Reference: https://core.telegram.org/bots/api#richblockcollage
2001
+ '''
2002
+
2003
+ type: Literal['collage'] = 'collage' # pyright: ignore[reportIncompatibleVariableOverride]
2004
+ blocks: List[_RichBlock]
2005
+ caption: Optional[RichBlockCaption] = Field(default=None)
2006
+
2007
+ class RichBlockSlideshow(RichBlock):
2008
+ '''
2009
+ A slideshow, corresponding to the custom HTML tag
2010
+ <tg-slideshow>.
2011
+
2012
+ Reference: https://core.telegram.org/bots/api#richblockslideshow
2013
+ '''
2014
+
2015
+ type: Literal['slideshow'] = 'slideshow' # pyright: ignore[reportIncompatibleVariableOverride]
2016
+ blocks: List[_RichBlock]
2017
+ caption: Optional[RichBlockCaption] = Field(default=None)
2018
+
2019
+ class RichBlockTable(RichBlock):
2020
+ '''
2021
+ A table, corresponding to the HTML tag <table>.
2022
+
2023
+ Reference: https://core.telegram.org/bots/api#richblocktable
2024
+ '''
2025
+
2026
+ type: Literal['table'] = 'table' # pyright: ignore[reportIncompatibleVariableOverride]
2027
+ cells: List[List[RichBlockTableCell]]
2028
+ is_bordered: Optional[bool] = Field(default=None)
2029
+ is_striped: Optional[bool] = Field(default=None)
2030
+ caption: Optional[_RichText] = Field(default=None)
2031
+
2032
+ class RichBlockDetails(RichBlock):
2033
+ '''
2034
+ An expandable block for details disclosure, corresponding to
2035
+ the HTML tag <details>.
2036
+
2037
+ Reference: https://core.telegram.org/bots/api#richblockdetails
2038
+ '''
2039
+
2040
+ type: Literal['details'] = 'details' # pyright: ignore[reportIncompatibleVariableOverride]
2041
+ summary: _RichText
2042
+ blocks: List[_RichBlock]
2043
+ is_open: Optional[bool] = Field(default=None)
2044
+
2045
+ class RichBlockMap(RichBlock):
2046
+ '''
2047
+ A block with a map, corresponding to the
2048
+ custom HTML tag <tg-map>.
2049
+
2050
+ Reference: https://core.telegram.org/bots/api#richblockmap
2051
+ '''
2052
+
2053
+ type: Literal['map'] = 'map' # pyright: ignore[reportIncompatibleVariableOverride]
2054
+ location: Location
2055
+ zoom: int
2056
+ width: int
2057
+ height: int
2058
+ caption: Optional[RichBlockCaption] = Field(default=None)
2059
+
2060
+ class RichBlockAnimation(RichBlock):
2061
+ '''
2062
+ A block with an animation, corresponding to the
2063
+ HTML tag <video>.
2064
+
2065
+ Reference: https://core.telegram.org/bots/api#richblockanimation
2066
+ '''
2067
+
2068
+ type: Literal['animation'] = 'animation' # pyright: ignore[reportIncompatibleVariableOverride]
2069
+ animation: Animation
2070
+ has_spoiler: Optional[bool] = Field(default=None)
2071
+ caption: Optional[RichBlockCaption] = Field(default=None)
2072
+
2073
+ class RichBlockAudio(RichBlock):
2074
+ '''
2075
+ A block with a music file, corresponding to
2076
+ the HTML tag <audio>.
2077
+
2078
+ Reference: https://core.telegram.org/bots/api#richblockaudio
2079
+ '''
2080
+
2081
+ type: Literal['audio'] = 'audio' # pyright: ignore[reportIncompatibleVariableOverride]
2082
+ audio: Audio
2083
+ caption: Optional[RichBlockCaption] = Field(default=None)
2084
+
2085
+ class RichBlockPhoto(RichBlock):
2086
+ '''
2087
+ A block with a photo, corresponding to the
2088
+ HTML tag <photo>.
2089
+
2090
+ Reference: https://core.telegram.org/bots/api#richblockphoto
2091
+ '''
2092
+
2093
+ type: Literal['photo'] = 'photo' # pyright: ignore[reportIncompatibleVariableOverride]
2094
+ photo: List[PhotoSize]
2095
+ has_spoiler: Optional[bool] = Field(default=None)
2096
+ caption: Optional[RichBlockCaption] = Field(default=None)
2097
+
2098
+ class RichBlockVideo(RichBlock):
2099
+ '''
2100
+ A block with a video, corresponding to the
2101
+ HTML tag <video>.
2102
+
2103
+ Reference: https://core.telegram.org/bots/api#richblockvideo
2104
+ '''
2105
+
2106
+ type: Literal['video'] = 'video' # pyright: ignore[reportIncompatibleVariableOverride]
2107
+ video: Video
2108
+ has_spoiler: Optional[bool] = Field(default=None)
2109
+ caption: Optional[RichBlockCaption] = Field(default=None)
2110
+
2111
+ class RichBlockVoiceNote(RichBlock):
2112
+ '''
2113
+ A block with a voice note, corresponding to
2114
+ the HTML tag <audio>.
2115
+
2116
+ Reference: https://core.telegram.org/bots/api#richblockvoicenote
2117
+ '''
2118
+
2119
+ type: Literal['voice_note'] = 'voice_note' # pyright: ignore[reportIncompatibleVariableOverride]
2120
+ voice_note: Voice
2121
+ caption: Optional[RichBlockCaption] = Field(default=None)
2122
+
2123
+ class RichBlockThinking(RichBlock):
2124
+ '''
2125
+ A block with a “Thinking…” placeholder, corresponding to
2126
+ the custom HTML tag <tg-thinking>. The block may
2127
+ be used only in sendRichMessageDraft, therefore it can't
2128
+ be received in messages. See https://t.me/addemoji/AIActions for examples
2129
+ of custom emoji, which are recommended for usage
2130
+ in the block.
2131
+
2132
+ Reference: https://core.telegram.org/bots/api#richblockthinking
2133
+ '''
2134
+
2135
+ type: Literal['thinking'] = 'thinking' # pyright: ignore[reportIncompatibleVariableOverride]
2136
+ text: _RichText
2137
+
2138
+ _RichBlock = Union[
2139
+ RichBlockParagraph,
2140
+ RichBlockSectionHeading,
2141
+ RichBlockPreformatted,
2142
+ RichBlockFooter,
2143
+ RichBlockDivider,
2144
+ RichBlockMathematicalExpression,
2145
+ RichBlockAnchor,
2146
+ RichBlockList,
2147
+ RichBlockBlockQuotation,
2148
+ RichBlockPullQuotation,
2149
+ RichBlockCollage,
2150
+ RichBlockSlideshow,
2151
+ RichBlockTable,
2152
+ RichBlockDetails,
2153
+ RichBlockMap,
2154
+ RichBlockAnimation,
2155
+ RichBlockAudio,
2156
+ RichBlockPhoto,
2157
+ RichBlockVideo,
2158
+ RichBlockVoiceNote,
2159
+ RichBlockThinking,
2160
+ ]
2161
+ RichBlockAdapter = TypeAdapter[_RichBlock](_RichBlock)
2162
+
1570
2163
  class InlineQueryResult(BaseModel):
1571
2164
  type: Literal['audio', 'document', 'gif', 'mpeg4_gif', 'photo', 'sticker', 'video', 'voice', 'article', 'contact', 'game', 'location', 'venue']
1572
2165
  id: str
@@ -2081,6 +2674,17 @@ class InputTextMessageContent(InputMessageContent):
2081
2674
  entities: Optional[List[MessageEntity]] = Field(default=None)
2082
2675
  link_preview_options: Optional[LinkPreviewOptions] = Field(default=None)
2083
2676
 
2677
+ class InputRichMessageContent(InputMessageContent):
2678
+ '''
2679
+ Represents the content of a rich message to
2680
+ be sent as the result of an inline
2681
+ query.
2682
+
2683
+ Reference: https://core.telegram.org/bots/api#inputrichmessagecontent
2684
+ '''
2685
+
2686
+ rich_message: InputRichMessage
2687
+
2084
2688
  class InputLocationMessageContent(InputMessageContent):
2085
2689
  '''
2086
2690
  Represents the content of a location message to
@@ -2161,6 +2765,7 @@ class InputInvoiceMessageContent(InputMessageContent):
2161
2765
 
2162
2766
  _InputMessageContent = Union[
2163
2767
  InputTextMessageContent,
2768
+ InputRichMessageContent,
2164
2769
  InputLocationMessageContent,
2165
2770
  InputVenueMessageContent,
2166
2771
  InputContactMessageContent,
@@ -2536,7 +3141,8 @@ class User(BaseModel):
2536
3141
  has_main_web_app: Optional[bool] = Field(default=None)
2537
3142
  has_topics_enabled: Optional[bool] = Field(default=None)
2538
3143
  allows_users_to_create_topics: Optional[bool] = Field(default=None)
2539
- can_manage_bots: Optional[bool] = Field(default=None)
3144
+ can_manage_bots: Optional[bool] = Field(default=None)
3145
+ supports_join_request_queries: Optional[bool] = Field(default=None)
2540
3146
 
2541
3147
  class Chat(BaseModel):
2542
3148
  '''
@@ -2611,7 +3217,8 @@ class ChatFullInfo(BaseModel):
2611
3217
  rating: Optional[UserRating] = Field(default=None)
2612
3218
  first_profile_audio: Optional[Audio] = Field(default=None)
2613
3219
  unique_gift_colors: Optional[UniqueGiftColors] = Field(default=None)
2614
- paid_message_star_count: Optional[int] = Field(default=None)
3220
+ paid_message_star_count: Optional[int] = Field(default=None)
3221
+ guard_bot: Optional[User] = Field(default=None)
2615
3222
 
2616
3223
  class MessageId(BaseModel):
2617
3224
  '''
@@ -2915,6 +3522,15 @@ class Dice(BaseModel):
2915
3522
  emoji: str
2916
3523
  value: int
2917
3524
 
3525
+ class Link(BaseModel):
3526
+ '''
3527
+ Represents an HTTP link.
3528
+
3529
+ Reference: https://core.telegram.org/bots/api#link
3530
+ '''
3531
+
3532
+ url: str
3533
+
2918
3534
  class PollMedia(BaseModel):
2919
3535
  '''
2920
3536
  At most one of the optional fields can
@@ -2926,6 +3542,7 @@ class PollMedia(BaseModel):
2926
3542
  animation: Optional[Animation] = Field(default=None)
2927
3543
  audio: Optional[Audio] = Field(default=None)
2928
3544
  document: Optional[Document] = Field(default=None)
3545
+ link: Optional[Link] = Field(default=None)
2929
3546
  live_photo: Optional[LivePhoto] = Field(default=None)
2930
3547
  location: Optional[Location] = Field(default=None)
2931
3548
  photo: Optional[List[PhotoSize]] = Field(default=None)
@@ -4020,13 +4637,14 @@ class ChatJoinRequest(BaseModel):
4020
4637
  date: int
4021
4638
  bio: Optional[str] = Field(default=None)
4022
4639
  invite_link: Optional[ChatInviteLink] = Field(default=None)
4640
+ query_id: Optional[str] = Field(default=None)
4023
4641
 
4024
4642
  async def approve(
4025
4643
  self,
4026
4644
  bot: bot.Bot
4027
4645
  ) -> bool:
4028
4646
  '''
4029
- Approves this chat join request.
4647
+ Approve this chat join request.
4030
4648
  '''
4031
4649
  return await bot.approve_chat_join_request(
4032
4650
  chat_id=self.chat.id,
@@ -4038,7 +4656,7 @@ class ChatJoinRequest(BaseModel):
4038
4656
  bot: bot.Bot
4039
4657
  ) -> bool:
4040
4658
  '''
4041
- Declines this chat join request.
4659
+ Decline this chat join request.
4042
4660
  '''
4043
4661
  return await bot.decline_chat_join_request(
4044
4662
  chat_id=self.chat.id,
@@ -4756,6 +5374,68 @@ class InputSticker(BaseModel):
4756
5374
  mask_position: Optional[MaskPosition] = Field(default=None)
4757
5375
  keywords: Optional[List[str]] = Field(default=None)
4758
5376
 
5377
+ class RichMessage(BaseModel):
5378
+ '''
5379
+ Rich formatted message.
5380
+
5381
+ Reference: https://core.telegram.org/bots/api#richmessage
5382
+ '''
5383
+
5384
+ blocks: List[_RichBlock]
5385
+ is_rtl: Optional[bool] = Field(default=None)
5386
+
5387
+ class InputRichMessage(BaseModel):
5388
+ '''
5389
+ Describes a rich message to be sent. Exactly
5390
+ one of the fields html or markdown must
5391
+ be used.
5392
+
5393
+ Reference: https://core.telegram.org/bots/api#inputrichmessage
5394
+ '''
5395
+
5396
+ html: Optional[str] = Field(default=None)
5397
+ markdown: Optional[str] = Field(default=None)
5398
+ is_rtl: Optional[bool] = Field(default=None)
5399
+ skip_entity_detection: Optional[bool] = Field(default=None)
5400
+
5401
+ class RichBlockCaption(BaseModel):
5402
+ '''
5403
+ Caption of a rich formatted block.
5404
+
5405
+ Reference: https://core.telegram.org/bots/api#richblockcaption
5406
+ '''
5407
+
5408
+ text: _RichText
5409
+ credit: Optional[_RichText] = Field(default=None)
5410
+
5411
+ class RichBlockTableCell(BaseModel):
5412
+ '''
5413
+ Cell in a table.
5414
+
5415
+ Reference: https://core.telegram.org/bots/api#richblocktablecell
5416
+ '''
5417
+
5418
+ align: str
5419
+ valign: str
5420
+ text: Optional[_RichText] = Field(default=None)
5421
+ is_header: Optional[bool] = Field(default=None)
5422
+ colspan: Optional[int] = Field(default=None)
5423
+ rowspan: Optional[int] = Field(default=None)
5424
+
5425
+ class RichBlockListItem(BaseModel):
5426
+ '''
5427
+ An item of a list.
5428
+
5429
+ Reference: https://core.telegram.org/bots/api#richblocklistitem
5430
+ '''
5431
+
5432
+ label: str
5433
+ blocks: List[_RichBlock]
5434
+ has_checkbox: Optional[bool] = Field(default=None)
5435
+ is_checked: Optional[bool] = Field(default=None)
5436
+ value: Optional[int] = Field(default=None)
5437
+ type: Optional[str] = Field(default=None)
5438
+
4759
5439
  class InlineQuery(BaseModel):
4760
5440
  '''
4761
5441
  This object represents an incoming inline query. When
File without changes
File without changes