hdkv
/
fwzookeeper
Archived
1
Fork 0
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues/pull-requests.
fwzookeeper/domains/battles/v1/announce.go

33 lines
1.1 KiB
Go

// Fantasy World Zookeeper Bot
// Copyright (c) 2018 Vladimir "fat0troll" Hodakov
package battlesv1
import (
"gitlab.com/toby3d/telegram"
itelegram "source.hodakov.me/fat0troll/fwzookeeper/internal/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)
}