Update recent keyboard after commit
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
844d11d5c8
commit
c3d68989a1
37
bot/bot.go
37
bot/bot.go
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue