-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bot API Huge Update - 7.0, introducing reactions, replies and some other changes #2106
Conversation
…senting different types of reaction.
…ctions, represented by the class MessageReactionCountUpdated and the field message_reaction_count in the class Update. The bot must explicitly allow the update to receive it.
…e ExternalReplyInfo to the class Message, containing information about a message that is replied to by the current message, but can be from another chat or forum topic.
…; CHECK THE COMMIT!
telebot/types.py
Outdated
@@ -1208,6 +1214,13 @@ def de_json(cls, json_string): | |||
if 'story' in obj: | |||
opts['story'] = Story.de_json(obj['story']) | |||
content_type = 'story' | |||
if 'external_reply' in obj: | |||
opts['external_reply'] = ExternalReplyInfo.de_json(obj['external_reply']) | |||
content_type = 'text' # @Badiboy not sure about content_types in here, please check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Badiboy check this line and the lines below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check it in previous commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I get the meaning of the field "external_reply" - it contains ADDITIONAL INFORMATION to the main content. So it should not process content_type at all: content_type will be set by the main data fields like "text"/"audio" etc.
The same for "quote".
I'll removed the content_type assignment in commit.
… in the class InputTextMessageContent.
…mation about the link preview options used to send the message.
…Users and added the field max_quantity to it. Renamed the field request_user in the class KeyboardButton to request_users. The old name will still work for backward compatibility.
…lass Message with the field users_shared.
content_type = 'user_shared' | ||
if 'users_shared' in obj: | ||
opts['users_shared'] = UserShared.de_json(obj['users_shared']) | ||
content_type = 'users_shared' # COMPATIBILITY BROKEN! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Badiboy compatibility will be broken here. They renamed the property, and this makes me rename the content_type too. Any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any better way... Let's hope not much people used this content type...
Bot API Update is just a bunch of deprecation warnings. Always. |
Fix "new_" usage. No valuable changes.
reply_to_message_id and allow_sending_without_reply deprecation extended with more precise values processing
@coder2020official |
disable_web_page_preview deprecation extended with more precise values processing
@coder2020official For commit 56fbcaf please update Async in the same way if you confirm these changes. |
def set_message_reaction(token, chat_id, message_id, reaction=None, is_big=None): | ||
method_url = r'setMessageReaction' | ||
payload = {'chat_id': chat_id, 'message_id': message_id} | ||
if reaction: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proposal.
Check if reaction is not list (single reaction) and convert it to list.
or
Check if reaction is not list and raise error with explanation.
Reasonable.
I suppose lot of mistakes by users because of parameter naming: "reaction".
@@ -586,6 +592,8 @@ async def process_new_updates(self, updates: List[types.Update]): | |||
new_my_chat_members = None | |||
new_chat_members = None | |||
chat_join_request = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Propose rename all three items to "new_".
if new_message_reaction_count_handlers: | ||
await self.process_new_message_reaction_count(new_message_reaction_count_handlers) | ||
if chat_boost_handlers: | ||
await self.process_new_chat_boost(chat_boost_handlers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed_chat_boost_handlers !
@@ -5490,6 +6133,33 @@ async def answer_callback_query( | |||
:rtype: :obj:`bool` | |||
""" | |||
return await asyncio_helper.answer_callback_query(self.token, callback_query_id, text, show_alert, url, cache_time) | |||
|
|||
# getUserChatBoosts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comment
@@ -776,6 +833,9 @@ class Message(JsonDeserializable): | |||
:param forward_date: Optional. For forwarded messages, date the original message was sent in Unix time | |||
:type forward_date: :obj:`int` | |||
|
|||
:forward_origin: Optional. For forwarded messages, information about the original message; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment for me: set deprecation for forward_xxx fields (in the next update: this one is too large).
Added the class MessageOrigin and replaced the fields forward_from, forward_from_chat, forward_from_message_id, forward_signature, forward_sender_name, and forward_date with the field forward_origin of type MessageOrigin in the class Message.
@@ -1283,9 +1390,20 @@ def __init__(self, message_id, from_user, date, chat, content_type, options, jso | |||
self.general_forum_topic_hidden: Optional[GeneralForumTopicHidden] = None | |||
self.general_forum_topic_unhidden: Optional[GeneralForumTopicUnhidden] = None | |||
self.write_access_allowed: Optional[WriteAccessAllowed] = None | |||
self.user_shared: Optional[UserShared] = None | |||
self.users_shared: Optional[UserShared] = None | |||
self.user_shared: Optional[UserShared] = self.users_shared |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment for me: process with deprecation
return data | ||
|
||
KeyboardButtonRequestUser = KeyboardButtonRequestUsers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Process with deprecation.
@@ -7515,7 +7647,7 @@ def __init__(self, from_request: Optional[bool]=None, web_app_name: Optional[str | |||
class UserShared(JsonDeserializable): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment for me: change class from UserShared => UsersShared + deprecation
:rtype: :class:`ExternalReplyInfo` | ||
""" | ||
@classmethod | ||
def de_json(cls, json_string): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad autogenerated code not corresponding to common way. It's better to check autogeneration resutls.
return None | ||
obj = cls.check_json(json_string) | ||
|
||
return cls(is_disabled=obj.get('is_disabled'), url=obj.get('url'), prefer_small_media=obj.get('prefer_small_media'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad.
@coder2020official I'm done. You did a huge work. Me too. :) This update is suitable to merge and then we'll fix raised questions in separate SMALL updates ) |
Nice! |
I did critical fixes for Async also. The given comments are regarding "fine tuning" and are left for you: if you think it's usefull - you can apply the same in Async. |
@coder2020official What about new version? |
4.2, 5 is a way big number |
And about the fine tuning - are you talking about type hints? |
4.2 is not possible, it already exists. :) 4.14 is not 4.1.4 ))) |
December 29, 2023
Bot API 7.0
Reactions
Replies 2.0
Link Preview Customization
Block Quotation
Multiple Message Actions
Request for multiple users
Chat Boost
Giveaway
Other Changes