Skip to content

Commit 0b51a81

Browse files
Minor fixes
1 parent 222b5dd commit 0b51a81

File tree

4 files changed

+13
-20
lines changed

4 files changed

+13
-20
lines changed

telebot/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6278,7 +6278,7 @@ def send_poll(
62786278
raise RuntimeError("Type of 'options' items is unknown. Options should be List[types.InputPollOption], other types are deprecated.")
62796279

62806280
# handle deprecated correct_option_id parameter
6281-
if correct_option_id is not None and type=="quiz":
6281+
if correct_option_id is not None:
62826282
if correct_option_ids is not None:
62836283
# show a conflict warning
62846284
logger.warning("Both 'correct_option_id' and 'correct_option_ids' parameters are set: use 'correct_option_ids' instead.")

telebot/async_telebot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7799,7 +7799,7 @@ async def send_poll(
77997799
raise RuntimeError("Type of 'options' items is unknown. Options should be List[types.InputPollOption], other types are deprecated.")
78007800

78017801
# handle deprecated correct_option_id parameter
7802-
if correct_option_id is not None and type=="quiz":
7802+
if correct_option_id is not None:
78037803
if correct_option_ids is not None:
78047804
# show a conflict warning
78057805
logger.warning("Both 'correct_option_id' and 'correct_option_ids' parameters are set: use 'correct_option_ids' instead.")

telebot/asyncio_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ async def save_prepared_inline_message(token, user_id, result: types.InlineQuery
439439
payload['allow_group_chats'] = allow_group_chats
440440
if allow_channel_chats is not None:
441441
payload['allow_channel_chats'] = allow_channel_chats
442-
return await _process_request(token, method_url, params=payload)
442+
return await _process_request(token, method_url, params=payload, method='post')
443443

444444

445445
async def save_prepared_keyboard_button(token, user_id, button: types.KeyboardButton):
@@ -2593,7 +2593,7 @@ async def send_poll(
25932593
if hide_results_until_closes is not None:
25942594
payload['hide_results_until_closes'] = hide_results_until_closes
25952595
if correct_option_ids is not None:
2596-
payload['correct_option_ids'] = correct_option_ids
2596+
payload['correct_option_ids'] = json.dumps(correct_option_ids)
25972597
if description is not None:
25982598
payload['description'] = description
25992599
if description_parse_mode is not None:

telebot/types.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def __init__(self, update_id, message, edited_message, channel_post, edited_chan
278278
self.edited_business_message: Optional[Message] = edited_business_message
279279
self.deleted_business_messages: Optional[BusinessMessagesDeleted] = deleted_business_messages
280280
self.purchased_paid_media: Optional[PaidMediaPurchased] = purchased_paid_media
281-
self.managed_bot: Optional[User] = managed_bot
281+
self.managed_bot: Optional[ManagedBotUpdated] = managed_bot
282282

283283
class ChatMemberUpdated(JsonDeserializable):
284284
"""
@@ -1780,7 +1780,7 @@ def __init__(self, message_id, from_user, date, chat, content_type, options, jso
17801780
self.managed_bot_created: Optional[ManagedBotCreated] = None
17811781
self.poll_option_added: Optional[PollOptionAdded] = None
17821782
self.poll_option_deleted: Optional[PollOptionDeleted] = None
1783-
self.reply_to_poll_option_id: Optional[int] = None
1783+
self.reply_to_poll_option_id: Optional[str] = None
17841784

17851785
for key in options:
17861786
setattr(self, key, options[key])
@@ -7714,15 +7714,11 @@ def to_json(self):
77147714

77157715
def to_dict(self):
77167716
# Left for backward compatibility, but with no support for voter_chat
7717+
logger.warning("PollAnswer.to_dict is deprecated and will be removed in future versions.")
77177718
json_dict = {
77187719
"poll_id": self.poll_id,
77197720
"option_ids": self.option_ids,
7720-
"option_persistent_ids": self.option_persistent_ids
77217721
}
7722-
if self.user:
7723-
json_dict["user"] = self.user.to_dict()
7724-
if self.voter_chat:
7725-
json_dict["voter_chat"] = self.voter_chat
77267722
return json_dict
77277723

77287724

@@ -13911,7 +13907,7 @@ def de_json(cls, json_string):
1391113907
return cls(**obj)
1391213908

1391313909

13914-
class PreparedKeyboardButton(JsonSerializable):
13910+
class PreparedKeyboardButton(JsonDeserializable):
1391513911
"""
1391613912
Describes a keyboard button to be used by a user of a Mini App.
1391713913

@@ -13926,14 +13922,11 @@ class PreparedKeyboardButton(JsonSerializable):
1392613922
def __init__(self, id: str, **kwargs):
1392713923
self.id: str = id
1392813924

13929-
def to_json(self):
13930-
return json.dumps(self.to_dict())
13931-
13932-
def to_dict(self):
13933-
data = {
13934-
'id': self.id
13935-
}
13936-
return data
13925+
@classmethod
13926+
def de_json(cls, json_string):
13927+
if json_string is None: return None
13928+
obj = cls.check_json(json_string)
13929+
return cls(**obj)
1393713930

1393813931

1393913932
class PollOptionAdded(JsonDeserializable):

0 commit comments

Comments
 (0)