Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
enable delay suggestions (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
PKuebler authored Sep 2, 2020
1 parent 4a7380b commit c488478
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
11 changes: 8 additions & 3 deletions cmd/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,16 @@ func BotCommand(ctx context.Context, cmd *cobra.Command, args []string) {
if tctx.IsRemoveSuggestions() {
reply.ReplyMarkup = tgbotapi.NewRemoveKeyboard(true)
} else if tctx.IsSuggestions() {
buttons := []tgbotapi.KeyboardButton{}
buttons := [][]tgbotapi.KeyboardButton{}
for _, button := range tctx.Suggestions() {
buttons = append(buttons, tgbotapi.NewKeyboardButton(button.Label))
buttons = append(
buttons,
tgbotapi.NewKeyboardButtonRow(
tgbotapi.NewKeyboardButton(button.Label),
),
)
}
keyboard := tgbotapi.NewReplyKeyboard(buttons)
keyboard := tgbotapi.NewReplyKeyboard(buttons...)
reply.ReplyMarkup = keyboard
}

Expand Down
13 changes: 12 additions & 1 deletion pkg/interface/telegram/editdelay.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,16 @@ func (t *TelegramService) EditDelay(ctx telegramconversation.TContext) telegramc
}

ctx.SetStatePayload(alarm.GetID())
return ctx.SendWithState(fmt.Sprintf("Ab wie viel Abweichung von `%s > %s` soll bescheid gesagt werden? z.B. 1h5min oder 10m", alarm.GetTrainName(), alarm.GetFinalDestinationName()), "savedelay")
ctx.ChangeState("savedelay")

txt := fmt.Sprintf("Ab wie viel Abweichung von `%s > %s` soll bescheid gesagt werden? z.B. 1h5min oder 10m", alarm.GetTrainName(), alarm.GetFinalDestinationName())

buttons := []telegramconversation.TButton{}
units := []string{"1m", "5m", "10m", "15m", "20m", "30m", "1h", "1h30m"}
for _, unit := range units {
button := telegramconversation.NewTButton(unit, unit)
buttons = append(buttons, button)
}

return ctx.SendWithSuggestions(txt, buttons, 1)
}

0 comments on commit c488478

Please sign in to comment.