Skip to content

Commit b7513aa

Browse files
committed
Merge branch 'renyhp/master'
2 parents cc8e4f8 + a8f6e0e commit b7513aa

File tree

3 files changed

+127
-17
lines changed

3 files changed

+127
-17
lines changed

botogram/objects/mixins.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,15 @@ def send(self, message, preview=True, reply_to=None, syntax=None,
9393

9494
@_require_api
9595
def send_photo(self, path=None, file_id=None, url=None, caption=None,
96-
reply_to=None, extra=None, attach=None, notify=True):
96+
reply_to=None, extra=None, attach=None, notify=True, *,
97+
syntax=None):
9798
"""Send a photo"""
9899
args = self._get_call_args(reply_to, extra, attach, notify)
99100
if caption is not None:
100101
args["caption"] = caption
102+
syntax = syntaxes.guess_syntax(caption, syntax)
103+
if syntax is not None:
104+
args["parse_mode"] = syntax
101105

102106
if path is not None and file_id is None and url is None:
103107
files = {"photo": open(path, "rb")}
@@ -119,11 +123,15 @@ def send_photo(self, path=None, file_id=None, url=None, caption=None,
119123
@_require_api
120124
def send_audio(self, path=None, file_id=None, url=None, duration=None,
121125
performer=None, title=None, reply_to=None,
122-
extra=None, attach=None, notify=True, caption=None):
126+
extra=None, attach=None, notify=True, caption=None, *,
127+
syntax=None):
123128
"""Send an audio track"""
124129
args = self._get_call_args(reply_to, extra, attach, notify)
125130
if caption is not None:
126131
args["caption"] = caption
132+
syntax = syntaxes.guess_syntax(caption, syntax)
133+
if syntax is not None:
134+
args["parse_mode"] = syntax
127135
if duration is not None:
128136
args["duration"] = duration
129137
if performer is not None:
@@ -151,13 +159,16 @@ def send_audio(self, path=None, file_id=None, url=None, duration=None,
151159
@_require_api
152160
def send_voice(self, path=None, file_id=None, url=None, duration=None,
153161
title=None, reply_to=None, extra=None, attach=None,
154-
notify=True, caption=None):
162+
notify=True, caption=None, *, syntax=None):
155163
"""Send a voice message"""
156164
args = self._get_call_args(reply_to, extra, attach, notify)
157165
if caption is not None:
158166
args["caption"] = caption
159167
if duration is not None:
160168
args["duration"] = duration
169+
syntax = syntaxes.guess_syntax(caption, syntax)
170+
if syntax is not None:
171+
args["parse_mode"] = syntax
161172

162173
if path is not None and file_id is None and url is None:
163174
files = {"voice": open(path, "rb")}
@@ -179,13 +190,16 @@ def send_voice(self, path=None, file_id=None, url=None, duration=None,
179190
@_require_api
180191
def send_video(self, path=None, file_id=None, url=None,
181192
duration=None, caption=None, reply_to=None, extra=None,
182-
attach=None, notify=True):
193+
attach=None, notify=True, *, syntax=None):
183194
"""Send a video"""
184195
args = self._get_call_args(reply_to, extra, attach, notify)
185196
if duration is not None:
186197
args["duration"] = duration
187198
if caption is not None:
188199
args["caption"] = caption
200+
syntax = syntaxes.guess_syntax(caption, syntax)
201+
if syntax is not None:
202+
args["parse_mode"] = syntax
189203

190204
if path is not None and file_id is None and url is None:
191205
files = {"video": open(path, "rb")}
@@ -206,11 +220,15 @@ def send_video(self, path=None, file_id=None, url=None,
206220

207221
@_require_api
208222
def send_file(self, path=None, file_id=None, url=None, reply_to=None,
209-
extra=None, attach=None, notify=True, caption=None):
223+
extra=None, attach=None, notify=True, caption=None, *,
224+
syntax=None):
210225
"""Send a generic file"""
211226
args = self._get_call_args(reply_to, extra, attach, notify)
212227
if caption is not None:
213228
args["caption"] = caption
229+
syntax = syntaxes.guess_syntax(caption, syntax)
230+
if syntax is not None:
231+
args["parse_mode"] = syntax
214232

215233
if path is not None and file_id is None and url is None:
216234
files = {"document": open(path, "rb")}
@@ -337,10 +355,13 @@ def edit(self, text, syntax=None, preview=True, extra=None, attach=None):
337355
self.text = text
338356

339357
@_require_api
340-
def edit_caption(self, caption, extra=None, attach=None):
358+
def edit_caption(self, caption, extra=None, attach=None, *, syntax=None):
341359
"""Edit this message's caption"""
342360
args = {"message_id": self.message_id, "chat_id": self.chat.id}
343361
args["caption"] = caption
362+
syntax = syntaxes.guess_syntax(caption, syntax)
363+
if syntax is not None:
364+
args["parse_mode"] = syntax
344365

