4747 InputPeerUser , InputPeerChat , InputPeerChannel
4848)
4949from pyrogram .crypto import CTR
50- from pyrogram .extensions import Markdown , HTML
5150from pyrogram .session import Auth , Session
51+ from .style import Markdown , HTML
5252
5353log = logging .getLogger (__name__ )
5454
@@ -472,6 +472,7 @@ def get_me(self):
472472 def send_message (self ,
473473 chat_id : int or str ,
474474 text : str ,
475+ parse_mode : str = "" ,
475476 disable_web_page_preview : bool = None ,
476477 disable_notification : bool = None ,
477478 reply_to_msg_id : int = None ):
@@ -486,6 +487,10 @@ def send_message(self,
486487 text (:obj:`str`):
487488 Text of the message to be sent.
488489
490+ parse_mode (:obj:`str`):
491+ Use "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or
492+ inline URLs in your message. Defaults to "Markdown".
493+
489494 disable_web_page_preview (:obj:`bool`, optional):
490495 Disables link previews for links in this message.
491496
@@ -502,14 +507,16 @@ def send_message(self,
502507 Raises:
503508 :class:`pyrogram.Error`
504509 """
510+ style = self .html if parse_mode .lower () == "html" else self .markdown
511+
505512 return self .send (
506513 functions .messages .SendMessage (
507514 peer = self .resolve_peer (chat_id ),
508515 no_webpage = disable_web_page_preview or None ,
509516 silent = disable_notification or None ,
510517 reply_to_msg_id = reply_to_msg_id ,
511518 random_id = self .rnd_id (),
512- ** self . markdown .parse (text )
519+ ** style .parse (text )
513520 )
514521 )
515522
@@ -558,6 +565,7 @@ def send_photo(self,
558565 chat_id : int or str ,
559566 photo : str ,
560567 caption : str = "" ,
568+ parse_mode : str = "" ,
561569 ttl_seconds : int = None ,
562570 disable_notification : bool = None ,
563571 reply_to_message_id : int = None ):
@@ -576,6 +584,10 @@ def send_photo(self,
576584 caption (:obj:`bool`, optional):
577585 Photo caption, 0-200 characters.
578586
587+ parse_mode (:obj:`str`):
588+ Use "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or
589+ inline URLs in your caption. Defaults to "Markdown".
590+
579591 ttl_seconds (:obj:`int`, optional):
580592 Self-Destruct Timer.
581593 If you set a timer, the photo will self-destruct in :obj:`ttl_seconds`
@@ -594,6 +606,7 @@ def send_photo(self,
594606 Raises:
595607 :class:`pyrogram.Error`
596608 """
609+ style = self .html if parse_mode .lower () == "html" else self .markdown
597610 file = self .save_file (photo )
598611
599612 while True :
@@ -608,7 +621,7 @@ def send_photo(self,
608621 silent = disable_notification or None ,
609622 reply_to_msg_id = reply_to_message_id ,
610623 random_id = self .rnd_id (),
611- ** self . markdown .parse (caption )
624+ ** style .parse (caption )
612625 )
613626 )
614627 except FilePartMissing as e :
@@ -620,6 +633,7 @@ def send_audio(self,
620633 chat_id : int or str ,
621634 audio : str ,
622635 caption : str = "" ,
636+ parse_mode : str = "" ,
623637 duration : int = 0 ,
624638 performer : str = None ,
625639 title : str = None ,
@@ -642,6 +656,10 @@ def send_audio(self,
642656 caption (:obj:`str`, optional):
643657 Audio caption, 0-200 characters.
644658
659+ parse_mode (:obj:`str`):
660+ Use "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or
661+ inline URLs in your caption. Defaults to "Markdown".
662+
645663 duration (:obj:`int`, optional):
646664 Duration of the audio in seconds.
647665
@@ -664,6 +682,7 @@ def send_audio(self,
664682 Raises:
665683 :class:`pyrogram.Error`
666684 """
685+ style = self .html if parse_mode .lower () == "html" else self .markdown
667686 file = self .save_file (audio )
668687
669688 while True :
@@ -686,7 +705,7 @@ def send_audio(self,
686705 silent = disable_notification or None ,
687706 reply_to_msg_id = reply_to_message_id ,
688707 random_id = self .rnd_id (),
689- ** self . markdown .parse (caption )
708+ ** style .parse (caption )
690709 )
691710 )
692711 except FilePartMissing as e :
@@ -698,6 +717,7 @@ def send_document(self,
698717 chat_id : int or str ,
699718 document : str ,
700719 caption : str = "" ,
720+ parse_mode : str = "" ,
701721 disable_notification : bool = None ,
702722 reply_to_message_id : int = None ):
703723 """Use this method to send general files.
@@ -715,6 +735,10 @@ def send_document(self,
715735 caption (:obj:`str`, optional):
716736 Document caption, 0-200 characters.
717737
738+ parse_mode (:obj:`str`):
739+ Use "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or
740+ inline URLs in your caption. Defaults to "Markdown".
741+
718742 disable_notification (:obj:`bool`, optional):
719743 Sends the message silently.
720744 Users will receive a notification with no sound.
@@ -728,6 +752,7 @@ def send_document(self,
728752 Raises:
729753 :class:`pyrogram.Error`
730754 """
755+ style = self .html if parse_mode .lower () == "html" else self .markdown
731756 file = self .save_file (document )
732757
733758 while True :
@@ -745,7 +770,7 @@ def send_document(self,
745770 silent = disable_notification or None ,
746771 reply_to_msg_id = reply_to_message_id ,
747772 random_id = self .rnd_id (),
748- ** self . markdown .parse (caption )
773+ ** style .parse (caption )
749774 )
750775 )
751776 except FilePartMissing as e :
@@ -756,10 +781,11 @@ def send_document(self,
756781 def send_video (self ,
757782 chat_id : int or str ,
758783 video : str ,
784+ caption : str = "" ,
785+ parse_mode : str = "" ,
759786 duration : int = 0 ,
760787 width : int = 0 ,
761788 height : int = 0 ,
762- caption : str = "" ,
763789 disable_notification : bool = None ,
764790 reply_to_message_id : int = None ):
765791 """Use this method to send video files.
@@ -774,6 +800,13 @@ def send_video(self,
774800 Video to send.
775801 Pass a file path as string to send a video that exists on your local machine.
776802
803+ caption (:obj:`str`, optional):
804+ Video caption, 0-200 characters.
805+
806+ parse_mode (:obj:`str`):
807+ Use "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or
808+ inline URLs in your caption. Defaults to "Markdown".
809+
777810 duration (:obj:`int`, optional):
778811 Duration of sent video in seconds.
779812
@@ -783,9 +816,6 @@ def send_video(self,
783816 height (:obj:`int`, optional):
784817 Video height.
785818
786- caption (:obj:`str`, optional):
787- Video caption, 0-200 characters.
788-
789819 disable_notification (:obj:`bool`, optional):
790820 Sends the message silently.
791821 Users will receive a notification with no sound.
@@ -799,6 +829,7 @@ def send_video(self,
799829 Raises:
800830 :class:`pyrogram.Error`
801831 """
832+ style = self .html if parse_mode .lower () == "html" else self .markdown
802833 file = self .save_file (video )
803834
804835 while True :
@@ -820,7 +851,7 @@ def send_video(self,
820851 silent = disable_notification or None ,
821852 reply_to_msg_id = reply_to_message_id ,
822853 random_id = self .rnd_id (),
823- ** self . markdown .parse (caption )
854+ ** style .parse (caption )
824855 )
825856 )
826857 except FilePartMissing as e :
@@ -832,6 +863,7 @@ def send_voice(self,
832863 chat_id : int or str ,
833864 voice : str ,
834865 caption : str = "" ,
866+ parse_mode : str = "" ,
835867 duration : int = 0 ,
836868 disable_notification : bool = None ,
837869 reply_to_message_id : int = None ):
@@ -850,6 +882,10 @@ def send_voice(self,
850882 caption (:obj:`str`, optional):
851883 Voice message caption, 0-200 characters.
852884
885+ parse_mode (:obj:`str`):
886+ Use "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or
887+ inline URLs in your caption. Defaults to "Markdown".
888+
853889 duration (:obj:`int`, optional):
854890 Duration of the voice message in seconds.
855891
@@ -866,6 +902,7 @@ def send_voice(self,
866902 Raises:
867903 :class:`pyrogram.Error`
868904 """
905+ style = self .html if parse_mode .lower () == "html" else self .markdown
869906 file = self .save_file (voice )
870907
871908 while True :
@@ -886,7 +923,7 @@ def send_voice(self,
886923 silent = disable_notification or None ,
887924 reply_to_msg_id = reply_to_message_id ,
888925 random_id = self .rnd_id (),
889- ** self . markdown .parse (caption )
926+ ** style .parse (caption )
890927 )
891928 )
892929 except FilePartMissing as e :
@@ -1193,6 +1230,7 @@ def edit_message_text(self,
11931230 chat_id : int or str ,
11941231 message_id : int ,
11951232 text : str ,
1233+ parse_mode : str = "" ,
11961234 disable_web_page_preview : bool = None ):
11971235 """Use this method to edit text messages.
11981236
@@ -1208,25 +1246,32 @@ def edit_message_text(self,
12081246 text (:obj:`str`):
12091247 New text of the message.
12101248
1249+ parse_mode (:obj:`str`):
1250+ Use "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or
1251+ inline URLs in your message. Defaults to "Markdown".
1252+
12111253 disable_web_page_preview (:obj:`bool`, optional):
12121254 Disables link previews for links in this message.
12131255
12141256 Raises:
12151257 :class:`pyrogram.Error`
12161258 """
1259+ style = self .html if parse_mode .lower () == "html" else self .markdown
1260+
12171261 return self .send (
12181262 functions .messages .EditMessage (
12191263 peer = self .resolve_peer (chat_id ),
12201264 id = message_id ,
12211265 no_webpage = disable_web_page_preview or None ,
1222- ** self . markdown .parse (text )
1266+ ** style .parse (text )
12231267 )
12241268 )
12251269
12261270 def edit_message_caption (self ,
12271271 chat_id : int or str ,
12281272 message_id : int ,
1229- caption : str ):
1273+ caption : str ,
1274+ parse_mode : str = "" ):
12301275 """Use this method to edit captions of messages.
12311276
12321277 Args:
@@ -1241,14 +1286,20 @@ def edit_message_caption(self,
12411286 caption (:obj:`str`):
12421287 New caption of the message.
12431288
1289+ parse_mode (:obj:`str`):
1290+ Use "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or
1291+ inline URLs in your caption. Defaults to "Markdown".
1292+
12441293 Raises:
12451294 :class:`pyrogram.Error`
12461295 """
1296+ style = self .html if parse_mode .lower () == "html" else self .markdown
1297+
12471298 return self .send (
12481299 functions .messages .EditMessage (
12491300 peer = self .resolve_peer (chat_id ),
12501301 id = message_id ,
1251- ** self . markdown .parse (caption )
1302+ ** style .parse (caption )
12521303 )
12531304 )
12541305
0 commit comments