@@ -768,6 +768,7 @@ def send_location(self,
768768 reply_markup = None ,
769769 timeout = None ,
770770 location = None ,
771+ live_period = None ,
771772 ** kwargs ):
772773 """Use this method to send point on the map.
773774
@@ -780,6 +781,8 @@ def send_location(self,
780781 latitude (:obj:`float`, optional): Latitude of location.
781782 longitude (:obj:`float`, optional): Longitude of location.
782783 location (:class:`telegram.Location`, optional): The location to send.
784+ live_period (:obj:`int`, optional): Period in seconds for which the location will be
785+ updated, should be between 60 and 86400.
783786 disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
784787 receive a notification with no sound.
785788 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
@@ -803,14 +806,126 @@ def send_location(self,
803806
804807 if not (all ([latitude , longitude ]) or location ):
805808 raise ValueError ("Either location or latitude and longitude must be passed as"
806- "argument" )
809+ "argument." )
810+
811+ if not ((latitude is not None or longitude is not None ) ^ bool (location )):
812+ raise ValueError ("Either location or latitude and longitude must be passed as"
813+ "argument. Not both." )
807814
808815 if isinstance (location , Location ):
809816 latitude = location .latitude
810817 longitude = location .longitude
811818
812819 data = {'chat_id' : chat_id , 'latitude' : latitude , 'longitude' : longitude }
813820
821+ if live_period :
822+ data ['live_period' ] = live_period
823+
824+ return url , data
825+
826+ @log
827+ @message
828+ def edit_message_live_location (self ,
829+ chat_id = None ,
830+ message_id = None ,
831+ inline_message_id = None ,
832+ latitude = None ,
833+ longitude = None ,
834+ location = None ,
835+ reply_markup = None ,
836+ ** kwargs ):
837+ """Use this method to edit live location messages sent by the bot or via the bot
838+ (for inline bots). A location can be edited until its :attr:`live_period` expires or
839+ editing is explicitly disabled by a call to :attr:`stop_message_live_location`.
840+
841+ Note:
842+ You can either supply a :obj:`latitude` and :obj:`longitude` or a :obj:`location`.
843+
844+ Args:
845+ chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
846+ of the target channel (in the format @channelusername).
847+ message_id (:obj:`int`, optional): Required if inline_message_id is not specified.
848+ Identifier of the sent message.
849+ inline_message_id (:obj:`str`, optional): Required if chat_id and message_id are not
850+ specified. Identifier of the inline message.
851+ latitude (:obj:`float`, optional): Latitude of location.
852+ longitude (:obj:`float`, optional): Longitude of location.
853+ location (:class:`telegram.Location`, optional): The location to send.
854+ reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
855+ JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
856+ to remove reply keyboard or to force a reply from the user.
857+ timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
858+ the read timeout from the server (instead of the one specified during creation of
859+ the connection pool).
860+
861+ Returns:
862+ :class:`telegram.Message`: On success the edited message.
863+ """
864+
865+ url = '{0}/editMessageLiveLocation' .format (self .base_url )
866+
867+ if not (all ([latitude , longitude ]) or location ):
868+ raise ValueError ("Either location or latitude and longitude must be passed as"
869+ "argument." )
870+ if not ((latitude is not None or longitude is not None ) ^ bool (location )):
871+ raise ValueError ("Either location or latitude and longitude must be passed as"
872+ "argument. Not both." )
873+
874+ if isinstance (location , Location ):
875+ latitude = location .latitude
876+ longitude = location .longitude
877+
878+ data = {'latitude' : latitude , 'longitude' : longitude }
879+
880+ if chat_id :
881+ data ['chat_id' ] = chat_id
882+ if message_id :
883+ data ['message_id' ] = message_id
884+ if inline_message_id :
885+ data ['inline_message_id' ] = inline_message_id
886+
887+ return url , data
888+
889+ @log
890+ @message
891+ def stop_message_live_location (self ,
892+ chat_id = None ,
893+ message_id = None ,
894+ inline_message_id = None ,
895+ reply_markup = None ,
896+ ** kwargs ):
897+ """Use this method to stop updating a live location message sent by the bot or via the bot
898+ (for inline bots) before live_period expires.
899+
900+ Args:
901+ chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
902+ of the target channel (in the format @channelusername).
903+ message_id (:obj:`int`, optional): Required if inline_message_id is not specified.
904+ Identifier of the sent message.
905+ inline_message_id (:obj:`str`, optional): Required if chat_id and message_id are not
906+ specified. Identifier of the inline message.
907+ reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
908+ JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
909+ to remove reply keyboard or to force a reply from the user.
910+ timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
911+ the read timeout from the server (instead of the one specified during creation of
912+ the connection pool).
913+
914+ Returns:
915+ :class:`telegram.Message`: On success the edited message.
916+ """
917+
918+ url = '{0}/stopMessageLiveLocation' .format (self .base_url )
919+
920+ data = {}
921+
922+ if chat_id :
923+ data ['chat_id' ] = chat_id
924+ if message_id :
925+ data ['message_id' ] = message_id
926+ if inline_message_id :
927+ data ['inline_message_id' ] = inline_message_id
928+
814929 return url , data
815930
816931 @log
@@ -1825,6 +1940,63 @@ def get_chat_member(self, chat_id, user_id, timeout=None, **kwargs):
18251940
18261941 return ChatMember .de_json (result , self )
18271942
1943+ @log
1944+ def set_chat_sticker_set (self , chat_id , sticker_set_name , timeout = None , ** kwargs ):
1945+ """Use this method to set a new group sticker set for a supergroup.
1946+ The bot must be an administrator in the chat for this to work and must have the appropriate
1947+ admin rights. Use the field :attr:`telegram.Chat.can_set_sticker_set` optionally returned
1948+ in :attr:`get_chat` requests to check if the bot can use this method.
1949+
1950+ Args:
1951+ chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
1952+ of the target supergroup (in the format @supergroupusername).
1953+ sticker_set_name (:obj:`str`): Name of the sticker set to be set as the group
1954+ sticker set.
1955+ timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
1956+ the read timeout from the server (instead of the one specified during creation of
1957+ the connection pool).
1958+ **kwargs (:obj:`dict`): Arbitrary keyword arguments.
1959+
1960+
1961+ Returns:
1962+ :obj:`bool`: True on success.
1963+ """
1964+
1965+ url = '{0}/setChatStickerSet' .format (self .base_url )
1966+
1967+ data = {'chat_id' : chat_id , 'sticker_set_name' : sticker_set_name }
1968+
1969+ result = self ._request .post (url , data , timeout = timeout )
1970+
1971+ return result
1972+
1973+ @log
1974+ def delete_chat_sticker_set (self , chat_id , timeout = None , ** kwargs ):
1975+ """Use this method to delete a group sticker set from a supergroup. The bot must be an
1976+ administrator in the chat for this to work and must have the appropriate admin rights.
1977+ Use the field :attr:`telegram.Chat.can_set_sticker_set` optionally returned in
1978+ :attr:`get_chat` requests to check if the bot can use this method.
1979+
1980+ Args:
1981+ chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
1982+ of the target supergroup (in the format @supergroupusername).
1983+ timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
1984+ the read timeout from the server (instead of the one specified during creation of
1985+ the connection pool).
1986+ **kwargs (:obj:`dict`): Arbitrary keyword arguments.
1987+
1988+ Returns:
1989+ :obj:`bool`: True on success.
1990+ """
1991+
1992+ url = '{0}/deleteChatStickerSet' .format (self .base_url )
1993+
1994+ data = {'chat_id' : chat_id }
1995+
1996+ result = self ._request .post (url , data , timeout = timeout )
1997+
1998+ return result
1999+
18282000 def get_webhook_info (self , timeout = None , ** kwargs ):
18292001 """Use this method to get current webhook status. Requires no parameters.
18302002
@@ -2794,6 +2966,8 @@ def __reduce__(self):
27942966 sendVoice = send_voice
27952967 sendVideoNote = send_video_note
27962968 sendLocation = send_location
2969+ editMessageLiveLocation = edit_message_live_location
2970+ stopMessageLiveLocation = stop_message_live_location
27972971 sendVenue = send_venue
27982972 sendContact = send_contact
27992973 sendGame = send_game
@@ -2814,6 +2988,8 @@ def __reduce__(self):
28142988 getChat = get_chat
28152989 getChatAdministrators = get_chat_administrators
28162990 getChatMember = get_chat_member
2991+ setChatStickerSet = set_chat_sticker_set
2992+ deleteChatStickerSet = delete_chat_sticker_set
28172993 getChatMembersCount = get_chat_members_count
28182994 getWebhookInfo = get_webhook_info
28192995 setGameScore = set_game_score
0 commit comments