diff options
Diffstat (limited to 'telegram/handlers.go')
-rw-r--r-- | telegram/handlers.go | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/telegram/handlers.go b/telegram/handlers.go index b76ea23..a28d5da 100644 --- a/telegram/handlers.go +++ b/telegram/handlers.go @@ -13,7 +13,7 @@ import ( "dev.narayana.im/narayana/telegabber/xmpp/gateway" log "github.com/sirupsen/logrus" - "github.com/godcong/go-tdlib/client" + "github.com/zelenin/go-tdlib/client" ) func uhOh() { @@ -119,15 +119,15 @@ func (c *Client) updateHandler() { // new user discovered func (c *Client) updateUser(update *client.UpdateUser) { - c.cache.SetUser(update.User.ID, update.User) + c.cache.SetUser(update.User.Id, update.User) show, status := c.userStatusToText(update.User.Status) - go c.ProcessStatusUpdate(update.User.ID, status, show) + go c.ProcessStatusUpdate(update.User.Id, status, show) } // user status changed func (c *Client) updateUserStatus(update *client.UpdateUserStatus) { show, status := c.userStatusToText(update.Status) - go c.ProcessStatusUpdate(update.UserID, status, show, gateway.SPImmed(false)) + go c.ProcessStatusUpdate(update.UserId, status, show, gateway.SPImmed(false)) } // new chat discovered @@ -135,7 +135,7 @@ func (c *Client) updateNewChat(update *client.UpdateNewChat) { go func() { if update.Chat != nil && update.Chat.Photo != nil && update.Chat.Photo.Small != nil { _, err := c.client.DownloadFile(&client.DownloadFileRequest{ - FileID: update.Chat.Photo.Small.ID, + FileId: update.Chat.Photo.Small.Id, Priority: 32, Synchronous: false, }) @@ -145,7 +145,7 @@ func (c *Client) updateNewChat(update *client.UpdateNewChat) { } } - c.cache.SetChat(update.Chat.ID, update.Chat) + c.cache.SetChat(update.Chat.Id, update.Chat) var isChannel = false if update.Chat.Type.ChatTypeType() == client.TypeChatTypeSupergroup { @@ -156,18 +156,18 @@ func (c *Client) updateNewChat(update *client.UpdateNewChat) { isChannel = typeSupergroup.IsChannel } - if !(isChannel && update.Chat.LastReadInboxMessageID == 0) { + if !(isChannel && update.Chat.LastReadInboxMessageId == 0) { gateway.SendPresence( c.xmpp, c.jid, - gateway.SPFrom(strconv.FormatInt(update.Chat.ID, 10)), + gateway.SPFrom(strconv.FormatInt(update.Chat.Id, 10)), gateway.SPType("subscribe"), gateway.SPNickname(update.Chat.Title), ) } - if update.Chat.ID < 0 { - c.ProcessStatusUpdate(update.Chat.ID, update.Chat.Title, "chat") + if update.Chat.Id < 0 { + c.ProcessStatusUpdate(update.Chat.Id, update.Chat.Title, "chat") } }() } @@ -176,7 +176,7 @@ func (c *Client) updateNewChat(update *client.UpdateNewChat) { func (c *Client) updateNewMessage(update *client.UpdateNewMessage) { go func() { // guarantee sequential message delivering per chat - lock := c.getChatMessageLock(update.Message.ChatID) + lock := c.getChatMessageLock(update.Message.ChatId) lock.Lock() defer lock.Unlock() @@ -188,7 +188,7 @@ func (c *Client) updateNewMessage(update *client.UpdateNewMessage) { } log.WithFields(log.Fields{ - "chat_id": update.Message.ChatID, + "chat_id": update.Message.ChatId, }).Warn("New message from chat") text := c.messageToText(update.Message) @@ -197,7 +197,7 @@ func (c *Client) updateNewMessage(update *client.UpdateNewMessage) { // download file(s) if file != nil && !file.Local.IsDownloadingCompleted { c.client.DownloadFile(&client.DownloadFileRequest{ - FileID: file.ID, + FileId: file.Id, Priority: 10, Synchronous: false, }) @@ -208,9 +208,9 @@ func (c *Client) updateNewMessage(update *client.UpdateNewMessage) { prefix.WriteString(c.messageToPrefix(update.Message, c.formatContent(file, filename))) if text != "" { // \n if it is groupchat and message is not empty - if update.Message.ChatID < 0 { + if update.Message.ChatId < 0 { prefix.WriteString("\n") - } else if update.Message.ChatID > 0 { + } else if update.Message.ChatId > 0 { prefix.WriteString(" | ") } @@ -222,12 +222,12 @@ func (c *Client) updateNewMessage(update *client.UpdateNewMessage) { // mark message as read c.client.ViewMessages(&client.ViewMessagesRequest{ - ChatID: update.Message.ChatID, - MessageIDs: []int64{update.Message.ID}, + ChatId: update.Message.ChatId, + MessageIds: []int64{update.Message.Id}, ForceRead: true, }) // forward message to XMPP - gateway.SendMessage(c.jid, strconv.FormatInt(update.Message.ChatID, 10), text, c.xmpp) + gateway.SendMessage(c.jid, strconv.FormatInt(update.Message.ChatId, 10), text, c.xmpp) }() } @@ -236,20 +236,20 @@ func (c *Client) updateMessageContent(update *client.UpdateMessageContent) { markupFunction := formatter.EntityToXEP0393 if update.NewContent.MessageContentType() == client.TypeMessageText { textContent := update.NewContent.(*client.MessageText) - text := fmt.Sprintf("✎ %v | %s", update.MessageID, formatter.Format( + text := fmt.Sprintf("✎ %v | %s", update.MessageId, formatter.Format( textContent.Text.Text, formatter.SortEntities(textContent.Text.Entities), markupFunction, )) - gateway.SendMessage(c.jid, strconv.FormatInt(update.ChatID, 10), text, c.xmpp) + gateway.SendMessage(c.jid, strconv.FormatInt(update.ChatId, 10), text, c.xmpp) } } // message(s) deleted func (c *Client) updateDeleteMessages(update *client.UpdateDeleteMessages) { if update.IsPermanent { - text := "✗ " + strings.Join(int64SliceToStringSlice(update.MessageIDs), ",") - gateway.SendMessage(c.jid, strconv.FormatInt(update.ChatID, 10), text, c.xmpp) + text := "✗ " + strings.Join(int64SliceToStringSlice(update.MessageIds), ",") + gateway.SendMessage(c.jid, strconv.FormatInt(update.ChatId, 10), text, c.xmpp) } } @@ -265,7 +265,7 @@ func (c *Client) updateFile(update *client.UpdateFile) { fmt.Sprintf( "%s/%s%s", c.content.Path, - fmt.Sprintf("%x", sha256.Sum256([]byte(update.File.Remote.ID))), + fmt.Sprintf("%x", sha256.Sum256([]byte(update.File.Remote.Id))), filepath.Ext(update.File.Local.Path), ), ) |