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 11
11
12
12
13
13
class Bot (object ):
14
+
14
15
def __init__ (self ,
15
16
token ,
16
17
base_url = None ):
@@ -554,12 +555,33 @@ def getUpdates(self,
554
555
555
556
return [Update .de_json (x ) for x in data ]
556
557
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
+ """
558
573
url = '%s/setWebhook' % (self .base_url )
559
574
560
575
if not self .__auth :
561
576
raise TelegramError ({'message' : "API must be authenticated." })
562
577
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
+
563
585
def _requestUrl (self ,
564
586
url ,
565
587
method ,
You can’t perform that action at this time.
0 commit comments