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.
Vladimir Hodakov 401f962bd2
Move support of channel to helper with TDLib
Now we're discarding messages sent directly to us, except for
messages from @fw_zookeeper.
2019-01-08 05:00:16 +04:00

33 lines
1.1 KiB
Go

// Fantasy World Zookeeper Bot
// Copyright (c) 2018 Vladimir "fat0troll" Hodakov
package battlesv1
import (
"gitlab.com/toby3d/telegram"
itelegram "lab.wtfteam.pro/fat0troll/fw_zookeeper/local/telegram"
"strings"
)
// AnnounceBattle posts battle announce to channel
func AnnounceBattle(update *telegram.Update) {
announcerID := 788961789
if update.Message.From.ID != announcerID {
log.Warn().Msgf("Someone trying to mimic announcer: user with ID %d and username %s", update.Message.From.ID, update.Message.From.Username)
return
}
battleInformationArray := strings.Split(update.Message.Text, " ")
if len(battleInformationArray) != 2 {
log.Error().Msgf("Unexpected battle information format: got %d elements instead of 2", len(battleInformationArray))
return
}
battleType := battleInformationArray[0]
battleTag := battleInformationArray[1]
log.Debug().Msgf("Battle type «%s», battle tag %s", battleType, battleTag)
itelegram.RespondWithoutMarkdown(c.Config.Announces.ChannelID, battleType)
itelegram.RespondWithoutMarkdown(c.Config.Announces.ChannelID, battleTag)
}