Pytdbot 0.10.0.dev9__py3-none-any.whl → 0.10.1.dev0__py3-none-any.whl

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.
pytdbot/__init__.py CHANGED
@@ -13,7 +13,7 @@ __all__ = [
13
13
  "Client",
14
14
  ]
15
15
 
16
- __version__ = "0.10.0.dev9"
16
+ __version__ = "0.10.1.dev0"
17
17
  __copyright__ = "Copyright (c) 2022-2026 Pytdbot, AYMENJD"
18
18
  __license__ = "MIT License"
19
19
 
@@ -4203,13 +4203,13 @@ class Updates:
4203
4203
 
4204
4204
  return decorator
4205
4205
 
4206
- def on_updatePendingTextMessage(
4206
+ def on_updatePendingMessage(
4207
4207
  self: pytdbot.Client | None = None,
4208
4208
  filters: pytdbot.filters.Filter | None = None,
4209
4209
  position: int | None = None,
4210
4210
  timeout: float | None = None,
4211
4211
  ) -> Callable:
4212
- r"""A new pending text message was received in a chat with a bot\. The message must be shown in the chat for at most getOption\(\"pending\_text\_message\_period\"\) seconds, replace any other pending message with the same draft\_id, and be deleted whenever any incoming message from the bot in the message thread is received
4212
+ r"""A new pending text or rich message was received in a chat with a bot\. The message must be shown in the chat for at most getOption\(\"pending\_text\_message\_period\"\) seconds, replace any other pending message with the same draft\_id, and be deleted whenever any incoming message from the bot in the message thread is received
4213
4213
 
4214
4214
  Parameters:
4215
4215
  filters (:class:`pytdbot.filters.Filter`, *optional*):
@@ -4231,7 +4231,7 @@ class Updates:
4231
4231
  elif isinstance(self, pytdbot.Client):
4232
4232
  if iscoroutinefunction(func):
4233
4233
  self.add_handler(
4234
- update_type="updatePendingTextMessage",
4234
+ update_type="updatePendingMessage",
4235
4235
  func=func,
4236
4236
  filters=filters,
4237
4237
  position=position,
@@ -4243,7 +4243,7 @@ class Updates:
4243
4243
  elif isinstance(self, pytdbot.filters.Filter):
4244
4244
  func._handler = Handler(
4245
4245
  func=func,
4246
- update_type="updatePendingTextMessage",
4246
+ update_type="updatePendingMessage",
4247
4247
  filter=self,
4248
4248
  position=position,
4249
4249
  inner_object=False,
@@ -4252,7 +4252,7 @@ class Updates:
4252
4252
  else:
4253
4253
  func._handler = Handler(
4254
4254
  func=func,
4255
- update_type="updatePendingTextMessage",
4255
+ update_type="updatePendingMessage",
4256
4256
  filter=filters,
4257
4257
  position=position,
4258
4258
  inner_object=False,
@@ -6327,6 +6327,65 @@ class Updates:
6327
6327
 
6328
6328
  return decorator
6329
6329
 
6330
+ def on_updateChatJoinResult(
6331
+ self: pytdbot.Client | None = None,
6332
+ filters: pytdbot.filters.Filter | None = None,
6333
+ position: int | None = None,
6334
+ timeout: float | None = None,
6335
+ ) -> Callable:
6336
+ r"""A join request from the user was completed
6337
+
6338
+ Parameters:
6339
+ filters (:class:`pytdbot.filters.Filter`, *optional*):
6340
+ An update filter
6341
+
6342
+ position (``int``, *optional*):
6343
+ The function position in handlers list. Default is ``None`` (append)
6344
+
6345
+ timeout (``float``, *optional*):
6346
+ Max execution time for the handler before it timeout. Default is ``None``
6347
+
6348
+ Raises:
6349
+ :py:class:`TypeError`
6350
+ """
6351
+
6352
+ def decorator(func: Callable) -> Callable:
6353
+ if hasattr(func, "_handler"):
6354
+ return func
6355
+ elif isinstance(self, pytdbot.Client):
6356
+ if iscoroutinefunction(func):
6357
+ self.add_handler(
6358
+ update_type="updateChatJoinResult",
6359
+ func=func,
6360
+ filters=filters,
6361
+ position=position,
6362
+ inner_object=False,
6363
+ timeout=timeout,
6364
+ )
6365
+ else:
6366
+ raise TypeError("Handler must be async")
6367
+ elif isinstance(self, pytdbot.filters.Filter):
6368
+ func._handler = Handler(
6369
+ func=func,
6370
+ update_type="updateChatJoinResult",
6371
+ filter=self,
6372
+ position=position,
6373
+ inner_object=False,
6374
+ timeout=timeout,
6375
+ )
6376
+ else:
6377
+ func._handler = Handler(
6378
+ func=func,
6379
+ update_type="updateChatJoinResult",
6380
+ filter=filters,
6381
+ position=position,
6382
+ inner_object=False,
6383
+ timeout=timeout,
6384
+ )
6385
+ return func
6386
+
6387
+ return decorator
6388
+
6330
6389
  def on_updateStory(
6331
6390
  self: pytdbot.Client | None = None,
6332
6391
  filters: pytdbot.filters.Filter | None = None,
@@ -7507,6 +7566,65 @@ class Updates:
7507
7566
 
7508
7567
  return decorator
7509
7568
 
7569
+ def on_updateWebBrowserSettings(
7570
+ self: pytdbot.Client | None = None,
7571
+ filters: pytdbot.filters.Filter | None = None,
7572
+ position: int | None = None,
7573
+ timeout: float | None = None,
7574
+ ) -> Callable:
7575
+ r"""Web browser settings have been updated
7576
+
7577
+ Parameters:
7578
+ filters (:class:`pytdbot.filters.Filter`, *optional*):
7579
+ An update filter
7580
+
7581
+ position (``int``, *optional*):
7582
+ The function position in handlers list. Default is ``None`` (append)
7583
+
7584
+ timeout (``float``, *optional*):
7585
+ Max execution time for the handler before it timeout. Default is ``None``
7586
+
7587
+ Raises:
7588
+ :py:class:`TypeError`
7589
+ """
7590
+
7591
+ def decorator(func: Callable) -> Callable:
7592
+ if hasattr(func, "_handler"):
7593
+ return func
7594
+ elif isinstance(self, pytdbot.Client):
7595
+ if iscoroutinefunction(func):
7596
+ self.add_handler(
7597
+ update_type="updateWebBrowserSettings",
7598
+ func=func,
7599
+ filters=filters,
7600
+ position=position,
7601
+ inner_object=False,
7602
+ timeout=timeout,
7603
+ )
7604
+ else:
7605
+ raise TypeError("Handler must be async")
7606
+ elif isinstance(self, pytdbot.filters.Filter):
7607
+ func._handler = Handler(
7608
+ func=func,
7609
+ update_type="updateWebBrowserSettings",
7610
+ filter=self,
7611
+ position=position,
7612
+ inner_object=False,
7613
+ timeout=timeout,
7614
+ )
7615
+ else:
7616
+ func._handler = Handler(
7617
+ func=func,
7618
+ update_type="updateWebBrowserSettings",
7619
+ filter=filters,
7620
+ position=position,
7621
+ inner_object=False,
7622
+ timeout=timeout,
7623
+ )
7624
+ return func
7625
+
7626
+ return decorator
7627
+
7510
7628
  def on_updateLanguagePackStrings(
7511
7629
  self: pytdbot.Client | None = None,
7512
7630
  filters: pytdbot.filters.Filter | None = None,
@@ -3,6 +3,9 @@ from ..types import (
3
3
  Error,
4
4
  FormattedText,
5
5
  HttpUrl,
6
+ InputAnimation,
7
+ InputAudio,
8
+ InputDocument,
6
9
  InputFile,
7
10
  InputFileRemote,
8
11
  InputMessageAnimation,
@@ -14,13 +17,17 @@ from ..types import (
14
17
  InputMessagePhoto,
15
18
  InputMessageReplyTo,
16
19
  InputMessageReplyToMessage,
20
+ InputMessageRichMessage,
17
21
  InputMessageSticker,
18
22
  InputMessageText,
19
23
  InputMessageVideo,
20
24
  InputMessageVideoNote,
21
25
  InputMessageVoiceNote,
26
+ InputPhoto,
27
+ InputRichMessage,
22
28
  InputTextQuote,
23
29
  InputThumbnail,
30
+ InputVideo,
24
31
  Invoice,
25
32
  LabeledPricePart,
26
33
  LinkPreviewOptions,
@@ -35,6 +42,8 @@ from ..types import (
35
42
  ReplyMarkupInlineKeyboard,
36
43
  ReplyMarkupRemoveKeyboard,
37
44
  ReplyMarkupShowKeyboard,
45
+ RichMessageSourceHtml,
46
+ RichMessageSourceMarkdown,
38
47
  TextEntity,
39
48
  TextParseModeHTML,
40
49
  TextParseModeMarkdown,
@@ -309,6 +318,109 @@ class Methods(TDLibFunctions):
309
318
  reply_markup=reply_markup,
310
319
  )
311
320
 
321
+ async def sendRichMessage(
322
+ self,
323
+ chat_id: int,
324
+ *,
325
+ markdown: str = None,
326
+ html: str = None,
327
+ is_rtl: bool = False,
328
+ detect_automatic_blocks: bool = False,
329
+ clear_draft: bool = False,
330
+ disable_notification: bool = False,
331
+ protect_content: bool = False,
332
+ allow_paid_broadcast: bool = False,
333
+ topic_id: MessageTopic = None,
334
+ quote: InputTextQuote = None,
335
+ reply_to: InputMessageReplyTo = None,
336
+ reply_to_message_id: int = 0,
337
+ reply_markup: (
338
+ ReplyMarkupInlineKeyboard
339
+ | ReplyMarkupShowKeyboard
340
+ | ReplyMarkupForceReply
341
+ | ReplyMarkupRemoveKeyboard
342
+ ) = None,
343
+ ) -> Error | Message:
344
+ r"""Send rich message to chat; either markdown or html must be provided
345
+
346
+ Parameters:
347
+ chat_id (``int``):
348
+ Target chat
349
+
350
+ markdown (``str``, *optional*):
351
+ Markdown-formatted text of the message
352
+
353
+ html (``str``, *optional*):
354
+ HTML-formatted text of the message
355
+
356
+ is_rtl (``bool``, *optional*):
357
+ Pass true if the message must be shown from right to left. Default is ``False``
358
+
359
+ detect_automatic_blocks (``bool``, *optional*):
360
+ Pass true to enable detection of URLs, email addresses and other automatic blocks. Default is ``False``
361
+
362
+ disable_notification (``bool``, *optional*):
363
+ If True, disable notification for the message. Default is ``None``
364
+
365
+ clear_draft (``bool``, *optional*):
366
+ True, if a chat message draft must be deleted. Default is ``False``
367
+
368
+ protect_content (``bool``, *optional*):
369
+ If True, the content of the message must be protected from forwarding and saving
370
+
371
+ allow_paid_broadcast (``bool``, *optional*):
372
+ Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default is ``False``
373
+
374
+ topic_id (:class:`~pytdbot.types.MessageTopic`, *optional*):
375
+ Topic in which the message will be sent; pass null if none
376
+
377
+ quote (:class:`~pytdbot.types.InputTextQuote`, *optional*):
378
+ Chosen quote from the replied message; may be null if none
379
+
380
+ reply_to (:class:`~pytdbot.types.InputMessageReplyTo`, *optional*):
381
+ Information about the message or the story this message is replying to; may be null if none
382
+
383
+ reply_to_message_id (``int``, *optional*):
384
+ Identifier of the message to reply. Ignored if ``reply_to`` is specified
385
+
386
+ reply_markup (:class:`~pytdbot.types.ReplyMarkupInlineKeyboard` | :class:`~pytdbot.types.ReplyMarkupShowKeyboard` | :class:`~pytdbot.types.ReplyMarkupForceReply` | :class:`~pytdbot.types.ReplyMarkupRemoveKeyboard`, *optional*):
387
+ The message reply markup
388
+
389
+ Returns:
390
+ :class:`~pytdbot.types.Message`
391
+ """
392
+
393
+ if not markdown and not html:
394
+ raise ValueError("Either markdown or html must be provided")
395
+
396
+ if markdown and html:
397
+ raise ValueError("Only one of markdown or html can be provided")
398
+
399
+ if markdown:
400
+ source = RichMessageSourceMarkdown(text=markdown)
401
+ else:
402
+ source = RichMessageSourceHtml(text=html)
403
+
404
+ return await self.sendMessageWithContent(
405
+ chat_id=chat_id,
406
+ content=InputMessageRichMessage(
407
+ message=InputRichMessage(
408
+ source=source,
409
+ is_rtl=is_rtl,
410
+ detect_automatic_blocks=detect_automatic_blocks,
411
+ ),
412
+ clear_draft=clear_draft,
413
+ ),
414
+ disable_notification=disable_notification,
415
+ protect_content=protect_content,
416
+ allow_paid_broadcast=allow_paid_broadcast,
417
+ topic_id=topic_id,
418
+ quote=quote,
419
+ reply_to=reply_to,
420
+ reply_to_message_id=reply_to_message_id,
421
+ reply_markup=reply_markup,
422
+ )
423
+
312
424
  async def sendAnimation(
313
425
  self,
314
426
  chat_id: int,
@@ -418,12 +530,14 @@ class Methods(TDLibFunctions):
418
530
  return await self.sendMessageWithContent(
419
531
  chat_id=chat_id,
420
532
  content=InputMessageAnimation(
421
- animation=animation,
422
- thumbnail=thumbnail,
423
- added_sticker_file_ids=added_sticker_file_ids,
424
- duration=duration,
425
- width=width,
426
- height=height,
533
+ animation=InputAnimation(
534
+ animation=animation,
535
+ thumbnail=thumbnail,
536
+ added_sticker_file_ids=added_sticker_file_ids,
537
+ duration=duration,
538
+ width=width,
539
+ height=height,
540
+ ),
427
541
  caption=caption,
428
542
  has_spoiler=has_spoiler,
429
543
  ),
@@ -539,11 +653,13 @@ class Methods(TDLibFunctions):
539
653
  return await self.sendMessageWithContent(
540
654
  chat_id=chat_id,
541
655
  content=InputMessageAudio(
542
- audio=audio,
543
- album_cover_thumbnail=album_cover_thumbnail,
544
- title=title,
545
- performer=performer,
546
- duration=duration,
656
+ audio=InputAudio(
657
+ audio=audio,
658
+ album_cover_thumbnail=album_cover_thumbnail,
659
+ title=title,
660
+ performer=performer,
661
+ duration=duration,
662
+ ),
547
663
  caption=caption,
548
664
  ),
549
665
  disable_notification=disable_notification,
@@ -649,9 +765,11 @@ class Methods(TDLibFunctions):
649
765
  return await self.sendMessageWithContent(
650
766
  chat_id=chat_id,
651
767
  content=InputMessageDocument(
652
- document=document,
653
- thumbnail=thumbnail,
654
- disable_content_type_detection=disable_content_type_detection,
768
+ document=InputDocument(
769
+ document=document,
770
+ thumbnail=thumbnail,
771
+ disable_content_type_detection=disable_content_type_detection,
772
+ ),
655
773
  caption=caption,
656
774
  ),
657
775
  disable_notification=disable_notification,
@@ -872,12 +990,14 @@ class Methods(TDLibFunctions):
872
990
  return await self.sendMessageWithContent(
873
991
  chat_id=chat_id,
874
992
  content=InputMessagePhoto(
875
- photo=photo,
876
- thumbnail=thumbnail,
877
- added_sticker_file_ids=added_sticker_file_ids,
993
+ photo=InputPhoto(
994
+ photo=photo,
995
+ thumbnail=thumbnail,
996
+ added_sticker_file_ids=added_sticker_file_ids,
997
+ width=width,
998
+ height=height,
999
+ ),
878
1000
  self_destruct_type=self_destruct_type,
879
- width=width,
880
- height=height,
881
1001
  caption=caption,
882
1002
  has_spoiler=has_spoiler,
883
1003
  ),
@@ -1008,13 +1128,15 @@ class Methods(TDLibFunctions):
1008
1128
  return await self.sendMessageWithContent(
1009
1129
  chat_id=chat_id,
1010
1130
  content=InputMessageVideo(
1011
- video=video,
1012
- thumbnail=thumbnail,
1013
- added_sticker_file_ids=added_sticker_file_ids,
1014
- duration=duration,
1015
- width=width,
1016
- height=height,
1017
- supports_streaming=supports_streaming,
1131
+ video=InputVideo(
1132
+ video=video,
1133
+ thumbnail=thumbnail,
1134
+ added_sticker_file_ids=added_sticker_file_ids,
1135
+ duration=duration,
1136
+ width=width,
1137
+ height=height,
1138
+ supports_streaming=supports_streaming,
1139
+ ),
1018
1140
  caption=caption,
1019
1141
  self_destruct_type=self_destruct_type,
1020
1142
  has_spoiler=has_spoiler,
@@ -1401,7 +1523,7 @@ class Methods(TDLibFunctions):
1401
1523
  return parse
1402
1524
  caption = parse
1403
1525
  else:
1404
- caption = FormattedText(id=new_caption)
1526
+ caption = FormattedText(text=new_caption)
1405
1527
 
1406
1528
  return await self.sendMessageWithContent(
1407
1529
  chat_id=chat_id,