Vladimir Hodakov
a9f1d25c7b
This commit introduces pokememes information storage in source code (because they're rarely changed and I always update them manually). All information about pokememes updated after nerf of 25 April. Also, added buttons to /pokedeks command for changing pages (there are 21 pages already!), and limited one page to 35 pokememes.
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
// i2_bot – Instinct PokememBro Bot
|
||
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
|
||
|
||
package router
|
||
|
||
import (
|
||
"regexp"
|
||
|
||
"github.com/go-telegram-bot-api/telegram-bot-api"
|
||
)
|
||
|
||
// RouteCallback routes inline requests to bot
|
||
func (r *Router) RouteCallback(update tgbotapi.Update) string {
|
||
playerRaw, err := c.DataCache.GetOrCreatePlayerByTelegramID(update.CallbackQuery.From.ID)
|
||
if err != nil {
|
||
c.Log.Error(err.Error())
|
||
return "fail"
|
||
}
|
||
|
||
if playerRaw.Status == "banned" {
|
||
return c.Talkers.BanError(&update)
|
||
}
|
||
|
||
var enableAlarmCallback = regexp.MustCompile("enable_reminder_(\\d+)\\z")
|
||
var disableAlarmCallback = regexp.MustCompile("disable_reminder_(\\d+)\\z")
|
||
var pokedeksPageCallback = regexp.MustCompile("pokedeks(\\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)
|
||
case pokedeksPageCallback.MatchString(update.CallbackQuery.Data):
|
||
return c.Pokedexer.PokememesListUpdater(&update)
|
||
}
|
||
|
||
return "ok"
|
||
}
|