use grammers_tl_types as tl;
pub struct Button {
pub raw: tl::enums::KeyboardButton,
}
pub struct Key {
pub raw: tl::enums::KeyboardButton,
}
impl Button {
pub fn data<T: Into<String>, B: Into<Vec<u8>>>(text: T, bytes: B) -> Button {
Button {
raw: tl::types::KeyboardButtonCallback {
text: text.into(),
data: bytes.into(),
requires_password: false,
style: None,
}
.into(),
}
}
pub fn switch<T: Into<String>, Q: Into<String>>(text: T, query: Q) -> Button {
Button {
raw: tl::types::KeyboardButtonSwitchInline {
text: text.into(),
query: query.into(),
same_peer: true,
style: None,
peer_types: None,
}
.into(),
}
}
pub fn switch_elsewhere<T: Into<String>, Q: Into<String>>(text: T, query: Q) -> Button {
Button {
raw: tl::types::KeyboardButtonSwitchInline {
text: text.into(),
query: query.into(),
same_peer: false,
style: None,
peer_types: None,
}
.into(),
}
}
pub fn url<T: Into<String>, U: Into<String>>(text: T, url: U) -> Button {
Button {
raw: tl::types::KeyboardButtonUrl {
style: None,
text: text.into(),
url: url.into(),
}
.into(),
}
}
pub fn webview<T: Into<String>, U: Into<String>>(text: T, url: U) -> Button {
Button {
raw: tl::types::KeyboardButtonWebView {
style: None,
text: text.into(),
url: url.into(),
}
.into(),
}
}
}
impl Key {
pub fn text<T: Into<String>>(text: T) -> Key {
Key {
raw: tl::types::KeyboardButton {
style: None,
text: text.into(),
}
.into(),
}
}
pub fn request_phone<T: Into<String>>(text: T) -> Key {
Key {
raw: tl::types::KeyboardButtonRequestPhone {
style: None,
text: text.into(),
}
.into(),
}
}
pub fn request_geo<T: Into<String>>(text: T) -> Key {
Key {
raw: tl::types::KeyboardButtonRequestGeoLocation {
style: None,
text: text.into(),
}
.into(),
}
}
pub fn request_poll<T: Into<String>>(text: T) -> Key {
Key {
raw: tl::types::KeyboardButtonRequestPoll {
style: None,
text: text.into(),
quiz: None,
}
.into(),
}
}
pub fn request_quiz<T: Into<String>>(text: T) -> Key {
Key {
raw: tl::types::KeyboardButtonRequestPoll {
style: None,
text: text.into(),
quiz: Some(true),
}
.into(),
}
}
}