botapi-py 1.4.8__tar.gz → 1.4.9__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.4.8
3
+ Version: 1.4.9
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.4.8"
3
+ version = "1.4.9"
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 = [
@@ -17,8 +17,8 @@ class BotShortcuts:
17
17
  async def send_media(
18
18
  self,
19
19
  chat_id: Union[int, str],
20
- media: Union[types.InputFile, str],
21
- file_type: enums.MediaType,
20
+ media: Union[types.InputFile, str, None],
21
+ file_type: Optional[enums.MediaType],
22
22
  caption: Optional[str] = None,
23
23
  parse_mode: Optional[enums.ParseMode] = enums.ParseMode.HTML,
24
24
  caption_entities: Optional[List[types.MessageEntity]] = None,
@@ -36,6 +36,7 @@ class BotShortcuts:
36
36
  ) -> types.Message:
37
37
  '''
38
38
  Method that sends common types of media by automatically routing to the correct `send_<type>` method.
39
+ Also supports send_message with text only for convenience.
39
40
 
40
41
  :param chat_id: Unique identifier for the target chat or username of the target channel.
41
42
  :param media: File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.
@@ -58,6 +59,29 @@ class BotShortcuts:
58
59
  '''
59
60
  self = cast(methods.Bot, self)
60
61
 
62
+ # Plain text message
63
+ if not media or not file_type:
64
+ if not caption:
65
+ raise ValueError('Either media or caption must be provided.')
66
+
67
+ return await self.send_message(
68
+ chat_id=chat_id,
69
+ # =media,
70
+ text=caption,
71
+ parse_mode=parse_mode,
72
+ entities=caption_entities,
73
+ disable_notification=disable_notification,
74
+ protect_content=protect_content,
75
+ reply_parameters=reply_parameters,
76
+ reply_markup=reply_markup,
77
+ message_effect_id=message_effect_id,
78
+ allow_paid_broadcast=allow_paid_broadcast,
79
+ business_connection_id=business_connection_id,
80
+ message_thread_id=message_thread_id,
81
+ # has_spoiler=has_spoiler,
82
+ # show_caption_above_media=show_caption_above_media
83
+ )
84
+
61
85
  match file_type:
62
86
 
63
87
  case enums.MediaType.PHOTO:
File without changes
File without changes
File without changes
File without changes