diff options
Diffstat (limited to 'telegram')
-rw-r--r-- | telegram/commands.go | 6 | ||||
-rw-r--r-- | telegram/utils.go | 9 |
2 files changed, 10 insertions, 5 deletions
diff --git a/telegram/commands.go b/telegram/commands.go index ec06f36..59fe1c7 100644 --- a/telegram/commands.go +++ b/telegram/commands.go @@ -498,7 +498,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool) return "Last message is empty", true } - content := c.ProcessOutgoingMessage(0, rawCmdArguments(cmdline, 0), "", 0) + content := c.ProcessOutgoingMessage(0, rawCmdArguments(cmdline, 0), "", "", 0) if content != nil { c.client.EditMessageText(&client.EditMessageTextRequest{ @@ -515,7 +515,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool) return "Not enough arguments", true } - content := c.ProcessOutgoingMessage(0, rawCmdArguments(cmdline, 0), "", 0) + content := c.ProcessOutgoingMessage(0, rawCmdArguments(cmdline, 0), "", "", 0) if content != nil { _, err := c.client.SendMessage(&client.SendMessageRequest{ @@ -594,7 +594,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool) } } - content := c.ProcessOutgoingMessage(0, rawCmdArguments(cmdline, 1), "", 0) + content := c.ProcessOutgoingMessage(0, rawCmdArguments(cmdline, 1), "", "", 0) if content != nil { _, err := c.client.SendMessage(&client.SendMessageRequest{ diff --git a/telegram/utils.go b/telegram/utils.go index 851c6c1..0a2ae1f 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -987,7 +987,7 @@ func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message) { } // ProcessOutgoingMessage executes commands or sends messages to mapped chats -func (c *Client) ProcessOutgoingMessage(chatID int64, text string, returnJid string, replyId int64) client.InputMessageContent { +func (c *Client) ProcessOutgoingMessage(chatID int64, text string, returnJid string, id string, replyId int64) client.InputMessageContent { if !c.Online() { // we're offline return nil @@ -1111,7 +1111,7 @@ func (c *Client) ProcessOutgoingMessage(chatID int64, text string, returnJid str } if chatID != 0 { - _, err := c.client.SendMessage(&client.SendMessageRequest{ + tgMessage, err := c.client.SendMessage(&client.SendMessageRequest{ ChatId: chatID, ReplyToMessageId: reply, InputMessageContent: message, @@ -1123,6 +1123,11 @@ func (c *Client) ProcessOutgoingMessage(chatID int64, text string, returnJid str fmt.Sprintf("Not sent: %s", err.Error()), c.xmpp, ) + } else { + err = gateway.IdsDB.Set(c.Session.Login, c.jid, tgMessage.ChatId, tgMessage.Id, id) + if err != nil { + log.Errorf("Failed to save ids %v/%v %v", tgMessage.ChatId, tgMessage.Id, id) + } } return nil } else { |