aboutsummaryrefslogtreecommitdiff
path: root/telegram/utils.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2023-07-16 15:19:11 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2023-07-16 15:19:11 +0300
commit563cb2d624598efdd3819daef00c64079d8a20e1 (patch)
treec19d0d96bc3c68c151d627b1f65091ec081dda67 /telegram/utils.go
parente954c73bd2d881bc448b6bb2b3cb3a4ad37d0139 (diff)
Avoid webpage preview updates being sent as message edits
Diffstat (limited to 'telegram/utils.go')
-rw-r--r--telegram/utils.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/telegram/utils.go b/telegram/utils.go
index 9486349..da66189 100644
--- a/telegram/utils.go
+++ b/telegram/utils.go
@@ -24,6 +24,7 @@ import (
"github.com/zelenin/go-tdlib/client"
)
+// VCardInfo contains intermediate data to produce a vCard
type VCardInfo struct {
Fn string
Photo *client.File
@@ -34,6 +35,12 @@ type VCardInfo struct {
Info string
}
+// ChatMessageId uniquely identifies a Telegram message
+type ChatMessageId struct {
+ ChatId int64
+ MessageId int64
+}
+
var errOffline = errors.New("TDlib instance is offline")
var spaceRegex = regexp.MustCompile(`\s+`)
@@ -1384,3 +1391,29 @@ func (c *Client) getCarbonFullJids(isOutgoing bool, ignoredResource string) []st
}
return jids
}
+
+func (c *Client) addToEditQueue(chatId, messageId int64) {
+ c.locks.editQueueLock.Lock()
+ defer c.locks.editQueueLock.Unlock()
+
+ c.editQueue[ChatMessageId{
+ ChatId: chatId,
+ MessageId: messageId,
+ }] = true
+}
+
+func (c *Client) deleteFromEditQueue(chatId, messageId int64) bool {
+ c.locks.editQueueLock.Lock()
+ defer c.locks.editQueueLock.Unlock()
+
+ key := ChatMessageId{
+ ChatId: chatId,
+ MessageId: messageId,
+ }
+ _, ok := c.editQueue[key]
+ if ok {
+ delete(c.editQueue, key)
+ }
+
+ return ok
+}