Add battle announces to channel
Channel ID is configured in fw_zookeeper.yaml.
This commit is contained in:
9
internal/config/announces.go
Normal file
9
internal/config/announces.go
Normal 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"`
|
||||
}
|
@@ -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"`
|
||||
}
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user