2121
2222import functools
2323import logging
24+ import warnings
2425
2526from telegram import (User , Message , Update , Chat , ChatMember , UserProfilePhotos , File ,
2627 ReplyMarkup , TelegramObject , WebhookInfo , GameHighScore )
@@ -208,7 +209,7 @@ def sendMessage(self,
208209 ID of the original message.
209210 reply_markup (Optional[:class:`telegram.ReplyMarkup`]): Additional
210211 interface options. A JSON-serialized object for an inline
211- keyboard, custom reply keyboard, instructions to hide reply
212+ keyboard, custom reply keyboard, instructions to remove reply
212213 keyboard or to force a reply from the user.
213214 timeout (Optional[float]): If this value is specified, use it as
214215 the definitive timeout (in seconds) for urlopen() operations.
@@ -299,7 +300,7 @@ def sendPhoto(self,
299300 message.
300301 reply_markup (Optional[:class:`telegram.ReplyMarkup`]): Additional interface options. A
301302 JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
302- to hide reply keyboard or to force a reply from the user.
303+ to remove reply keyboard or to force a reply from the user.
303304 timeout (Optional[float]): If this value is specified, use it as the definitive timeout
304305 (in seconds) for urlopen() operations.
305306 **kwargs (dict): Arbitrary keyword arguments.
@@ -360,7 +361,7 @@ def sendAudio(self,
360361 message.
361362 reply_markup (Optional[:class:`telegram.ReplyMarkup`]): Additional interface options. A
362363 JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
363- to hide reply keyboard or to force a reply from the user.
364+ to remove reply keyboard or to force a reply from the user.
364365 timeout (Optional[float]): If this value is specified, use it as the definitive timeout
365366 (in seconds) for urlopen() operations.
366367 **kwargs (dict): Arbitrary keyword arguments.
@@ -415,7 +416,7 @@ def sendDocument(self,
415416 message.
416417 reply_markup (Optional[:class:`telegram.ReplyMarkup`]): Additional interface options. A
417418 JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
418- to hide reply keyboard or to force a reply from the user.
419+ to remove reply keyboard or to force a reply from the user.
419420 timeout (Optional[float]): If this value is specified, use it as the definitive timeout
420421 (in seconds) for urlopen() operations.
421422 **kwargs (dict): Arbitrary keyword arguments.
@@ -461,7 +462,7 @@ def sendSticker(self,
461462 message.
462463 reply_markup (Optional[:class:`telegram.ReplyMarkup`]): Additional interface options. A
463464 JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
464- to hide reply keyboard or to force a reply from the user.
465+ to remove reply keyboard or to force a reply from the user.
465466 timeout (Optional[float]): If this value is specified, use it as the definitive timeout
466467 (in seconds) for urlopen() operations.
467468 **kwargs (dict): Arbitrary keyword arguments.
@@ -508,7 +509,7 @@ def sendVideo(self,
508509 message.
509510 reply_markup (Optional[:class:`telegram.ReplyMarkup`]): Additional interface options. A
510511 JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
511- to hide reply keyboard or to force a reply from the user.
512+ to remove reply keyboard or to force a reply from the user.
512513 timeout (Optional[float]): If this value is specified, use it as the definitive timeout
513514 (in seconds) for urlopen() operations.
514515
@@ -561,7 +562,7 @@ def sendVoice(self,
561562 message.
562563 reply_markup (Optional[:class:`telegram.ReplyMarkup`]): Additional interface options. A
563564 JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
564- to hide reply keyboard or to force a reply from the user.
565+ to remove reply keyboard or to force a reply from the user.
565566 timeout (Optional[float]): If this value is specified, use it as the definitive timeout
566567 (in seconds) for urlopen() operations.
567568 **kwargs (dict): Arbitrary keyword arguments.
@@ -607,7 +608,7 @@ def sendLocation(self,
607608 message.
608609 reply_markup (Optional[:class:`telegram.ReplyMarkup`]): Additional interface options. A
609610 JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
610- to hide reply keyboard or to force a reply from the user.
611+ to remove reply keyboard or to force a reply from the user.
611612 timeout (Optional[float]): If this value is specified, use it as the definitive timeout
612613 (in seconds) for urlopen() operations.
613614 **kwargs (dict): Arbitrary keyword arguments.
@@ -656,7 +657,7 @@ def sendVenue(self,
656657 message.
657658 reply_markup (Optional[:class:`telegram.ReplyMarkup`]): Additional interface options. A
658659 JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
659- to hide reply keyboard or to force a reply from the user.
660+ to remove reply keyboard or to force a reply from the user.
660661 timeout (Optional[float]): If this value is specified, use it as the definitive timeout
661662 (in seconds) for urlopen() operations.
662663 **kwargs (dict): Arbitrary keyword arguments.
@@ -710,7 +711,7 @@ def sendContact(self,
710711 message.
711712 reply_markup (Optional[:class:`telegram.ReplyMarkup`]): Additional interface options. A
712713 JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
713- to hide reply keyboard or to force a reply from the user.
714+ to remove reply keyboard or to force a reply from the user.
714715 timeout (Optional[float]): If this value is specified, use it as the definitive timeout
715716 (in seconds) for urlopen() operations.
716717 **kwargs (dict): Arbitrary keyword arguments.
@@ -749,7 +750,7 @@ def sendGame(self, chat_id, game_short_name, **kwargs):
749750 ID of the original message.
750751 reply_markup (Optional[:class:`telegram.ReplyMarkup`]): Additional interface options.
751752 A JSON-serialized object for an inline keyboard, custom reply keyboard,
752- instructions to hide reply keyboard or to force a reply from the user.
753+ instructions to remove reply keyboard or to force a reply from the user.
753754 timeout (Optional[float]): If this value is specified, use it as
754755 the definitive timeout (in seconds) for urlopen() operations.
755756
@@ -987,6 +988,7 @@ def answerCallbackQuery(self,
987988 text = None ,
988989 show_alert = False ,
989990 url = None ,
991+ cache_time = None ,
990992 timeout = None ,
991993 ** kwargs ):
992994 """Use this method to send answers to callback queries sent from inline keyboards. The
@@ -999,9 +1001,12 @@ def answerCallbackQuery(self,
9991001 to the user.
10001002 show_alert (Optional[bool]): If `True`, an alert will be shown by the client instead of
10011003 a notification at the top of the chat screen. Defaults to `False`.
1004+ url (Optional[str]): URL that will be opened by the user's client.
1005+ cache_time (Optional[int]): The maximum amount of time in seconds that the result of
1006+ the callback query may be cached client-side. Telegram apps will support caching
1007+ starting in version 3.14. Defaults to 0.
10021008 timeout (Optional[float]): If this value is specified, use it as the definitive timeout
10031009 (in seconds) for urlopen() operations.
1004- url (Optional[str]): URL that will be opened by the user's client.
10051010 **kwargs (dict): Arbitrary keyword arguments.
10061011
10071012 Returns:
@@ -1021,6 +1026,8 @@ def answerCallbackQuery(self,
10211026 data ['show_alert' ] = show_alert
10221027 if url :
10231028 data ['url' ] = url
1029+ if cache_time is not None :
1030+ data ['cache_time' ] = cache_time
10241031
10251032 result = self ._request .post (url_ , data , timeout = timeout )
10261033
@@ -1054,7 +1061,7 @@ def editMessageText(self,
10541061 reply_markup: A JSON-serialized object for an inline keyboard.
10551062 reply_markup (Optional[:class:`telegram.ReplyMarkup`]): Additional interface options. A
10561063 JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
1057- to hide reply keyboard or to force a reply from the user.
1064+ to remove reply keyboard or to force a reply from the user.
10581065 timeout (Optional[float]): If this value is specified, use it as the definitive timeout
10591066 (in seconds) for urlopen() operations.
10601067 **kwargs (dict): Arbitrary keyword arguments.
@@ -1434,9 +1441,32 @@ def setGameScore(self,
14341441 message_id = None ,
14351442 inline_message_id = None ,
14361443 edit_message = None ,
1444+ force = None ,
1445+ disable_edit_message = None ,
14371446 ** kwargs ):
14381447 """Use this method to set the score of the specified user in a game.
14391448
1449+ Args:
1450+ user_id (int): User identifier.
1451+ score (int): New score, must be non-negative.
1452+ chat_id (Optional[int|str]): Required if `inline_message_id` is not specified. Unique
1453+ identifier for the target chat (or username of the target channel in the format
1454+ `@channelusername`)
1455+ message_id (Optional[int]): Required if inline_message_id is not specified. Identifier
1456+ of the sent message.
1457+ inline_message_id (Optional[str]): Required if chat_id and message_id are not
1458+ specified. Identifier of the inline message.
1459+ force (Optional[bool]): Pass True, if the high score is allowed to decrease. This can
1460+ be useful when fixing mistakes or banning cheaters.
1461+ disable_edit_message (Optional[bool]): Pass True, if the game message should not be
1462+ automatically edited to include the current scoreboard.
1463+ edit_message (Optional[bool]): Deprecated. Has the opposite logic for
1464+ `disable_edit_message`.
1465+
1466+ Keyword Args:
1467+ timeout (Optional[float]): If this value is specified, use it as the definitive timeout
1468+ (in seconds) for urlopen() operations.
1469+
14401470 Returns:
14411471 :class:`telegram.Message` or True: The edited message, or if the
14421472 message wasn't sent by the bot, True.
@@ -1452,8 +1482,16 @@ def setGameScore(self,
14521482 data ['message_id' ] = message_id
14531483 if inline_message_id :
14541484 data ['inline_message_id' ] = inline_message_id
1455- if edit_message :
1456- data ['edit_message' ] = edit_message
1485+ if force is not None :
1486+ data ['force' ] = force
1487+ if disable_edit_message is not None :
1488+ data ['disable_edit_message' ] = disable_edit_message
1489+ if edit_message is not None :
1490+ warnings .warn ('edit_message is deprecated, use disable_edit_message instead' )
1491+ if disable_edit_message is None :
1492+ data ['edit_message' ] = edit_message
1493+ else :
1494+ warnings .warn ('edit_message is ignored when disable_edit_message is used' )
14571495
14581496 result = self ._request .post (url , data , timeout = kwargs .get ('timeout' ))
14591497 if result is True :
0 commit comments