50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
// Fantasy World Zookeeper Bot
|
|
// Copyright (c) 2018 Vladimir "fat0troll" Hodakov
|
|
|
|
package telegram
|
|
|
|
import (
|
|
"gitlab.com/toby3d/telegram"
|
|
)
|
|
|
|
func getMessageParams(chatID int64, message string, disableWebPagePreview bool) telegram.SendMessageParameters {
|
|
return telegram.SendMessageParameters{
|
|
ChatID: chatID,
|
|
Text: message,
|
|
ParseMode: "Markdown",
|
|
DisableWebPagePreview: disableWebPagePreview}
|
|
}
|
|
|
|
// RespondWithMarkdown will send message to given chat with Markdown parse mode
|
|
func RespondWithMarkdown(chatID int64, message string) {
|
|
messageParams := getMessageParams(chatID, message, false)
|
|
|
|
_, err := bot.SendMessage(&messageParams)
|
|
if err != nil {
|
|
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)
|
|
}
|
|
}
|