Archived
1

Add fixes and linter improvements to talkers package

This commit is contained in:
2018-03-31 17:25:41 +04:00
parent 4abfc457ce
commit c4d146ba20
8 changed files with 50 additions and 31 deletions

View File

@@ -12,6 +12,10 @@ var (
c *appcontext.Context
)
const (
parseMode = "Markdown"
)
// Sender is a function-handling struct for sender
type Sender struct{}

View File

@@ -7,10 +7,10 @@ import (
"github.com/go-telegram-bot-api/telegram-bot-api"
)
// SendMarkdownAnswer sends markdown-powered message as reply
// SendMarkdownAnswer sends markdown-powered message as answer
func (s *Sender) SendMarkdownAnswer(update *tgbotapi.Update, message string) {
msg := tgbotapi.NewMessage(update.Message.Chat.ID, message)
msg.ParseMode = "Markdown"
msg.ParseMode = parseMode
_, err := c.Bot.Send(msg)
if err != nil {
@@ -21,7 +21,19 @@ func (s *Sender) SendMarkdownAnswer(update *tgbotapi.Update, message string) {
// SendMarkdownMessageToChatID sends markdown-powered message to specified chat
func (s *Sender) SendMarkdownMessageToChatID(chatID int64, message string) {
msg := tgbotapi.NewMessage(chatID, message)
msg.ParseMode = "Markdown"
msg.ParseMode = parseMode
_, err := c.Bot.Send(msg)
if err != nil {
c.Log.Error(err.Error())
}
}
// SendMarkdownReply sends markdown-powered message as reply
func (s *Sender) SendMarkdownReply(update *tgbotapi.Update, message string, messageID int) {
msg := tgbotapi.NewMessage(update.Message.Chat.ID, message)
msg.ParseMode = parseMode
msg.ReplyToMessageID = messageID
_, err := c.Bot.Send(msg)
if err != nil {

View File

@@ -13,4 +13,5 @@ type SenderInterface interface {
SendMarkdownAnswer(update *tgbotapi.Update, message string)
SendMarkdownMessageToChatID(chatID int64, message string)
SendMarkdownReply(update *tgbotapi.Update, message string, messageID int)
}