@@ -768,6 +768,7 @@ def send_location(self,
768
768
reply_markup = None ,
769
769
timeout = None ,
770
770
location = None ,
771
+ live_period = None ,
771
772
** kwargs ):
772
773
"""Use this method to send point on the map.
773
774
@@ -780,6 +781,8 @@ def send_location(self,
780
781
latitude (:obj:`float`, optional): Latitude of location.
781
782
longitude (:obj:`float`, optional): Longitude of location.
782
783
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.
783
786
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
784
787
receive a notification with no sound.
785
788
reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the
@@ -803,14 +806,126 @@ def send_location(self,
803
806
804
807
if not (all ([latitude , longitude ]) or location ):
805
808
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." )
807
814
808
815
if isinstance (location , Location ):
809
816
latitude = location .latitude
810
817
longitude = location .longitude
811
818
812
819
data = {'chat_id' : chat_id , 'latitude' : latitude , 'longitude' : longitude }
813
820
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
+
814
929
return url , data
815
930
816
931
@log
@@ -1825,6 +1940,63 @@ def get_chat_member(self, chat_id, user_id, timeout=None, **kwargs):
1825
1940
1826
1941
return ChatMember .de_json (result , self )
1827
1942
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
+
1828
2000
def get_webhook_info (self , timeout = None , ** kwargs ):
1829
2001
"""Use this method to get current webhook status. Requires no parameters.
1830
2002
@@ -2794,6 +2966,8 @@ def __reduce__(self):
2794
2966
sendVoice = send_voice
2795
2967
sendVideoNote = send_video_note
2796
2968
sendLocation = send_location
2969
+ editMessageLiveLocation = edit_message_live_location
2970
+ stopMessageLiveLocation = stop_message_live_location
2797
2971
sendVenue = send_venue
2798
2972
sendContact = send_contact
2799
2973
sendGame = send_game
@@ -2814,6 +2988,8 @@ def __reduce__(self):
2814
2988
getChat = get_chat
2815
2989
getChatAdministrators = get_chat_administrators
2816
2990
getChatMember = get_chat_member
2991
+ setChatStickerSet = set_chat_sticker_set
2992
+ deleteChatStickerSet = delete_chat_sticker_set
2817
2993
getChatMembersCount = get_chat_members_count
2818
2994
getWebhookInfo = get_webhook_info
2819
2995
setGameScore = set_game_score
0 commit comments