aboutsummaryrefslogtreecommitdiff
path: root/telegram/handlers.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-03-12 20:25:53 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-03-12 20:25:53 +0300
commit022a12ce3174ebc53ad7be712fd37077145aaffc (patch)
tree8d99a186b4f621c2abcb63b6b61ed24be7ac86e8 /telegram/handlers.go
parentc6556eb6b86d4267bb35b7a27c34a0046668e3b9 (diff)
Add /forward command
Diffstat (limited to 'telegram/handlers.go')
-rw-r--r--telegram/handlers.go50
1 files changed, 1 insertions, 49 deletions
diff --git a/telegram/handlers.go b/telegram/handlers.go
index a4fa39f..45f10fd 100644
--- a/telegram/handlers.go
+++ b/telegram/handlers.go
@@ -192,55 +192,7 @@ func (c *Client) updateNewMessage(update *client.UpdateNewMessage) {
"chat_id": chatId,
}).Warn("New message from chat")
- var text string
- content := update.Message.Content
- if content != nil && content.MessageContentType() == client.TypeMessageChatChangePhoto {
- chat, err := c.client.GetChat(&client.GetChatRequest{
- ChatId: chatId,
- })
- if err == nil {
- c.cache.SetChat(chatId, chat)
- go c.ProcessStatusUpdate(chatId, "", "", gateway.SPImmed(true))
- text = "<Chat photo has changed>"
- }
- } else {
- text = c.messageToText(update.Message, false)
- file := c.contentToFile(content)
-
- // download file (if one)
- if file != nil {
- newFile, err := c.DownloadFile(file.Id, 1, true)
- if err == nil {
- file = newFile
- }
- }
- // OTR support (I do not know why would you need it, seriously)
- if !(strings.HasPrefix(text, "?OTR") || c.Session.RawMessages) {
- var prefix strings.Builder
- prefix.WriteString(c.messageToPrefix(update.Message, c.formatFile(file)))
- if text != "" {
- // \n if it is groupchat and message is not empty
- if chatId < 0 {
- prefix.WriteString("\n")
- } else if chatId > 0 {
- prefix.WriteString(" | ")
- }
-
- prefix.WriteString(text)
- }
-
- text = prefix.String()
- }
- }
-
- // mark message as read
- c.client.ViewMessages(&client.ViewMessagesRequest{
- ChatId: chatId,
- MessageIds: []int64{update.Message.Id},
- ForceRead: true,
- })
- // forward message to XMPP
- gateway.SendMessage(c.jid, strconv.FormatInt(chatId, 10), text, c.xmpp)
+ c.ProcessIncomingMessage(chatId, update.Message)
}()
}