Skip to content

Commit 5582865

Browse files
authored
Merge pull request eternnoir#2162 from Badiboy/master
One more fix for BoostSource
2 parents 31e3bd1 + cf323fc commit 5582865

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

telebot/types.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9055,11 +9055,11 @@ def de_json(cls, json_string):
90559055
if json_string is None:
90569056
return None
90579057
obj = cls.check_json(json_string)
9058-
user = User.de_json(obj['user'])
9059-
return cls(user)
9058+
obj['user'] = User.de_json(obj['user'])
9059+
return cls(**obj)
90609060

9061-
def __init__(self, user):
9062-
super().__init__('premium')
9061+
def __init__(self, source, user, **kwargs):
9062+
self.source = source
90639063
self.user = user
90649064

90659065

@@ -9085,11 +9085,11 @@ def de_json(cls, json_string):
90859085
if json_string is None:
90869086
return None
90879087
obj = cls.check_json(json_string)
9088-
user = User.de_json(obj['user'])
9089-
return cls(user)
9088+
obj['user'] = User.de_json(obj['user'])
9089+
return cls(**obj)
90909090

9091-
def __init__(self, user):
9092-
super().__init__('gift_code')
9091+
def __init__(self, source, user, **kwargs):
9092+
self.source = source
90939093
self.user = user
90949094

90959095

@@ -9121,11 +9121,11 @@ def de_json(cls, json_string):
91219121
if json_string is None:
91229122
return None
91239123
obj = cls.check_json(json_string)
9124-
user = User.de_json(obj['user']) if 'user' in obj else None
9125-
return cls(obj['giveaway_message_id'], user, obj.get('is_unclaimed'))
9124+
obj['user'] = User.de_json(obj['user'])
9125+
return cls(**obj)
91269126

9127-
def __init__(self, giveaway_message_id, user=None, is_unclaimed=None):
9128-
super().__init__('giveaway')
9127+
def __init__(self, source, giveaway_message_id, user=None, is_unclaimed=None, **kwargs):
9128+
self.source = source
91299129
self.giveaway_message_id = giveaway_message_id
91309130
self.user = user
91319131
self.is_unclaimed = is_unclaimed
@@ -9158,6 +9158,18 @@ def de_json(cls, json_string):
91589158
if json_string is None:
91599159
return None
91609160
obj = cls.check_json(json_string)
9161+
if not 'boost_id' in obj:
9162+
# Suppose that the field "boost_id" is not always provided by Telegram
9163+
logger.warning('The field "boost_id" is not found in received ChatBoost.')
9164+
obj['boost_id'] = None
9165+
if not 'add_date' in obj:
9166+
# Suppose that the field "boost_id" is not always provided by Telegram
9167+
logger.warning('The field "add_date" is not found in received ChatBoost.')
9168+
obj['add_date'] = None
9169+
if not 'expiration_date' in obj:
9170+
# Suppose that the field "boost_id" is not always provided by Telegram
9171+
logger.warning('The field "expiration_date" is not found in received ChatBoost.')
9172+
obj['expiration_date'] = None
91619173
source = obj.get('source', None)
91629174
obj['source'] = ChatBoostSource.de_json(source) if source else None
91639175
return cls(**obj)
@@ -9191,7 +9203,7 @@ def de_json(cls, json_string):
91919203
return cls(**obj)
91929204

91939205
def __init__(self, boosts, **kwargs):
9194-
self.boosts: ChatBoost = boosts
9206+
self.boosts: List[ChatBoost] = boosts
91959207

91969208

91979209
class InaccessibleMessage(JsonDeserializable):

0 commit comments

Comments
 (0)