aboutsummaryrefslogtreecommitdiff
path: root/telegram/utils.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2023-06-03 07:20:03 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2023-06-03 07:20:03 +0300
commit9a84e9a8b6b7a6f953301e54f19cdf4be73592e1 (patch)
tree33e96558211827f696868815222e2d36abbd8fcb /telegram/utils.go
parent8663a29e157aae6e68cc880a86b3a666da37bfc9 (diff)
Store message ids in Badger DB
Diffstat (limited to 'telegram/utils.go')
-rw-r--r--telegram/utils.go9
1 files changed, 7 insertions, 2 deletions
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 {