Skip to content
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

[V2] add inlinecallback to buttoncallback event #4252

Open
wants to merge 13 commits into
base: v2
Choose a base branch
from

Conversation

apepenkov
Copy link
Contributor

Allow ButtonCallback event to handle UpdateInlineBotCallbackQuery, add chat property to it

client/src/telethon/_impl/client/events/queries.py Outdated Show resolved Hide resolved
@@ -75,8 +88,10 @@ async def get_message(self) -> Optional[Message]:
"""
Get the :class:`~telethon.types.Message` containing the button that was clicked.

If the message is too old and is no longer accessible, :data:`None` is returned instead.
If the message is inline, or too old and is no longer accessible, :data:`None` is returned instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But isn't the purpose of using InputMessageCallbackQuery the fact that it can work? functions.messages.get_messages doesn't need a chat. CherryPickedList does require one, so I see the problem.

But we should be able to fetch the message without a chat. So maybe we need to rethink this method's implementation.

@apepenkov
Copy link
Contributor Author

Getting message from inline doesn't really work, unless peer is known. Not sure if it should. Needs to be investigated

@apepenkov
Copy link
Contributor Author

For the editing of inline messages - there are multiple options what to do with it.

  • leave users to use raw api
  • create separate friendly method for editing it
  • update friendly method edit_message to accept abcs.InputBotInlineMessageId, and call edit_inline_bot_message under the hood
  • create edit_message just for this update type.

My opinion - 2nd or 3rd are the best options. 3rd is better for users, 2nd is better for maitainers - especially since edit_inline_bot_message just returns a bool

return isinstance(self._raw, types.UpdateInlineBotCallbackQuery)

@property
def message_id(self) -> typing.Union[int, abcs.InputBotInlineMessageId]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should never return abcs to the user. They're in a private package.

client/src/telethon/_impl/client/events/queries.py Outdated Show resolved Hide resolved
client/src/telethon/_impl/client/events/queries.py Outdated Show resolved Hide resolved
client/src/telethon/_impl/client/events/queries.py Outdated Show resolved Hide resolved

if owner_id > 0:
# We can't know if it's really a chat with user, or an ID of the user who issued the inline query.
# So it's better to return None, then to return wrong chat.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo then -> than.

Still a bit weird that there's no way to tell. Does the update type not contain any other hint elsewhere?

if packed:
access_hash = packed.access_hash

return Channel._from_raw(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not check the chat_map with the owner_id first?

client/src/telethon/_impl/client/events/queries.py Outdated Show resolved Hide resolved
client/src/telethon/_impl/client/types/chat/channel.py Outdated Show resolved Hide resolved
@apepenkov
Copy link
Contributor Author

apepenkov commented Dec 18, 2023

Note - message id, that is unpacked from types.InputBotInlineMessageId/types.InputBotInlineMessageId64 (in case of PM or simple chat) is sender's message id, not even bot's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants