File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 1111
1212
1313class Bot (object ):
14+
1415 def __init__ (self ,
1516 token ,
1617 base_url = None ):
@@ -554,12 +555,33 @@ def getUpdates(self,
554555
555556 return [Update .de_json (x ) for x in data ]
556557
557- def setWebhook (self ):
558+ def setWebhook (self , webhook_url = "" ):
559+ """Use this method to specify a url and receive incoming updates via an
560+ outgoing webhook. Whenever there is an update for the bot, we will send
561+ an HTTPS POST request to the specified url, containing a
562+ JSON-serialized Update. In case of an unsuccessful request, we will
563+ give up after a reasonable amount of attempts.
564+
565+ Args:
566+ url:
567+ HTTPS url to send updates to.
568+ Use an empty string to remove webhook integration
569+
570+ Returns:
571+ True if successful else TelegramError was raised
572+ """
558573 url = '%s/setWebhook' % (self .base_url )
559574
560575 if not self .__auth :
561576 raise TelegramError ({'message' : "API must be authenticated." })
562577
578+ data = {'url' : webhook_url }
579+
580+ json_data = self ._requestUrl (url , 'POST' , data = data )
581+ data = self ._parseAndCheckTelegram (json_data .content )
582+
583+ return True
584+
563585 def _requestUrl (self ,
564586 url ,
565587 method ,
You can’t perform that action at this time.
0 commit comments