create function that stores button parts and creates tg button wrapper

This commit is contained in:
Akulij 2025-06-06 03:32:27 +05:00
parent bde3c1a0e1
commit 6e31fa86e6

View File

@ -66,6 +66,23 @@ where
)) ))
} }
pub async fn callback_button<C, D>(
name: &str,
callback_name: String,
callback_data: C,
db: &mut D,
) -> BotResult<InlineKeyboardButton>
where
C: Serialize + for<'a> Deserialize<'a> + Send + Sync,
D: CallDB + Send + Sync,
{
let ci = CallbackInfo::new_with_literal(callback_data, callback_name)
.store(db)
.await?;
Ok(InlineKeyboardButton::callback(name, ci.get_id()))
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;