1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

feat: make LoginUrl JsonDeserializable

feat: make LoginUrl JsonDeserializable, add de_json func
This commit is contained in:
meoww-bot 2020-09-01 18:03:21 +08:00 committed by GitHub
parent 6832c33733
commit cdae65116b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1017,12 +1017,23 @@ class InlineKeyboardMarkup(Dictionaryable, JsonSerializable):
return json_dict
class LoginUrl(Dictionaryable, JsonSerializable):
class LoginUrl(Dictionaryable, JsonSerializable, JsonDeserializable):
def __init__(self, url, forward_text=None, bot_username=None, request_write_access=None):
self.url = url
self.forward_text = forward_text
self.bot_username = bot_username
self.request_write_access = request_write_access
@classmethod
def de_json(cls, json_string):
if (json_string is None):
return None
obj = cls.check_json(json_string)
url = obj['url']
forward_text = obj.get('forward_text')
bot_username = obj.get('bot_username')
request_write_access = obj.get('request_write_access')
return cls(url, forward_text, bot_username, request_write_access)
def to_json(self):
return json.dumps(self.to_dict())