Skip to content

Commit cdae651

Browse files
authored
feat: make LoginUrl JsonDeserializable
feat: make LoginUrl JsonDeserializable, add de_json func
1 parent 6832c33 commit cdae651

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

telebot/types.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,12 +1017,23 @@ def to_dict(self):
10171017
return json_dict
10181018

10191019

1020-
class LoginUrl(Dictionaryable, JsonSerializable):
1020+
class LoginUrl(Dictionaryable, JsonSerializable, JsonDeserializable):
10211021
def __init__(self, url, forward_text=None, bot_username=None, request_write_access=None):
10221022
self.url = url
10231023
self.forward_text = forward_text
10241024
self.bot_username = bot_username
10251025
self.request_write_access = request_write_access
1026+
1027+
@classmethod
1028+
def de_json(cls, json_string):
1029+
if (json_string is None):
1030+
return None
1031+
obj = cls.check_json(json_string)
1032+
url = obj['url']
1033+
forward_text = obj.get('forward_text')
1034+
bot_username = obj.get('bot_username')
1035+
request_write_access = obj.get('request_write_access')
1036+
return cls(url, forward_text, bot_username, request_write_access)
10261037

10271038
def to_json(self):
10281039
return json.dumps(self.to_dict())

0 commit comments

Comments
 (0)