Archived
1
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues or pull requests.
i2_bot/lib/router/callback_request.go

30 lines
829 B
Go
Raw Normal View History

// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package router
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"regexp"
)
// RouteCallback routes inline requests to bot
func (r *Router) RouteCallback(update *tgbotapi.Update) string {
playerRaw, ok := c.Users.GetOrCreatePlayer(update.CallbackQuery.From.ID)
if !ok {
return "fail"
}
var enableAlarmCallback = regexp.MustCompile("enable_reminder_(\\d+)\\z")
var disableAlarmCallback = regexp.MustCompile("disable_reminder_(\\d+)\\z")
switch {
case enableAlarmCallback.MatchString(update.CallbackQuery.Data):
return c.Reminder.CreateAlarmSetting(update, &playerRaw)
case disableAlarmCallback.MatchString(update.CallbackQuery.Data):
return c.Reminder.DestroyAlarmSetting(update, &playerRaw)
}
return "ok"
}