Archived
1

Add battle announces to channel

Channel ID is configured in fw_zookeeper.yaml.
This commit is contained in:
2018-11-29 22:15:21 +04:00
parent eeee9a72e3
commit 0ba20b3ed5
7 changed files with 83 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
// Fantasy World Zookeeper Bot
// Copyright (c) 2018 Vladimir "fat0troll" Hodakov
package config
// Announces is a struct which handles announces configuration
type Announces struct {
ChannelID int64 `yaml:"channel_id"`
}

View File

@@ -6,5 +6,6 @@ package config
// Struct is a main configuration structure that holds all other
// structs within.
type Struct struct {
Telegram Telegram `yaml:"telegram"`
Telegram Telegram `yaml:"telegram"`
Announces Announces `yaml:"announces"`
}

View File

@@ -24,3 +24,26 @@ func RespondWithMarkdown(chatID int64, message string) {
log.Error().Err(err)
}
}
// RespondWithoutMarkdown will send message to given chat without parse mode
func RespondWithoutMarkdown(chatID int64, message string) {
messageParams := getMessageParams(chatID, message, false)
messageParams.ParseMode = "HTML"
_, err := bot.SendMessage(&messageParams)
if err != nil {
log.Error().Err(err)
}
}
// RespondWithInlineKeyboard will send message to given chat with Markdown parse
// mode and keyboard attached
func RespondWithInlineKeyboard(chatID int64, message string, keyboard *telegram.InlineKeyboardMarkup) {
messageParams := getMessageParams(chatID, message, false)
messageParams.ReplyMarkup = keyboard
_, err := bot.SendMessage(&messageParams)
if err != nil {
log.Error().Err(err)
}
}

View File

@@ -90,7 +90,6 @@ func StartBot() {
log.Info().Msg("Connection with Telegram established")
for update := range updates {
log.Debug().Msgf("%+v", update)
go router.Respond(update)
}
}