mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
parent
cd89de5a9a
commit
702763edd6
@ -78,6 +78,10 @@ class TeleBot:
|
||||
def set_webhook(self, url=None, certificate=None):
|
||||
return apihelper.set_webhook(self.token, url, certificate)
|
||||
|
||||
def get_webhook_info(self):
|
||||
result = apihelper.get_webhook_info(self.token)
|
||||
return types.WebhookInfo.de_json(result)
|
||||
|
||||
def remove_webhook(self):
|
||||
return self.set_webhook() # No params resets webhook
|
||||
|
||||
|
@ -127,6 +127,12 @@ def set_webhook(token, url=None, certificate=None):
|
||||
return _make_request(token, method_url, params=payload, files=files)
|
||||
|
||||
|
||||
def get_webhook_info(token):
|
||||
method_url = r'getWebhookInfo'
|
||||
payload = {}
|
||||
return _make_request(token, method_url, params=payload)
|
||||
|
||||
|
||||
def get_updates(token, offset=None, limit=None, timeout=None):
|
||||
method_url = r'getUpdates'
|
||||
payload = {}
|
||||
|
@ -121,6 +121,29 @@ class Update(JsonDeserializable):
|
||||
self.callback_query = callback_query
|
||||
|
||||
|
||||
class WebhookInfo(JsonDeserializable):
|
||||
@classmethod
|
||||
def de_json(cls, json_string):
|
||||
obj = cls.check_json(json_string)
|
||||
url = obj['url']
|
||||
has_custom_certificate = obj['has_custom_certificate']
|
||||
pending_update_count = obj['pending_update_count']
|
||||
last_error_date = None
|
||||
last_error_message = None
|
||||
if 'last_error_message' in obj:
|
||||
last_error_date = obj['last_error_date']
|
||||
if 'last_error_message' in obj:
|
||||
last_error_message = obj['last_error_message']
|
||||
return cls(url, has_custom_certificate, pending_update_count, last_error_date, last_error_message)
|
||||
|
||||
def __init__(self, url, has_custom_certificate, pending_update_count, last_error_date, last_error_message):
|
||||
self.url = url
|
||||
self.has_custom_certificate = has_custom_certificate
|
||||
self.pending_update_count = pending_update_count
|
||||
self.last_error_date = last_error_date
|
||||
self.last_error_message = last_error_message
|
||||
|
||||
|
||||
class User(JsonDeserializable):
|
||||
@classmethod
|
||||
def de_json(cls, json_string):
|
||||
|
Loading…
Reference in New Issue
Block a user