mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-10 20:12:25 +01:00
commit
896c9991f4
3 changed files with 39 additions and 16 deletions
|
@ -12,6 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Support for Telegram Bot API [version 6.0](https://core.telegram.org/bots/api#april-16-2022)
|
||||
- Note that some field were renamed
|
||||
|
||||
### Changed
|
||||
|
||||
- Accept `IntoIterator` in `KeyboardMarkup::append_row`.
|
||||
- Accept `Into<String>` instead of `String` in `InlineKeyboardButton::{url, callback, switch_inline_query, switch_inline_query_current_chat}`.
|
||||
|
||||
## 0.5.1 - 2022-04-18
|
||||
|
||||
### Fixed
|
||||
|
|
|
@ -123,35 +123,50 @@ pub enum InlineKeyboardButtonKind {
|
|||
/// let url_button = InlineKeyboardButton::url("Text".to_string(), url);
|
||||
/// ```
|
||||
impl InlineKeyboardButton {
|
||||
pub fn url(text: String, url: reqwest::Url) -> InlineKeyboardButton {
|
||||
pub fn url<T>(text: T, url: reqwest::Url) -> InlineKeyboardButton
|
||||
where
|
||||
T: Into<String>,
|
||||
{
|
||||
InlineKeyboardButton {
|
||||
text,
|
||||
text: text.into(),
|
||||
kind: InlineKeyboardButtonKind::Url(url),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn callback(text: String, callback_data: String) -> InlineKeyboardButton {
|
||||
pub fn callback<T, C>(text: T, callback_data: C) -> InlineKeyboardButton
|
||||
where
|
||||
T: Into<String>,
|
||||
C: Into<String>,
|
||||
{
|
||||
InlineKeyboardButton {
|
||||
text,
|
||||
kind: InlineKeyboardButtonKind::CallbackData(callback_data),
|
||||
text: text.into(),
|
||||
kind: InlineKeyboardButtonKind::CallbackData(callback_data.into()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn switch_inline_query(text: String, switch_inline_query: String) -> InlineKeyboardButton {
|
||||
pub fn switch_inline_query<T, Q>(text: T, switch_inline_query: Q) -> InlineKeyboardButton
|
||||
where
|
||||
T: Into<String>,
|
||||
Q: Into<String>,
|
||||
{
|
||||
InlineKeyboardButton {
|
||||
text,
|
||||
kind: InlineKeyboardButtonKind::SwitchInlineQuery(switch_inline_query),
|
||||
text: text.into(),
|
||||
kind: InlineKeyboardButtonKind::SwitchInlineQuery(switch_inline_query.into()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn switch_inline_query_current_chat(
|
||||
text: String,
|
||||
switch_inline_query_current_chat: String,
|
||||
) -> InlineKeyboardButton {
|
||||
pub fn switch_inline_query_current_chat<T, Q>(
|
||||
text: T,
|
||||
switch_inline_query_current_chat: Q,
|
||||
) -> InlineKeyboardButton
|
||||
where
|
||||
T: Into<String>,
|
||||
Q: Into<String>,
|
||||
{
|
||||
InlineKeyboardButton {
|
||||
text,
|
||||
text: text.into(),
|
||||
kind: InlineKeyboardButtonKind::SwitchInlineQueryCurrentChat(
|
||||
switch_inline_query_current_chat,
|
||||
switch_inline_query_current_chat.into(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,8 +67,11 @@ impl KeyboardMarkup {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn append_row(mut self, buttons: Vec<KeyboardButton>) -> Self {
|
||||
self.keyboard.push(buttons);
|
||||
pub fn append_row<R>(mut self, buttons: R) -> Self
|
||||
where
|
||||
R: IntoIterator<Item = KeyboardButton>,
|
||||
{
|
||||
self.keyboard.push(buttons.into_iter().collect());
|
||||
self
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue