mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Refactoring bugfix
This commit is contained in:
parent
995814d846
commit
247fe6e947
@ -49,7 +49,7 @@ class JsonDeserializable(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def de_json(cls, json_type):
|
def de_json(cls, json_string):
|
||||||
"""
|
"""
|
||||||
Returns an instance of this class from the given json dict or string.
|
Returns an instance of this class from the given json dict or string.
|
||||||
|
|
||||||
@ -86,8 +86,9 @@ class JsonDeserializable(object):
|
|||||||
|
|
||||||
class Update(JsonDeserializable):
|
class Update(JsonDeserializable):
|
||||||
@classmethod
|
@classmethod
|
||||||
def de_json(cls, json_type):
|
def de_json(cls, json_string):
|
||||||
obj = cls.check_json(json_type)
|
if (json_string is None): return None
|
||||||
|
obj = cls.check_json(json_string)
|
||||||
update_id = obj['update_id']
|
update_id = obj['update_id']
|
||||||
message = Message.de_json(obj.get('message'))
|
message = Message.de_json(obj.get('message'))
|
||||||
edited_message = Message.de_json(obj.get('edited_message'))
|
edited_message = Message.de_json(obj.get('edited_message'))
|
||||||
@ -668,8 +669,9 @@ class Location(JsonDeserializable):
|
|||||||
|
|
||||||
class Venue(JsonDeserializable):
|
class Venue(JsonDeserializable):
|
||||||
@classmethod
|
@classmethod
|
||||||
def de_json(cls, json_type):
|
def de_json(cls, json_string):
|
||||||
obj = cls.check_json(json_type)
|
if (json_string is None): return None
|
||||||
|
obj = cls.check_json(json_string)
|
||||||
location = Location.de_json(obj['location'])
|
location = Location.de_json(obj['location'])
|
||||||
title = obj['title']
|
title = obj['title']
|
||||||
address = obj['address']
|
address = obj['address']
|
||||||
@ -699,8 +701,9 @@ class UserProfilePhotos(JsonDeserializable):
|
|||||||
|
|
||||||
class File(JsonDeserializable):
|
class File(JsonDeserializable):
|
||||||
@classmethod
|
@classmethod
|
||||||
def de_json(cls, json_type):
|
def de_json(cls, json_string):
|
||||||
obj = cls.check_json(json_type)
|
if (json_string is None): return None
|
||||||
|
obj = cls.check_json(json_string)
|
||||||
file_id = obj['file_id']
|
file_id = obj['file_id']
|
||||||
file_size = obj.get('file_size')
|
file_size = obj.get('file_size')
|
||||||
file_path = obj.get('file_path')
|
file_path = obj.get('file_path')
|
||||||
@ -928,8 +931,9 @@ class InlineKeyboardButton(JsonSerializable):
|
|||||||
|
|
||||||
class CallbackQuery(JsonDeserializable):
|
class CallbackQuery(JsonDeserializable):
|
||||||
@classmethod
|
@classmethod
|
||||||
def de_json(cls, json_type):
|
def de_json(cls, json_string):
|
||||||
obj = cls.check_json(json_type)
|
if (json_string is None): return None
|
||||||
|
obj = cls.check_json(json_string)
|
||||||
id = obj['id']
|
id = obj['id']
|
||||||
from_user = User.de_json(obj['from'])
|
from_user = User.de_json(obj['from'])
|
||||||
message = Message.de_json(obj.get('message'))
|
message = Message.de_json(obj.get('message'))
|
||||||
@ -951,8 +955,9 @@ class CallbackQuery(JsonDeserializable):
|
|||||||
|
|
||||||
class ChatPhoto(JsonDeserializable):
|
class ChatPhoto(JsonDeserializable):
|
||||||
@classmethod
|
@classmethod
|
||||||
def de_json(cls, json_type):
|
def de_json(cls, json_string):
|
||||||
obj = cls.check_json(json_type)
|
if (json_string is None): return None
|
||||||
|
obj = cls.check_json(json_string)
|
||||||
small_file_id = obj['small_file_id']
|
small_file_id = obj['small_file_id']
|
||||||
big_file_id = obj['big_file_id']
|
big_file_id = obj['big_file_id']
|
||||||
return cls(small_file_id, big_file_id)
|
return cls(small_file_id, big_file_id)
|
||||||
@ -964,8 +969,9 @@ class ChatPhoto(JsonDeserializable):
|
|||||||
|
|
||||||
class ChatMember(JsonDeserializable):
|
class ChatMember(JsonDeserializable):
|
||||||
@classmethod
|
@classmethod
|
||||||
def de_json(cls, json_type):
|
def de_json(cls, json_string):
|
||||||
obj = cls.check_json(json_type)
|
if (json_string is None): return None
|
||||||
|
obj = cls.check_json(json_string)
|
||||||
user = User.de_json(obj['user'])
|
user = User.de_json(obj['user'])
|
||||||
status = obj['status']
|
status = obj['status']
|
||||||
until_date = obj.get('until_date')
|
until_date = obj.get('until_date')
|
||||||
@ -1011,8 +1017,9 @@ class ChatMember(JsonDeserializable):
|
|||||||
|
|
||||||
class InlineQuery(JsonDeserializable):
|
class InlineQuery(JsonDeserializable):
|
||||||
@classmethod
|
@classmethod
|
||||||
def de_json(cls, json_type):
|
def de_json(cls, json_string):
|
||||||
obj = cls.check_json(json_type)
|
if (json_string is None): return None
|
||||||
|
obj = cls.check_json(json_string)
|
||||||
id = obj['id']
|
id = obj['id']
|
||||||
from_user = User.de_json(obj['from'])
|
from_user = User.de_json(obj['from'])
|
||||||
location = Location.de_json(obj.get('location'))
|
location = Location.de_json(obj.get('location'))
|
||||||
@ -1098,8 +1105,9 @@ class InputContactMessageContent(Dictionaryable):
|
|||||||
|
|
||||||
class ChosenInlineResult(JsonDeserializable):
|
class ChosenInlineResult(JsonDeserializable):
|
||||||
@classmethod
|
@classmethod
|
||||||
def de_json(cls, json_type):
|
def de_json(cls, json_string):
|
||||||
obj = cls.check_json(json_type)
|
if (json_string is None): return None
|
||||||
|
obj = cls.check_json(json_string)
|
||||||
result_id = obj['result_id']
|
result_id = obj['result_id']
|
||||||
from_user = User.de_json(obj['from'])
|
from_user = User.de_json(obj['from'])
|
||||||
query = obj['query']
|
query = obj['query']
|
||||||
@ -2181,8 +2189,9 @@ class InputMediaDocument(InputMedia):
|
|||||||
|
|
||||||
class PollOption(JsonSerializable, JsonDeserializable):
|
class PollOption(JsonSerializable, JsonDeserializable):
|
||||||
@classmethod
|
@classmethod
|
||||||
def de_json(cls, json_type):
|
def de_json(cls, json_string):
|
||||||
obj = cls.check_json(json_type)
|
if (json_string is None): return None
|
||||||
|
obj = cls.check_json(json_string)
|
||||||
text = obj['text']
|
text = obj['text']
|
||||||
voter_count = int(obj['voter_count'])
|
voter_count = int(obj['voter_count'])
|
||||||
option = cls(text)
|
option = cls(text)
|
||||||
@ -2199,8 +2208,9 @@ class PollOption(JsonSerializable, JsonDeserializable):
|
|||||||
|
|
||||||
class Poll(JsonDeserializable):
|
class Poll(JsonDeserializable):
|
||||||
@classmethod
|
@classmethod
|
||||||
def de_json(cls, json_type):
|
def de_json(cls, json_string):
|
||||||
obj = cls.check_json(json_type)
|
if (json_string is None): return None
|
||||||
|
obj = cls.check_json(json_string)
|
||||||
poll_id = obj['id']
|
poll_id = obj['id']
|
||||||
question = obj['question']
|
question = obj['question']
|
||||||
poll = cls(question)
|
poll = cls(question)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user