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

support callback button #279

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

support callback button #279

wants to merge 1 commit into from

Conversation

RuofengX
Copy link
Contributor

Copy link
Contributor Author

@RuofengX RuofengX left a comment

Choose a reason for hiding this comment

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

Here list a todo-list.

@@ -388,6 +388,50 @@ impl Message {
self.raw.reply_markup.clone()
}

/// Collect all inline callback buttons. Those buttons often appeare in bot chat.
/// Buttons could be clicked by [`click_callback_button`]
pub fn callback_buttons(&self) -> Option<Vec<tl::types::KeyboardButtonCallback>> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only handle KeyboardButtonCallback, other KeyboardButton types cannot handle.

Copy link
Owner

Choose a reason for hiding this comment

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

I was thinking more to return a custom type of buttons, so that .click() could be called directly on the one you need.

By the way, might be good to call this "inline buttons". The term in your code is used by the API, but I believe the other term is more common in the applications? Not sure what the bot API calls it.

button: &tl::types::KeyboardButtonCallback,
) -> Result<()> {
if button.requires_password {
unimplemented!()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't know how to deal with password.

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah it's a bit of a mess. I'd take the implementation from Telethon.

let rtn = self
.client
.invoke(&tl::functions::GetBotCallbackAnswer {
game: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't know how to deal with game flag.

Copy link
Owner

Choose a reason for hiding this comment

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

Likewise.

tl::enums::KeyboardButton::Callback(callback_b) => {
rtn.push(callback_b.clone());
}
_ => (),
Copy link
Owner

Choose a reason for hiding this comment

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

This means the position in the returned array will not match the one users see in the application. Which would be really confusing.

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