Vladimir Hodakov
b8226d8aa8
Recent game update changed pokememes view in pokedeks, so we need to reflect it by updating parser. Introducing DataCache - a silver bullet for eliminating lags linked to database queries. Less queries, more in RAM, faster work. Needs testing in production environment.
33 lines
690 B
Go
33 lines
690 B
Go
// i2_bot – Instinct PokememBro Bot
|
||
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
|
||
|
||
package pokedexer
|
||
|
||
import (
|
||
"github.com/go-telegram-bot-api/telegram-bot-api"
|
||
"strconv"
|
||
)
|
||
|
||
// DeletePokememe deletes pokememe by its ID
|
||
func (p *Pokedexer) DeletePokememe(update *tgbotapi.Update) string {
|
||
pokememeNum, _ := strconv.Atoi(update.Message.CommandArguments())
|
||
if pokememeNum == 0 {
|
||
return "fail"
|
||
}
|
||
|
||
err := c.DataCache.DeletePokememeByID(pokememeNum)
|
||
if err != nil {
|
||
c.Log.Error(err.Error())
|
||
return "fail"
|
||
}
|
||
|
||
message := "Покемем удалён."
|
||
|
||
msg := tgbotapi.NewMessage(update.Message.Chat.ID, message)
|
||
msg.ParseMode = "Markdown"
|
||
|
||
c.Bot.Send(msg)
|
||
|
||
return "ok"
|
||
}
|