345366
if extra is not None:
346367
_deprecated_message(

docs/api/telegram.rst

Lines changed: 66 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ about its business.
125125

126126
Now the method returns the sent message
127127

128-
.. py:method:: send_photo([path=None, file_id=None, url=None, caption=None, reply_to=None, extra=None, attach=None, notify=True])
128+
.. py:method:: send_photo([path=None, file_id=None, url=None, caption=None, reply_to=None, extra=None, attach=None, notify=True, syntax=None])
129129
130130
Send a photo to the user. You can specify the photo by passing its *path*,
131131
its *url*, or its Telegram *file_id*. Only one of these arguments must be passed.
@@ -149,6 +149,7 @@ about its business.
149149
:param object attach: An extra thing to attach to the message.
150150
:param object extra: An extra reply interface object to attach.
151151
:param bool notify: If you want to trigger the client notification.
152+
:param str syntax: The name of the syntax used for the caption.
152153
:returns: The message you sent
153154
:rtype: ~botogram.Message
154155

@@ -163,8 +164,12 @@ about its business.
163164
.. versionchanged:: 0.5
164165

165166
Added support for *file_id* and *url*.
167+
168+
.. versionchanged:: 0.6
169+
170+
Support text formatting in caption through *syntax*.
166171

167-
.. py:method:: send_audio([path=None, file_id=None, url=None, duration=None, performer=None, title=None, reply_to=None, attach=None, extra=None, notify=True, caption=None])
172+
.. py:method:: send_audio([path=None, file_id=None, url=None, duration=None, performer=None, title=None, reply_to=None, attach=None, extra=None, notify=True, caption=None, syntax=None])
168173
169174
Send an audio track to the user. You can specify the track by passing its *path*,
170175
its *url*, or its Telegram *file_id*. Only one of these arguments must be passed.
@@ -190,6 +195,7 @@ about its business.
190195
:param object extra: An extra reply interface object to attach
191196
:param bool notify: If you want to trigger the client notification.
192197
:param str caption: A caption for the audio track.
198+
:param str syntax: The name of the syntax used for the caption.
193199
:returns: The message you sent
194200
:rtype: ~botogram.Message
195201

@@ -204,8 +210,12 @@ about its business.
204210
.. versionchanged:: 0.5
205211

206212
Added support for *caption*, *file_id* and *url*.
213+
214+
.. versionchanged:: 0.6
215+
216+
Support text formatting in caption through *syntax*.
207217

208-
.. py:method:: send_voice([path=None, file_id=None, url=None, duration=None, reply_to=None, extra=None, attach=None, notify=True, caption=None])
218+
.. py:method:: send_voice([path=None, file_id=None, url=None, duration=None, reply_to=None, extra=None, attach=None, notify=True, caption=None, syntax=None])
209219
210220
Send a voice message to the user. You can specify the audio by passing its *path*,
211221
its *url*, or its Telegram *file_id*. Only one of these arguments must be passed.
@@ -229,6 +239,7 @@ about its business.
229239
:param object extra: An extra reply interface object to attach
230240
:param bool notify: If you want to trigger the client notification.
231241
:param str caption: A caption for the voice message.
242+
:param str syntax: The name of the syntax used for the caption.
232243
:returns: The message you sent
233244
:rtype: ~botogram.Message
234245

@@ -243,8 +254,12 @@ about its business.
243254
.. versionchanged:: 0.5
244255

245256
Added support for *caption*, *file_id* and *url*.
257+
258+
.. versionchanged:: 0.6
259+
260+
Support text formatting in caption through *syntax*.
246261

247-
.. py:method:: send_video([path=None, file_id=None, url=None, duration=None, caption=None, reply_to=None, attach=None, extra=None, notify=True])
262+
.. py:method:: send_video([path=None, file_id=None, url=None, duration=None, caption=None, reply_to=None, attach=None, extra=None, notify=True, syntax=None])
248263
249264
Send a video to the user. You can specify the video by passing its *path*,
250265
its *url*, or its Telegram *file_id*. Only one of these arguments must be passed.
@@ -268,6 +283,7 @@ about its business.
268283
:param object attach: An extra thing to attach to the message.
269284
:param object extra: An extra reply interface object to attach
270285
:param bool notify: If you want to trigger the client notification.
286+
:param str syntax: The name of the syntax used for the caption.
271287
:returns: The message you sent
272288
:rtype: ~botogram.Message
273289

@@ -282,8 +298,12 @@ about its business.
282298
.. versionchanged:: 0.5
283299

284300
Added support for *file_id* and *url*.
301+
302+
.. versionchanged:: 0.6
303+
304+
Support text formatting in caption through *syntax*.
285305

286-
.. py:method:: send_file([path=None, file_id=None, url=None, reply_to=None, attach=None, extra=None, notify=True, caption=None])
306+
.. py:method:: send_file([path=None, file_id=None, url=None, reply_to=None, attach=None, extra=None, notify=True, caption=None, syntax=None])
287307
288308
Send a generic file to the user. You can specify the file by passing its *path*,
289309
its *url*, or its Telegram *file_id*. Only one of these arguments must be passed.
@@ -305,6 +325,7 @@ about its business.
305325
:param object extra: An extra reply interface object to attach
306326
:param bool notify: If you want to trigger the client notification.
307327
:param str caption: A caption for the file.
328+
:param str syntax: The name of the syntax used for the caption.
308329
:returns: The message you sent
309330
:rtype: ~botogram.Message
310331

@@ -319,6 +340,10 @@ about its business.
319340
.. versionchanged:: 0.5
320341

321342
Added support for *caption*, *file_id* and *url*.
343+
344+
.. versionchanged:: 0.6
345+
346+
Support text formatting in caption through *syntax*.
322347

323348
.. py:method:: send_location(latitude, longitude, [reply_to=None, attach=None, extra=None, notify=True])
324349
@@ -742,7 +767,7 @@ about its business.
742767

743768
Now the method returns the sent message
744769

745-
.. py:method:: send_photo([path=None, file_id=None, url=None, caption=None, reply_to=None, attach=None, extra=None, attach=None, notify=True])
770+
.. py:method:: send_photo([path=None, file_id=None, url=None, caption=None, reply_to=None, attach=None, extra=None, attach=None, notify=True, syntax=None])
746771
747772
Send a photo to the chat. You can specify the photo by passing its *path*,
748773
its *url*, or its Telegram *file_id*. Only one of these arguments must be passed.
@@ -766,6 +791,7 @@ about its business.
766791
:param object attach: An extra thing to attach to the message.
767792
:param object extra: An extra reply interface object to attach.
768793
:param bool notify: If you want to trigger the client notification.
794+
:param str syntax: The name of the syntax used for the caption.
769795
:returns: The message you sent
770796
:rtype: ~botogram.Message
771797

@@ -780,8 +806,12 @@ about its business.
780806
.. versionchanged:: 0.5
781807

782808
Added support for *file_id* and *url*
809+
810+
.. versionchanged:: 0.6
811+
812+
Support text formatting in caption through *syntax*.
783813

784-
.. py:method:: send_audio([path=None, file_id=None, url=None, duration=None, performer=None, title=None, reply_to=None, extra=None, attach=None, notify=True, caption=None])
814+
.. py:method:: send_audio([path=None, file_id=None, url=None, duration=None, performer=None, title=None, reply_to=None, extra=None, attach=None, notify=True, caption=None, syntax=None])
785815
786816
Send an audio track to the chat. You can specify the track by passing its *path*,
787817
its *url*, or its Telegram *file_id*. Only one of these arguments must be passed.
@@ -808,6 +838,7 @@ about its business.
808838
:param object extra: An extra reply interface object to attach
809839
:param bool notify: If you want to trigger the client notification.
810840
:param str caption: A caption for the audio track.
841+
:param str syntax: The name of the syntax used for the caption.
811842
:returns: The message you sent
812843
:rtype: ~botogram.Message
813844

@@ -822,8 +853,12 @@ about its business.
822853
.. versionchanged:: 0.5
823854

824855
Added support for *caption*, *file_id* and *url*
856+
857+
.. versionchanged:: 0.6
858+
859+
Support text formatting in caption through *syntax*.
825860

826-
.. py:method:: send_voice([path=None, file_id=None, url=None, duration=None, reply_to=None, extra=None, attach=None, notify=True, caption=None])
861+
.. py:method:: send_voice([path=None, file_id=None, url=None, duration=None, reply_to=None, extra=None, attach=None, notify=True, caption=None, syntax=None])
827862
828863
Send a voice message to the chat. You can specify the audio by passing its *path*,
829864
its *url*, or its Telegram *file_id*. Only one of these arguments must be passed.
@@ -847,6 +882,7 @@ about its business.
847882
:param object extra: An extra reply interface object to attach
848883
:param bool notify: If you want to trigger the client notification.
849884
:param str caption: A caption for the voice message.
885+
:param str syntax: The name of the syntax used for the caption.
850886
:returns: The message you sent
851887
:rtype: ~botogram.Message
852888

@@ -861,8 +897,12 @@ about its business.
861897
.. versionchanged:: 0.5
862898

863899
Added support for *caption*, *file_id* and *url*
900+
901+
.. versionchanged:: 0.6
902+
903+
Support text formatting in caption through *syntax*.
864904

865-
.. py:method:: send_video([path=None, file_id=None, url=None, duration=None, caption=None, reply_to=None, extra=None, attach=None, notify=True])
905+
.. py:method:: send_video([path=None, file_id=None, url=None, duration=None, caption=None, reply_to=None, extra=None, attach=None, notify=True, syntax=None])
866906
867907
Send a video to the chat. You can specify the video by passing its *path*,
868908
its *url*, or its Telegram *file_id*. Only one of these arguments must be passed.
@@ -887,6 +927,7 @@ about its business.
887927
:param object attach: An extra thing to attach to the message.
888928
:param object extra: An extra reply interface object to attach
889929
:param bool notify: If you want to trigger the client notification.
930+
:param str syntax: The name of the syntax used for the caption.
890931
:returns: The message you sent
891932
:rtype: ~botogram.Message
892933

@@ -901,8 +942,12 @@ about its business.
901942
.. versionchanged:: 0.5
902943

903944
Added support for *file_id* and *url*
945+
946+
.. versionchanged:: 0.6
947+
948+
Support text formatting in caption through *syntax*.
904949

905-
.. py:method:: send_file([path=None, file_id=None, url=None, reply_to=None, attach=None, extra=None, notify=True, caption=None])
950+
.. py:method:: send_file([path=None, file_id=None, url=None, reply_to=None, attach=None, extra=None, notify=True, caption=None, syntax=None])
906951
907952
Send a generic file to the chat. You can specify the video by passing its *path*,
908953
its *url*, or its Telegram *file_id*. Only one of these arguments must be passed.
@@ -924,6 +969,7 @@ about its business.
924969
:param object extra: An extra reply interface object to attach
925970
:param bool notify: If you want to trigger the client notification.
926971
:param str caption: A caption for the file.
972+
:param str syntax: The name of the syntax used for the caption.
927973
:returns: The message you sent
928974
:rtype: ~botogram.Message
929975

@@ -938,6 +984,10 @@ about its business.
938984
.. versionchanged:: 0.5
939985

940986
Added support for *caption*, *file_id* and *url*
987+
988+
.. versionchanged:: 0.6
989+
990+
Support text formatting in caption through *syntax*.
941991

942992
.. py:method:: send_location(latitude, longitude, [reply_to=None, attach=None, extra=None, notify=True])
943993
@@ -1470,7 +1520,7 @@ about its business.
14701520

14711521
.. versionadded:: 0.4
14721522

1473-
.. py:method:: edit_caption(caption, [attach=None, extra=None])
1523+
.. py:method:: edit_caption(caption, [attach=None, extra=None, syntax=None])
14741524
14751525
With this method you can edit the caption of the media attached to a
14761526
message the user already received. This allows you to do a lot of
@@ -1482,12 +1532,17 @@ about its business.
14821532
:param str caption: The new caption of the media file.
14831533
:param object attach: An extra thing to attach to the message.
14841534
:param object extra: An extra reply interface object to attach.
1535+
:param str syntax: The name of the syntax used for the message.
14851536

14861537
.. deprecated:: 0.4
14871538

14881539
The *extra* parameter is now deprecated
14891540

14901541
.. versionadded:: 0.3
1542+
1543+
.. versionchanged:: 0.6
1544+
1545+
Support text formatting in caption through *syntax*.
14911546

14921547
.. py:method:: edit_attach(attach)
14931548

docs/changelog/0.6.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.. Copyright (c) 2015-2018 The Botogram Authors (see AUTHORS)
2+
Documentation released under the MIT license (see LICENSE)
3+
4+
===========================
5+
Changelog of botogram 0.6.x
6+
===========================
7+
8+
Here you can find all the changes in the botogram 0.6.x releases.
9+
10+
.. _changelog-0.6:
11+
12+
botogram 0.6
13+
============
14+
15+
*Alpha release, not yet released.*
16+
17+
Release description not yet written.
18+
19+
New features
20+
------------
21+
22+
* Added support for text formatting in media captions
23+
24+
* New argument ``syntax`` in :py:meth:`botogram.Chat.send_photo`
25+
* New argument ``syntax`` in :py:meth:`botogram.Chat.send_audio`
26+
* New argument ``syntax`` in :py:meth:`botogram.Chat.send_file`
27+
* New argument ``syntax`` in :py:meth:`botogram.Chat.send_video`
28+
* New argument ``syntax`` in :py:meth:`botogram.Chat.send_voice`
29+
* New argument ``syntax`` in :py:meth:`botogram.User.send_photo`
30+
* New argument ``syntax`` in :py:meth:`botogram.User.send_audio`
31+
* New argument ``syntax`` in :py:meth:`botogram.User.send_file`
32+
* New argument ``syntax`` in :py:meth:`botogram.User.send_video`
33+
* New argument ``syntax`` in :py:meth:`botogram.User.send_voice`
34+
* New argument ``syntax`` in :py:meth:`botogram.Message.edit_caption`

0 commit comments

Comments
 (0)