Added menu endpoints

This commit is contained in:
2023-07-25 19:09:34 +03:00
parent 64a5435dc3
commit 96c7d2e37e
6 changed files with 75 additions and 2 deletions

View File

@@ -24,6 +24,22 @@ pub async fn account_markup(
Ok(markup)
}
#[inline]
pub fn menu_markup(names: impl IntoIterator<Item = String>) -> InlineKeyboardMarkup {
let names = names
.into_iter()
.map(|name| {
let hash = <Sha256 as Digest>::digest(name.as_bytes());
let mut data = "get ".to_owned();
data.reserve(43);
B64_ENGINE.encode_string(hash, &mut data);
InlineKeyboardButton::callback(name, data)
})
.chunks(3);
InlineKeyboardMarkup::new(&names)
}
/// Creates a markup with a "Delete message" button.
/// This markup should be added for all messages that won't be deleted afterwards
#[inline]