-
Notifications
You must be signed in to change notification settings - Fork 117
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
base: master
Are you sure you want to change the base?
Conversation
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.
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>> { |
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.
Only handle KeyboardButtonCallback, other KeyboardButton types cannot handle.
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 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!() |
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.
Don't know how to deal with password.
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.
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, |
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.
Don't know how to deal with game flag.
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.
Likewise.
tl::enums::KeyboardButton::Callback(callback_b) => { | ||
rtn.push(callback_b.clone()); | ||
} | ||
_ => (), |
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.
This means the position in the returned array will not match the one users see in the application. Which would be really confusing.
#191