Add info command & fix mentions with underscores

This commit is contained in:
2024-08-04 11:26:45 +03:00
parent 4a47b83226
commit e886a22046
4 changed files with 25 additions and 10 deletions
+5 -2
View File
@@ -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 {
+1
View File
@@ -17,6 +17,7 @@ type MessageUpdate struct {
type Message struct {
Text string
UseMarkdown bool
Image *Image
Video *Video
}
+3 -1
View File
@@ -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 = "Неизвестная команда!"
}
+13 -4
View File
@@ -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}
}