Update recent keyboard after commit
continuous-integration/drone/push Build is passing Details

This commit is contained in:
SeraphJACK 2023-09-26 21:47:22 +08:00
parent 844d11d5c8
commit c3d68989a1
Signed by: SeraphJACK
GPG Key ID: B4FFEA56F3BE0D0C
2 changed files with 23 additions and 16 deletions

View File

@ -70,22 +70,7 @@ func handleMessage(ctx *messageHandleContext) {
}
if msg.Command() == "recent" {
var btns [][]tgbotapi.KeyboardButton
for _, v := range recentCmds {
btns = append(btns, tgbotapi.NewKeyboardButtonRow(
tgbotapi.NewKeyboardButton(v.command),
))
}
msg := tgbotapi.NewMessage(ctx.chat.ID, "Recent Commands")
if len(btns) > 0 {
markup := tgbotapi.NewReplyKeyboard(btns...)
markup.OneTimeKeyboard = true
msg.ReplyMarkup = markup
}
_, err := ctx.bot.Send(msg)
if err != nil {
log.Printf("Failed to send recent menu: %v", err)
}
updateRecentKeyboard(ctx)
return
}
@ -126,3 +111,23 @@ func handleMessage(ctx *messageHandleContext) {
func handleCallbackQuery(query *tgbotapi.CallbackQuery) {
cancel(query.Data)
}
func updateRecentKeyboard(ctx *messageHandleContext) {
var btns [][]tgbotapi.KeyboardButton
for _, v := range recentCmds {
btns = append(btns, tgbotapi.NewKeyboardButtonRow(
tgbotapi.NewKeyboardButton(v.command),
))
}
msg := tgbotapi.NewMessage(ctx.chat.ID, "Recent Commands")
if len(btns) > 0 {
markup := tgbotapi.NewReplyKeyboard(btns...)
markup.OneTimeKeyboard = true
msg.ReplyMarkup = markup
}
_, err := ctx.bot.Send(msg)
if err != nil {
log.Printf("Failed to send recent menu: %v", err)
}
return
}

View File

@ -64,5 +64,7 @@ func commitAll() {
}
// delete transaction confirmation message
go v.ctx.bot.Send(tgbotapi.NewDeleteMessage(v.ctx.chat.ID, v.confirmMsg.MessageID))
go updateRecentKeyboard(v.ctx)
}
}