// 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) }