Add info command & fix mentions with underscores
This commit is contained in:
@@ -14,7 +14,7 @@ func NewAnonymousQuestionsService(
|
||||
|
||||
const (
|
||||
messageSentReply = "*Сообщение отправлено!*"
|
||||
newMessageNotification = "*Новое анонимное сообщение!*"
|
||||
newMessageNotification = "Новое анонимное сообщение!"
|
||||
)
|
||||
|
||||
type AnonymousMessagesService interface {
|
||||
@@ -50,7 +50,10 @@ func (s *anonymousMessagesService) ServeMessages() error {
|
||||
}
|
||||
|
||||
func (s *anonymousMessagesService) pingClient(chatID int64) error {
|
||||
return s.api.SendMessage(chatID, Message{Text: messageSentReply})
|
||||
return s.api.SendMessage(chatID, Message{
|
||||
Text: messageSentReply,
|
||||
UseMarkdown: true,
|
||||
})
|
||||
}
|
||||
|
||||
func (s *anonymousMessagesService) handleMessage(message Message) error {
|
||||
|
||||
+4
-3
@@ -16,9 +16,10 @@ type MessageUpdate struct {
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
Text string
|
||||
Image *Image
|
||||
Video *Video
|
||||
Text string
|
||||
UseMarkdown bool
|
||||
Image *Image
|
||||
Video *Video
|
||||
}
|
||||
|
||||
type Image struct {
|
||||
|
||||
@@ -22,7 +22,9 @@ func (h *commandHandler) HandleCommand(update MessageUpdate) error {
|
||||
var msgText string
|
||||
switch *update.Command {
|
||||
case StartCommand:
|
||||
msgText = "Жду твоих вопросов!"
|
||||
msgText = "Жду твоих вопросов!!\nОтветы будут в канале @meme_me_a_meme (>ᴗ•)"
|
||||
case InfoCommand:
|
||||
msgText = "Бот привязан к каналу @meme_me_a_meme, так что ответы ищи там!!\nНа данный момент поддерживаются текст, фото и видео („• ᴗ •„)"
|
||||
case UnknownCommand:
|
||||
msgText = "Неизвестная команда!"
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
const (
|
||||
updateTimeoutInSeconds = 60
|
||||
messageParseMode = tgbotapi.ModeMarkdown
|
||||
|
||||
startCommand = "start"
|
||||
infoCommand = "info"
|
||||
@@ -88,7 +87,10 @@ func (api *botAPI) sendTextMessage(chatID int64, message app.Message) error {
|
||||
chatID,
|
||||
message.Text,
|
||||
)
|
||||
msg.ParseMode = messageParseMode
|
||||
|
||||
if message.UseMarkdown {
|
||||
msg.ParseMode = tgbotapi.ModeMarkdown
|
||||
}
|
||||
|
||||
_, err := api.bot.Send(msg)
|
||||
return errors.WithStack(err)
|
||||
@@ -160,7 +162,10 @@ func (api *botAPI) hydrateVideo(video *tgbotapi.Video) *app.Video {
|
||||
func (api *botAPI) preparePhotos(message app.Message) []interface{} {
|
||||
photo := tgbotapi.NewInputMediaPhoto(tgbotapi.FileID(message.Image.FileID))
|
||||
photo.Caption = message.Text
|
||||
photo.ParseMode = messageParseMode
|
||||
|
||||
if message.UseMarkdown {
|
||||
photo.ParseMode = tgbotapi.ModeMarkdown
|
||||
}
|
||||
|
||||
var photos []interface{}
|
||||
photos = append(photos, photo)
|
||||
@@ -171,6 +176,10 @@ func (api *botAPI) preparePhotos(message app.Message) []interface{} {
|
||||
func (api *botAPI) prepareVideo(message app.Message) []interface{} {
|
||||
video := tgbotapi.NewInputMediaVideo(tgbotapi.FileID(message.Video.FileID))
|
||||
video.Caption = message.Text
|
||||
video.ParseMode = messageParseMode
|
||||
|
||||
if message.UseMarkdown {
|
||||
video.ParseMode = tgbotapi.ModeMarkdown
|
||||
}
|
||||
|
||||
return []interface{}{video}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user