Add warning for stickers
This commit is contained in:
@@ -13,7 +13,9 @@ func NewAnonymousQuestionsService(
|
||||
}
|
||||
|
||||
const (
|
||||
messageSentReply = "*Сообщение отправлено!*"
|
||||
messageSentReply = "*Сообщение отправлено!*"
|
||||
unsupportedMessageReply = "*Такое сообщение не поддерживается :(*"
|
||||
|
||||
newMessageNotification = "Новое анонимное сообщение!"
|
||||
)
|
||||
|
||||
@@ -37,30 +39,33 @@ func (s *anonymousMessagesService) ServeMessages() error {
|
||||
return
|
||||
}
|
||||
|
||||
err := s.handleMessage(update.Message)
|
||||
if update.Message.Sticker != nil {
|
||||
err := s.api.SendMessage(update.FromChatID, Message{
|
||||
Text: unsupportedMessageReply,
|
||||
UseMarkdown: true,
|
||||
})
|
||||
if err != nil {
|
||||
s.errorsChan <- err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
notificationText := newMessageNotification + "\n\n" + update.Message.Text
|
||||
err := s.api.SendMessageToOwner(Message{
|
||||
Text: notificationText,
|
||||
Image: update.Message.Image,
|
||||
Video: update.Message.Video,
|
||||
})
|
||||
if err != nil {
|
||||
s.errorsChan <- err
|
||||
}
|
||||
|
||||
err = s.pingClient(update.FromChatID)
|
||||
err = s.api.SendMessage(update.FromChatID, Message{
|
||||
Text: messageSentReply,
|
||||
UseMarkdown: true,
|
||||
})
|
||||
if err != nil {
|
||||
s.errorsChan <- err
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (s *anonymousMessagesService) pingClient(chatID int64) error {
|
||||
return s.api.SendMessage(chatID, Message{
|
||||
Text: messageSentReply,
|
||||
UseMarkdown: true,
|
||||
})
|
||||
}
|
||||
|
||||
func (s *anonymousMessagesService) handleMessage(message Message) error {
|
||||
msgText := newMessageNotification + "\n\n" + message.Text
|
||||
return s.api.SendMessageToOwner(Message{
|
||||
Text: msgText,
|
||||
Image: message.Image,
|
||||
Video: message.Video,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ type Message struct {
|
||||
UseMarkdown bool
|
||||
Image *Image
|
||||
Video *Video
|
||||
Sticker *Sticker
|
||||
}
|
||||
|
||||
type Image struct {
|
||||
@@ -30,6 +31,11 @@ type Video struct {
|
||||
FileID string
|
||||
}
|
||||
|
||||
type Sticker struct {
|
||||
FileID string
|
||||
Emoji string
|
||||
}
|
||||
|
||||
type Command int
|
||||
|
||||
const (
|
||||
|
||||
@@ -76,9 +76,10 @@ func (api *botAPI) hydrateMessage(msg *tgbotapi.Message) app.Message {
|
||||
}
|
||||
|
||||
return app.Message{
|
||||
Text: text,
|
||||
Image: api.hydrateImage(msg.Photo),
|
||||
Video: api.hydrateVideo(msg.Video),
|
||||
Text: text,
|
||||
Image: api.hydrateImage(msg.Photo),
|
||||
Video: api.hydrateVideo(msg.Video),
|
||||
Sticker: api.hydrateSticker(msg.Sticker),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +160,17 @@ func (api *botAPI) hydrateVideo(video *tgbotapi.Video) *app.Video {
|
||||
}
|
||||
}
|
||||
|
||||
func (api *botAPI) hydrateSticker(sticker *tgbotapi.Sticker) *app.Sticker {
|
||||
if sticker == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &app.Sticker{
|
||||
FileID: sticker.FileID,
|
||||
Emoji: sticker.Emoji,
|
||||
}
|
||||
}
|
||||
|
||||
func (api *botAPI) preparePhotos(message app.Message) []interface{} {
|
||||
photo := tgbotapi.NewInputMediaPhoto(tgbotapi.FileID(message.Image.FileID))
|
||||
photo.Caption = message.Text
|
||||
|
||||
Reference in New Issue
Block a user