Skip to content

Commit 9b0de24

Browse files
committed
feat: add return_card option to inline keyboard buttons
1 parent b432d4a commit 9b0de24

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/cmd_carte.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,21 @@ pub async fn start_card_dialogue(
4747
// bot.delete_message(msg.chat.id, msg.id).await?;
4848

4949
// if there is a holder:
50-
let cartd_status = "random"; // TODO get DB info from who hold the card
50+
let cartd_status = "CLIC"; // TODO get DB info from who hold the card
51+
52+
let is_at_office = cartd_status == "CLIC";
53+
let (text, token) = if is_at_office {("Donner la carte", "give_card")} else {("Rendre la carte", "return_card")};
54+
55+
let row = vec![
56+
InlineKeyboardButton::callback(text, token),
57+
InlineKeyboardButton::callback("Cancel", "nothing")
58+
];
5159

5260
log::debug!("Sending message with inline keyboard for callback");
5361

54-
let keyboard: Vec<Vec<InlineKeyboardButton>> = vec![vec![InlineKeyboardButton::callback("Donnez la carte", "give_card"), InlineKeyboardButton::callback("Cancel", "nothing")]];
55-
5662
bot
5763
.send_message(msg.chat.id, cartd_status)
58-
.reply_markup(ReplyMarkup::InlineKeyboard(InlineKeyboardMarkup::new(keyboard)))
64+
.reply_markup(ReplyMarkup::InlineKeyboard(InlineKeyboardMarkup::new(vec![row])))
5965
.await?;
6066

6167
log::debug!("Updating dialogue to ChooseTarget");

0 commit comments

Comments
 (0)