Migrate back to the upstream go-tdlib
This commit is contained in:
parent
0b79d6feb1
commit
6eb0e5f15f
3
go.mod
3
go.mod
|
@ -8,10 +8,9 @@ require (
|
||||||
github.com/santhosh-tekuri/jsonschema v1.2.4
|
github.com/santhosh-tekuri/jsonschema v1.2.4
|
||||||
github.com/sirupsen/logrus v1.4.2
|
github.com/sirupsen/logrus v1.4.2
|
||||||
github.com/soheilhy/args v0.0.0-20150720134047-6bcf4c78e87e
|
github.com/soheilhy/args v0.0.0-20150720134047-6bcf4c78e87e
|
||||||
github.com/godcong/go-tdlib v0.1.0
|
github.com/zelenin/go-tdlib v0.5.2
|
||||||
gopkg.in/yaml.v2 v2.2.4
|
gopkg.in/yaml.v2 v2.2.4
|
||||||
gosrc.io/xmpp v0.5.2-0.20211214110136-5f99e1cd06e1
|
gosrc.io/xmpp v0.5.2-0.20211214110136-5f99e1cd06e1
|
||||||
)
|
)
|
||||||
|
|
||||||
replace gosrc.io/xmpp => github.com/bodqhrohro/go-xmpp v0.2.1-0.20211218153313-a8aadd78b65b
|
replace gosrc.io/xmpp => github.com/bodqhrohro/go-xmpp v0.2.1-0.20211218153313-a8aadd78b65b
|
||||||
replace github.com/godcong/go-tdlib => github.com/bodqhrohro/go-tdlib v0.4.4-0.20211229000346-ee6018be8ec0
|
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -90,6 +90,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
|
||||||
github.com/twitchyliquid64/golang-asm v0.0.0-20190126203739-365674df15fc/go.mod h1:NoCfSFWosfqMqmmD7hApkirIK9ozpHjxRnRxs1l413A=
|
github.com/twitchyliquid64/golang-asm v0.0.0-20190126203739-365674df15fc/go.mod h1:NoCfSFWosfqMqmmD7hApkirIK9ozpHjxRnRxs1l413A=
|
||||||
github.com/zelenin/go-tdlib v0.1.0 h1:Qq+FGE0/EWdsRB6m26ULDndu2DtW558aFXNzi0Y/FqQ=
|
github.com/zelenin/go-tdlib v0.1.0 h1:Qq+FGE0/EWdsRB6m26ULDndu2DtW558aFXNzi0Y/FqQ=
|
||||||
github.com/zelenin/go-tdlib v0.1.0/go.mod h1:Xs8fXbk5n7VaPyrSs9DP7QYoBScWYsjX+lUcWmx1DIU=
|
github.com/zelenin/go-tdlib v0.1.0/go.mod h1:Xs8fXbk5n7VaPyrSs9DP7QYoBScWYsjX+lUcWmx1DIU=
|
||||||
|
github.com/zelenin/go-tdlib v0.5.2 h1:inEATEM0Pz6/HBI3wTlhd+brDHpmoXGgwdSb8/V6GiA=
|
||||||
|
github.com/zelenin/go-tdlib v0.5.2/go.mod h1:Xs8fXbk5n7VaPyrSs9DP7QYoBScWYsjX+lUcWmx1DIU=
|
||||||
go.coder.com/go-tools v0.0.0-20190317003359-0c6a35b74a16/go.mod h1:iKV5yK9t+J5nG9O3uF6KYdPEz3dyfMyB15MN1rbQ8Qw=
|
go.coder.com/go-tools v0.0.0-20190317003359-0c6a35b74a16/go.mod h1:iKV5yK9t+J5nG9O3uF6KYdPEz3dyfMyB15MN1rbQ8Qw=
|
||||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||||
|
|
2
telegram/cache/cache.go
vendored
2
telegram/cache/cache.go
vendored
|
@ -3,7 +3,7 @@ package cache
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/godcong/go-tdlib/client"
|
"github.com/zelenin/go-tdlib/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Status stores formatted data for XMPP presence
|
// Status stores formatted data for XMPP presence
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"dev.narayana.im/narayana/telegabber/persistence"
|
"dev.narayana.im/narayana/telegabber/persistence"
|
||||||
"dev.narayana.im/narayana/telegabber/telegram/cache"
|
"dev.narayana.im/narayana/telegabber/telegram/cache"
|
||||||
|
|
||||||
"github.com/godcong/go-tdlib/client"
|
"github.com/zelenin/go-tdlib/client"
|
||||||
"gosrc.io/xmpp"
|
"gosrc.io/xmpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ func NewClient(conf config.TelegramConfig, jid string, component *xmpp.Component
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
apiID, err := strconv.Atoi(conf.Tdlib.Client.APIID)
|
apiID, err := strconv.ParseInt(conf.Tdlib.Client.APIID, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &Client{}, errors.Wrap(err, "Wrong api_id")
|
return &Client{}, errors.Wrap(err, "Wrong api_id")
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ func NewClient(conf config.TelegramConfig, jid string, component *xmpp.Component
|
||||||
UseMessageDatabase: true,
|
UseMessageDatabase: true,
|
||||||
UseSecretChats: conf.Tdlib.Client.UseSecretChats,
|
UseSecretChats: conf.Tdlib.Client.UseSecretChats,
|
||||||
|
|
||||||
ApiID: int64(apiID),
|
ApiId: int32(apiID),
|
||||||
ApiHash: conf.Tdlib.Client.APIHash,
|
ApiHash: conf.Tdlib.Client.APIHash,
|
||||||
|
|
||||||
SystemLanguageCode: "en",
|
SystemLanguageCode: "en",
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"dev.narayana.im/narayana/telegabber/xmpp/gateway"
|
"dev.narayana.im/narayana/telegabber/xmpp/gateway"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/godcong/go-tdlib/client"
|
"github.com/zelenin/go-tdlib/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
const notEnoughArguments string = "Not enough arguments"
|
const notEnoughArguments string = "Not enough arguments"
|
||||||
|
@ -163,7 +163,7 @@ func (c *Client) usernameOrIDToID(username string) (int64, error) {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
userID = chat.ID
|
userID = chat.Id
|
||||||
if userID <= 0 {
|
if userID <= 0 {
|
||||||
return 0, errors.New("Not a user")
|
return 0, errors.New("Not a user")
|
||||||
}
|
}
|
||||||
|
@ -363,7 +363,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
limit = 1
|
limit = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
messages, err := c.getLastMessages(chatID, "", c.me.ID, limit)
|
messages, err := c.getLastMessages(chatID, "", c.me.Id, limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error(), true
|
return err.Error(), true
|
||||||
}
|
}
|
||||||
|
@ -372,13 +372,13 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
var messageIds []int64
|
var messageIds []int64
|
||||||
for _, message := range messages.Messages {
|
for _, message := range messages.Messages {
|
||||||
if message != nil {
|
if message != nil {
|
||||||
messageIds = append(messageIds, message.ID)
|
messageIds = append(messageIds, message.Id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.client.DeleteMessages(&client.DeleteMessagesRequest{
|
_, err = c.client.DeleteMessages(&client.DeleteMessagesRequest{
|
||||||
ChatID: chatID,
|
ChatId: chatID,
|
||||||
MessageIDs: messageIds,
|
MessageIds: messageIds,
|
||||||
Revoke: true,
|
Revoke: true,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -393,7 +393,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
return "Not enough arguments", true
|
return "Not enough arguments", true
|
||||||
}
|
}
|
||||||
|
|
||||||
messages, err := c.getLastMessages(chatID, "", c.me.ID, 1)
|
messages, err := c.getLastMessages(chatID, "", c.me.Id, 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error(), true
|
return err.Error(), true
|
||||||
}
|
}
|
||||||
|
@ -410,8 +410,8 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
|
|
||||||
if content != nil {
|
if content != nil {
|
||||||
c.client.EditMessageText(&client.EditMessageTextRequest{
|
c.client.EditMessageText(&client.EditMessageTextRequest{
|
||||||
ChatID: chatID,
|
ChatId: chatID,
|
||||||
MessageID: message.ID,
|
MessageId: message.Id,
|
||||||
InputMessageContent: content,
|
InputMessageContent: content,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
@ -436,7 +436,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
gateway.SendPresence(
|
gateway.SendPresence(
|
||||||
c.xmpp,
|
c.xmpp,
|
||||||
c.jid,
|
c.jid,
|
||||||
gateway.SPFrom(strconv.FormatInt(chat.ID, 10)),
|
gateway.SPFrom(strconv.FormatInt(chat.Id, 10)),
|
||||||
gateway.SPType("subscribe"),
|
gateway.SPType("subscribe"),
|
||||||
)
|
)
|
||||||
// join https://t.me/publichat
|
// join https://t.me/publichat
|
||||||
|
@ -481,7 +481,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
// create new secret chat with current user
|
// create new secret chat with current user
|
||||||
case "secret":
|
case "secret":
|
||||||
_, err := c.client.CreateNewSecretChat(&client.CreateNewSecretChatRequest{
|
_, err := c.client.CreateNewSecretChat(&client.CreateNewSecretChatRequest{
|
||||||
UserID: chatID,
|
UserId: chatID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error(), true
|
return err.Error(), true
|
||||||
|
@ -493,7 +493,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.client.CreateNewBasicGroupChat(&client.CreateNewBasicGroupChatRequest{
|
_, err := c.client.CreateNewBasicGroupChat(&client.CreateNewBasicGroupChatRequest{
|
||||||
UserIDs: []int64{chatID},
|
UserIds: []int64{chatID},
|
||||||
Title: args[0],
|
Title: args[0],
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -502,7 +502,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
// blacklists current user
|
// blacklists current user
|
||||||
case "block":
|
case "block":
|
||||||
_, err := c.client.ToggleMessageSenderIsBlocked(&client.ToggleMessageSenderIsBlockedRequest{
|
_, err := c.client.ToggleMessageSenderIsBlocked(&client.ToggleMessageSenderIsBlockedRequest{
|
||||||
Sender: &client.MessageSenderUser{UserID: chatID},
|
SenderId: &client.MessageSenderUser{UserId: chatID},
|
||||||
IsBlocked: true,
|
IsBlocked: true,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -511,7 +511,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
// unblacklists current user
|
// unblacklists current user
|
||||||
case "unblock":
|
case "unblock":
|
||||||
_, err := c.client.ToggleMessageSenderIsBlocked(&client.ToggleMessageSenderIsBlockedRequest{
|
_, err := c.client.ToggleMessageSenderIsBlocked(&client.ToggleMessageSenderIsBlockedRequest{
|
||||||
Sender: &client.MessageSenderUser{UserID: chatID},
|
SenderId: &client.MessageSenderUser{UserId: chatID},
|
||||||
IsBlocked: false,
|
IsBlocked: false,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -529,8 +529,8 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.client.AddChatMember(&client.AddChatMemberRequest{
|
_, err = c.client.AddChatMember(&client.AddChatMemberRequest{
|
||||||
ChatID: chatID,
|
ChatId: chatID,
|
||||||
UserID: contact.ID,
|
UserId: contact.Id,
|
||||||
ForwardLimit: 100,
|
ForwardLimit: 100,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -548,8 +548,8 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
|
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
|
||||||
ChatID: chatID,
|
ChatId: chatID,
|
||||||
UserID: contact.ID,
|
MemberId: &client.MessageSenderUser{UserId: contact.Id},
|
||||||
Status: c.formatRestrict(false, 0),
|
Status: c.formatRestrict(false, 0),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -575,8 +575,8 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
|
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
|
||||||
ChatID: chatID,
|
ChatId: chatID,
|
||||||
UserID: contact.ID,
|
MemberId: &client.MessageSenderUser{UserId: contact.Id},
|
||||||
Status: c.formatRestrict(true, hours),
|
Status: c.formatRestrict(true, hours),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -585,7 +585,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
// leave current chat
|
// leave current chat
|
||||||
case "leave":
|
case "leave":
|
||||||
_, err := c.client.LeaveChat(&client.LeaveChatRequest{
|
_, err := c.client.LeaveChat(&client.LeaveChatRequest{
|
||||||
ChatID: chatID,
|
ChatId: chatID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error(), true
|
return err.Error(), true
|
||||||
|
@ -603,7 +603,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
if chatType == client.TypeChatTypeSecret {
|
if chatType == client.TypeChatTypeSecret {
|
||||||
chatTypeSecret, _ := chat.Type.(*client.ChatTypeSecret)
|
chatTypeSecret, _ := chat.Type.(*client.ChatTypeSecret)
|
||||||
_, err = c.client.CloseSecretChat(&client.CloseSecretChatRequest{
|
_, err = c.client.CloseSecretChat(&client.CloseSecretChatRequest{
|
||||||
SecretChatID: chatTypeSecret.SecretChatID,
|
SecretChatId: chatTypeSecret.SecretChatId,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error(), true
|
return err.Error(), true
|
||||||
|
@ -614,7 +614,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
// delete current chat
|
// delete current chat
|
||||||
case "delete":
|
case "delete":
|
||||||
_, err := c.client.DeleteChatHistory(&client.DeleteChatHistoryRequest{
|
_, err := c.client.DeleteChatHistory(&client.DeleteChatHistoryRequest{
|
||||||
ChatID: chatID,
|
ChatId: chatID,
|
||||||
RemoveFromChatList: true,
|
RemoveFromChatList: true,
|
||||||
Revoke: true,
|
Revoke: true,
|
||||||
})
|
})
|
||||||
|
@ -658,7 +658,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
var err error
|
var err error
|
||||||
for _ = range make([]struct{}, 2) {
|
for _ = range make([]struct{}, 2) {
|
||||||
messages, err = c.client.GetChatHistory(&client.GetChatHistoryRequest{
|
messages, err = c.client.GetChatHistory(&client.GetChatHistoryRequest{
|
||||||
ChatID: chatID,
|
ChatId: chatID,
|
||||||
Limit: limit,
|
Limit: limit,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -680,7 +680,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
members, err := c.client.SearchChatMembers(&client.SearchChatMembersRequest{
|
members, err := c.client.SearchChatMembers(&client.SearchChatMembersRequest{
|
||||||
ChatID: chatID,
|
ChatId: chatID,
|
||||||
Limit: 9999,
|
Limit: 9999,
|
||||||
Query: query,
|
Query: query,
|
||||||
Filter: &client.ChatMembersFilterMembers{},
|
Filter: &client.ChatMembersFilterMembers{},
|
||||||
|
@ -692,13 +692,13 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
var entries []string
|
var entries []string
|
||||||
for _, member := range members.Members {
|
for _, member := range members.Members {
|
||||||
var senderId int64
|
var senderId int64
|
||||||
switch member.MemberID.MessageSenderType() {
|
switch member.MemberId.MessageSenderType() {
|
||||||
case client.TypeMessageSenderUser:
|
case client.TypeMessageSenderUser:
|
||||||
memberUser, _ := member.MemberID.(*client.MessageSenderUser)
|
memberUser, _ := member.MemberId.(*client.MessageSenderUser)
|
||||||
senderId = memberUser.UserID
|
senderId = memberUser.UserId
|
||||||
case client.TypeMessageSenderChat:
|
case client.TypeMessageSenderChat:
|
||||||
memberChat, _ := member.MemberID.(*client.MessageSenderChat)
|
memberChat, _ := member.MemberId.(*client.MessageSenderChat)
|
||||||
senderId = memberChat.ChatID
|
senderId = memberChat.ChatId
|
||||||
}
|
}
|
||||||
entries = append(entries, fmt.Sprintf(
|
entries = append(entries, fmt.Sprintf(
|
||||||
"%v | role: %v",
|
"%v | role: %v",
|
||||||
|
|
|
@ -2,13 +2,12 @@ package telegram
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"math"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"dev.narayana.im/narayana/telegabber/xmpp/gateway"
|
"dev.narayana.im/narayana/telegabber/xmpp/gateway"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/godcong/go-tdlib/client"
|
"github.com/zelenin/go-tdlib/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
const chatsLimit int32 = 999
|
const chatsLimit int32 = 999
|
||||||
|
@ -135,7 +134,6 @@ func (c *Client) Connect(resource string) error {
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
_, err = c.client.GetChats(&client.GetChatsRequest{
|
_, err = c.client.GetChats(&client.GetChatsRequest{
|
||||||
OffsetOrder: client.JsonInt64(math.MaxInt64),
|
|
||||||
Limit: chatsLimit,
|
Limit: chatsLimit,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/godcong/go-tdlib/client"
|
"github.com/zelenin/go-tdlib/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Insertion is a piece of text in given position
|
// Insertion is a piece of text in given position
|
||||||
|
|
|
@ -3,7 +3,7 @@ package formatter
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/godcong/go-tdlib/client"
|
"github.com/zelenin/go-tdlib/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNoFormatting(t *testing.T) {
|
func TestNoFormatting(t *testing.T) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"dev.narayana.im/narayana/telegabber/xmpp/gateway"
|
"dev.narayana.im/narayana/telegabber/xmpp/gateway"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/godcong/go-tdlib/client"
|
"github.com/zelenin/go-tdlib/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
func uhOh() {
|
func uhOh() {
|
||||||
|
@ -119,15 +119,15 @@ func (c *Client) updateHandler() {
|
||||||
|
|
||||||
// new user discovered
|
// new user discovered
|
||||||
func (c *Client) updateUser(update *client.UpdateUser) {
|
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)
|
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
|
// user status changed
|
||||||
func (c *Client) updateUserStatus(update *client.UpdateUserStatus) {
|
func (c *Client) updateUserStatus(update *client.UpdateUserStatus) {
|
||||||
show, status := c.userStatusToText(update.Status)
|
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
|
// new chat discovered
|
||||||
|
@ -135,7 +135,7 @@ func (c *Client) updateNewChat(update *client.UpdateNewChat) {
|
||||||
go func() {
|
go func() {
|
||||||
if update.Chat != nil && update.Chat.Photo != nil && update.Chat.Photo.Small != nil {
|
if update.Chat != nil && update.Chat.Photo != nil && update.Chat.Photo.Small != nil {
|
||||||
_, err := c.client.DownloadFile(&client.DownloadFileRequest{
|
_, err := c.client.DownloadFile(&client.DownloadFileRequest{
|
||||||
FileID: update.Chat.Photo.Small.ID,
|
FileId: update.Chat.Photo.Small.Id,
|
||||||
Priority: 32,
|
Priority: 32,
|
||||||
Synchronous: false,
|
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
|
var isChannel = false
|
||||||
if update.Chat.Type.ChatTypeType() == client.TypeChatTypeSupergroup {
|
if update.Chat.Type.ChatTypeType() == client.TypeChatTypeSupergroup {
|
||||||
|
@ -156,18 +156,18 @@ func (c *Client) updateNewChat(update *client.UpdateNewChat) {
|
||||||
isChannel = typeSupergroup.IsChannel
|
isChannel = typeSupergroup.IsChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
if !(isChannel && update.Chat.LastReadInboxMessageID == 0) {
|
if !(isChannel && update.Chat.LastReadInboxMessageId == 0) {
|
||||||
gateway.SendPresence(
|
gateway.SendPresence(
|
||||||
c.xmpp,
|
c.xmpp,
|
||||||
c.jid,
|
c.jid,
|
||||||
gateway.SPFrom(strconv.FormatInt(update.Chat.ID, 10)),
|
gateway.SPFrom(strconv.FormatInt(update.Chat.Id, 10)),
|
||||||
gateway.SPType("subscribe"),
|
gateway.SPType("subscribe"),
|
||||||
gateway.SPNickname(update.Chat.Title),
|
gateway.SPNickname(update.Chat.Title),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if update.Chat.ID < 0 {
|
if update.Chat.Id < 0 {
|
||||||
c.ProcessStatusUpdate(update.Chat.ID, update.Chat.Title, "chat")
|
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) {
|
func (c *Client) updateNewMessage(update *client.UpdateNewMessage) {
|
||||||
go func() {
|
go func() {
|
||||||
// guarantee sequential message delivering per chat
|
// guarantee sequential message delivering per chat
|
||||||
lock := c.getChatMessageLock(update.Message.ChatID)
|
lock := c.getChatMessageLock(update.Message.ChatId)
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
defer lock.Unlock()
|
defer lock.Unlock()
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ func (c *Client) updateNewMessage(update *client.UpdateNewMessage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"chat_id": update.Message.ChatID,
|
"chat_id": update.Message.ChatId,
|
||||||
}).Warn("New message from chat")
|
}).Warn("New message from chat")
|
||||||
|
|
||||||
text := c.messageToText(update.Message)
|
text := c.messageToText(update.Message)
|
||||||
|
@ -197,7 +197,7 @@ func (c *Client) updateNewMessage(update *client.UpdateNewMessage) {
|
||||||
// download file(s)
|
// download file(s)
|
||||||
if file != nil && !file.Local.IsDownloadingCompleted {
|
if file != nil && !file.Local.IsDownloadingCompleted {
|
||||||
c.client.DownloadFile(&client.DownloadFileRequest{
|
c.client.DownloadFile(&client.DownloadFileRequest{
|
||||||
FileID: file.ID,
|
FileId: file.Id,
|
||||||
Priority: 10,
|
Priority: 10,
|
||||||
Synchronous: false,
|
Synchronous: false,
|
||||||
})
|
})
|
||||||
|
@ -208,9 +208,9 @@ func (c *Client) updateNewMessage(update *client.UpdateNewMessage) {
|
||||||
prefix.WriteString(c.messageToPrefix(update.Message, c.formatContent(file, filename)))
|
prefix.WriteString(c.messageToPrefix(update.Message, c.formatContent(file, filename)))
|
||||||
if text != "" {
|
if text != "" {
|
||||||
// \n if it is groupchat and message is not empty
|
// \n if it is groupchat and message is not empty
|
||||||
if update.Message.ChatID < 0 {
|
if update.Message.ChatId < 0 {
|
||||||
prefix.WriteString("\n")
|
prefix.WriteString("\n")
|
||||||
} else if update.Message.ChatID > 0 {
|
} else if update.Message.ChatId > 0 {
|
||||||
prefix.WriteString(" | ")
|
prefix.WriteString(" | ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,12 +222,12 @@ func (c *Client) updateNewMessage(update *client.UpdateNewMessage) {
|
||||||
|
|
||||||
// mark message as read
|
// mark message as read
|
||||||
c.client.ViewMessages(&client.ViewMessagesRequest{
|
c.client.ViewMessages(&client.ViewMessagesRequest{
|
||||||
ChatID: update.Message.ChatID,
|
ChatId: update.Message.ChatId,
|
||||||
MessageIDs: []int64{update.Message.ID},
|
MessageIds: []int64{update.Message.Id},
|
||||||
ForceRead: true,
|
ForceRead: true,
|
||||||
})
|
})
|
||||||
// forward message to XMPP
|
// 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
|
markupFunction := formatter.EntityToXEP0393
|
||||||
if update.NewContent.MessageContentType() == client.TypeMessageText {
|
if update.NewContent.MessageContentType() == client.TypeMessageText {
|
||||||
textContent := update.NewContent.(*client.MessageText)
|
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,
|
textContent.Text.Text,
|
||||||
formatter.SortEntities(textContent.Text.Entities),
|
formatter.SortEntities(textContent.Text.Entities),
|
||||||
markupFunction,
|
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
|
// message(s) deleted
|
||||||
func (c *Client) updateDeleteMessages(update *client.UpdateDeleteMessages) {
|
func (c *Client) updateDeleteMessages(update *client.UpdateDeleteMessages) {
|
||||||
if update.IsPermanent {
|
if update.IsPermanent {
|
||||||
text := "✗ " + strings.Join(int64SliceToStringSlice(update.MessageIDs), ",")
|
text := "✗ " + strings.Join(int64SliceToStringSlice(update.MessageIds), ",")
|
||||||
gateway.SendMessage(c.jid, strconv.FormatInt(update.ChatID, 10), text, c.xmpp)
|
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(
|
fmt.Sprintf(
|
||||||
"%s/%s%s",
|
"%s/%s%s",
|
||||||
c.content.Path,
|
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),
|
filepath.Ext(update.File.Local.Path),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,7 +19,7 @@ import (
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/soheilhy/args"
|
"github.com/soheilhy/args"
|
||||||
"github.com/godcong/go-tdlib/client"
|
"github.com/zelenin/go-tdlib/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
var errOffline = errors.New("TDlib instance is offline")
|
var errOffline = errors.New("TDlib instance is offline")
|
||||||
|
@ -43,7 +43,7 @@ func (c *Client) GetContactByUsername(username string) (*client.Chat, *client.Us
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.GetContactByID(chat.ID, chat)
|
return c.GetContactByID(chat.Id, chat)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetContactByID gets user and chat information from cache (or tries to retrieve it, if missing)
|
// GetContactByID gets user and chat information from cache (or tries to retrieve it, if missing)
|
||||||
|
@ -60,7 +60,7 @@ func (c *Client) GetContactByID(id int64, chat *client.Chat) (*client.Chat, *cli
|
||||||
user, ok = c.cache.GetUser(id)
|
user, ok = c.cache.GetUser(id)
|
||||||
if !ok && id > 0 {
|
if !ok && id > 0 {
|
||||||
user, err = c.client.GetUser(&client.GetUserRequest{
|
user, err = c.client.GetUser(&client.GetUserRequest{
|
||||||
UserID: id,
|
UserId: id,
|
||||||
})
|
})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
c.cache.SetUser(id, user)
|
c.cache.SetUser(id, user)
|
||||||
|
@ -71,7 +71,7 @@ func (c *Client) GetContactByID(id int64, chat *client.Chat) (*client.Chat, *cli
|
||||||
if !ok {
|
if !ok {
|
||||||
if chat == nil {
|
if chat == nil {
|
||||||
cacheChat, err = c.client.GetChat(&client.GetChatRequest{
|
cacheChat, err = c.client.GetChat(&client.GetChatRequest{
|
||||||
ChatID: id,
|
ChatId: id,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// error is irrelevant if the user was found successfully
|
// error is irrelevant if the user was found successfully
|
||||||
|
@ -194,11 +194,11 @@ func (c *Client) formatContact(chatID int64) string {
|
||||||
|
|
||||||
var str string
|
var str string
|
||||||
if chat != nil {
|
if chat != nil {
|
||||||
str = fmt.Sprintf("%s (%v)", chat.Title, chat.ID)
|
str = fmt.Sprintf("%s (%v)", chat.Title, chat.Id)
|
||||||
} else if user != nil {
|
} else if user != nil {
|
||||||
username := user.Username
|
username := user.Username
|
||||||
if username == "" {
|
if username == "" {
|
||||||
username = strconv.FormatInt(user.ID, 10)
|
username = strconv.FormatInt(user.Id, 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
str = fmt.Sprintf("%s %s (%v)", user.FirstName, user.LastName, username)
|
str = fmt.Sprintf("%s %s (%v)", user.FirstName, user.LastName, username)
|
||||||
|
@ -215,8 +215,8 @@ func (c *Client) formatMessage(chatID int64, messageID int64, preview bool, mess
|
||||||
var err error
|
var err error
|
||||||
if message == nil {
|
if message == nil {
|
||||||
message, err = c.client.GetMessage(&client.GetMessageRequest{
|
message, err = c.client.GetMessage(&client.GetMessageRequest{
|
||||||
ChatID: chatID,
|
ChatId: chatID,
|
||||||
MessageID: messageID,
|
MessageId: messageID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Sprintf("<error fetching message: %s>", err.Error())
|
return fmt.Sprintf("<error fetching message: %s>", err.Error())
|
||||||
|
@ -229,15 +229,15 @@ func (c *Client) formatMessage(chatID int64, messageID int64, preview bool, mess
|
||||||
|
|
||||||
var str strings.Builder
|
var str strings.Builder
|
||||||
var senderId int64
|
var senderId int64
|
||||||
switch message.Sender.MessageSenderType() {
|
switch message.SenderId.MessageSenderType() {
|
||||||
case client.TypeMessageSenderUser:
|
case client.TypeMessageSenderUser:
|
||||||
senderUser, _ := message.Sender.(*client.MessageSenderUser)
|
senderUser, _ := message.SenderId.(*client.MessageSenderUser)
|
||||||
senderId = senderUser.UserID
|
senderId = senderUser.UserId
|
||||||
case client.TypeMessageSenderChat:
|
case client.TypeMessageSenderChat:
|
||||||
senderChat, _ := message.Sender.(*client.MessageSenderChat)
|
senderChat, _ := message.SenderId.(*client.MessageSenderChat)
|
||||||
senderId = senderChat.ChatID
|
senderId = senderChat.ChatId
|
||||||
}
|
}
|
||||||
str.WriteString(fmt.Sprintf("%v | %s | ", message.ID, c.formatContact(senderId)))
|
str.WriteString(fmt.Sprintf("%v | %s | ", message.Id, c.formatContact(senderId)))
|
||||||
if !preview {
|
if !preview {
|
||||||
str.WriteString(
|
str.WriteString(
|
||||||
time.Unix(int64(message.Date), 0).
|
time.Unix(int64(message.Date), 0).
|
||||||
|
@ -275,14 +275,14 @@ func (c *Client) formatForward(fwd *client.MessageForwardInfo) string {
|
||||||
switch fwd.Origin.MessageForwardOriginType() {
|
switch fwd.Origin.MessageForwardOriginType() {
|
||||||
case client.TypeMessageForwardOriginUser:
|
case client.TypeMessageForwardOriginUser:
|
||||||
originUser := fwd.Origin.(*client.MessageForwardOriginUser)
|
originUser := fwd.Origin.(*client.MessageForwardOriginUser)
|
||||||
return c.formatContact(originUser.SenderUserID)
|
return c.formatContact(originUser.SenderUserId)
|
||||||
case client.TypeMessageForwardOriginChat:
|
case client.TypeMessageForwardOriginChat:
|
||||||
originChat := fwd.Origin.(*client.MessageForwardOriginChat)
|
originChat := fwd.Origin.(*client.MessageForwardOriginChat)
|
||||||
var signature string
|
var signature string
|
||||||
if originChat.AuthorSignature != "" {
|
if originChat.AuthorSignature != "" {
|
||||||
signature = fmt.Sprintf(" (%s)", originChat.AuthorSignature)
|
signature = fmt.Sprintf(" (%s)", originChat.AuthorSignature)
|
||||||
}
|
}
|
||||||
return c.formatContact(originChat.SenderChatID)+signature
|
return c.formatContact(originChat.SenderChatId)+signature
|
||||||
case client.TypeMessageForwardOriginHiddenUser:
|
case client.TypeMessageForwardOriginHiddenUser:
|
||||||
originUser := fwd.Origin.(*client.MessageForwardOriginHiddenUser)
|
originUser := fwd.Origin.(*client.MessageForwardOriginHiddenUser)
|
||||||
return originUser.SenderName
|
return originUser.SenderName
|
||||||
|
@ -292,7 +292,7 @@ func (c *Client) formatForward(fwd *client.MessageForwardInfo) string {
|
||||||
if channel.AuthorSignature != "" {
|
if channel.AuthorSignature != "" {
|
||||||
signature = fmt.Sprintf(" (%s)", channel.AuthorSignature)
|
signature = fmt.Sprintf(" (%s)", channel.AuthorSignature)
|
||||||
}
|
}
|
||||||
return c.formatContact(channel.ChatID)+signature
|
return c.formatContact(channel.ChatId)+signature
|
||||||
}
|
}
|
||||||
return "Unknown forward type"
|
return "Unknown forward type"
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ func (c *Client) formatContent(file *client.File, filename string) string {
|
||||||
filename,
|
filename,
|
||||||
file.Size/1024,
|
file.Size/1024,
|
||||||
c.content.Link,
|
c.content.Link,
|
||||||
fmt.Sprintf("%x", sha256.Sum256([]byte(file.Remote.ID))),
|
fmt.Sprintf("%x", sha256.Sum256([]byte(file.Remote.Id))),
|
||||||
filepath.Ext(filename),
|
filepath.Ext(filename),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -346,17 +346,17 @@ func (c *Client) messageToText(message *client.Message) string {
|
||||||
addMembers, _ := message.Content.(*client.MessageChatAddMembers)
|
addMembers, _ := message.Content.(*client.MessageChatAddMembers)
|
||||||
|
|
||||||
text := "invited "
|
text := "invited "
|
||||||
if len(addMembers.MemberUserIDs) > 0 {
|
if len(addMembers.MemberUserIds) > 0 {
|
||||||
text += c.formatContact(addMembers.MemberUserIDs[0])
|
text += c.formatContact(addMembers.MemberUserIds[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
return text
|
return text
|
||||||
case client.TypeMessageChatDeleteMember:
|
case client.TypeMessageChatDeleteMember:
|
||||||
deleteMember, _ := message.Content.(*client.MessageChatDeleteMember)
|
deleteMember, _ := message.Content.(*client.MessageChatDeleteMember)
|
||||||
return "kicked " + c.formatContact(deleteMember.UserID)
|
return "kicked " + c.formatContact(deleteMember.UserId)
|
||||||
case client.TypeMessagePinMessage:
|
case client.TypeMessagePinMessage:
|
||||||
pinMessage, _ := message.Content.(*client.MessagePinMessage)
|
pinMessage, _ := message.Content.(*client.MessagePinMessage)
|
||||||
return "pinned message: " + c.formatMessage(message.ChatID, pinMessage.MessageID, false, nil)
|
return "pinned message: " + c.formatMessage(message.ChatId, pinMessage.MessageId, false, nil)
|
||||||
case client.TypeMessageChatChangeTitle:
|
case client.TypeMessageChatChangeTitle:
|
||||||
changeTitle, _ := message.Content.(*client.MessageChatChangeTitle)
|
changeTitle, _ := message.Content.(*client.MessageChatChangeTitle)
|
||||||
return "chat title set to: " + changeTitle.Title
|
return "chat title set to: " + changeTitle.Title
|
||||||
|
@ -448,7 +448,7 @@ func (c *Client) contentToFilename(content client.MessageContent) (*client.File,
|
||||||
sizes := photo.Photo.Sizes
|
sizes := photo.Photo.Sizes
|
||||||
if len(sizes) > 1 {
|
if len(sizes) > 1 {
|
||||||
file := sizes[len(sizes)-1].Photo
|
file := sizes[len(sizes)-1].Photo
|
||||||
return file, strconv.FormatInt(file.ID, 10) + ".jpg"
|
return file, strconv.FormatInt(int64(file.Id), 10) + ".jpg"
|
||||||
}
|
}
|
||||||
return nil, ""
|
return nil, ""
|
||||||
case client.TypeMessageAudio:
|
case client.TypeMessageAudio:
|
||||||
|
@ -474,23 +474,23 @@ func (c *Client) messageToPrefix(message *client.Message, fileString string) str
|
||||||
} else {
|
} else {
|
||||||
directionChar = "⇽ "
|
directionChar = "⇽ "
|
||||||
}
|
}
|
||||||
prefix = append(prefix, directionChar+strconv.FormatInt(message.ID, 10))
|
prefix = append(prefix, directionChar+strconv.FormatInt(message.Id, 10))
|
||||||
// show sender in group chats
|
// show sender in group chats
|
||||||
if message.ChatID < 0 && message.Sender != nil {
|
if message.ChatId < 0 && message.SenderId != nil {
|
||||||
var senderId int64
|
var senderId int64
|
||||||
switch message.Sender.MessageSenderType() {
|
switch message.SenderId.MessageSenderType() {
|
||||||
case client.TypeMessageSenderUser:
|
case client.TypeMessageSenderUser:
|
||||||
senderUser, _ := message.Sender.(*client.MessageSenderUser)
|
senderUser, _ := message.SenderId.(*client.MessageSenderUser)
|
||||||
senderId = senderUser.UserID
|
senderId = senderUser.UserId
|
||||||
case client.TypeMessageSenderChat:
|
case client.TypeMessageSenderChat:
|
||||||
senderChat, _ := message.Sender.(*client.MessageSenderChat)
|
senderChat, _ := message.SenderId.(*client.MessageSenderChat)
|
||||||
senderId = senderChat.ChatID
|
senderId = senderChat.ChatId
|
||||||
}
|
}
|
||||||
prefix = append(prefix, c.formatContact(senderId))
|
prefix = append(prefix, c.formatContact(senderId))
|
||||||
}
|
}
|
||||||
// reply to
|
// reply to
|
||||||
if message.ReplyToMessageID != 0 {
|
if message.ReplyToMessageId != 0 {
|
||||||
prefix = append(prefix, "reply: "+c.formatMessage(message.ChatID, message.ReplyToMessageID, true, nil))
|
prefix = append(prefix, "reply: "+c.formatMessage(message.ChatId, message.ReplyToMessageId, true, nil))
|
||||||
}
|
}
|
||||||
if message.ForwardInfo != nil {
|
if message.ForwardInfo != nil {
|
||||||
prefix = append(prefix, "fwd: "+c.formatForward(message.ForwardInfo))
|
prefix = append(prefix, "fwd: "+c.formatForward(message.ForwardInfo))
|
||||||
|
@ -535,7 +535,7 @@ func (c *Client) ProcessOutgoingMessage(chatID int64, text string, returnJid str
|
||||||
var file *client.InputFileRemote
|
var file *client.InputFileRemote
|
||||||
if chatID != 0 && c.content.Upload != "" && strings.HasPrefix(text, c.content.Upload) {
|
if chatID != 0 && c.content.Upload != "" && strings.HasPrefix(text, c.content.Upload) {
|
||||||
file = &client.InputFileRemote{
|
file = &client.InputFileRemote{
|
||||||
ID: text,
|
Id: text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,8 +567,8 @@ func (c *Client) ProcessOutgoingMessage(chatID int64, text string, returnJid str
|
||||||
|
|
||||||
if chatID != 0 {
|
if chatID != 0 {
|
||||||
_, err := c.client.SendMessage(&client.SendMessageRequest{
|
_, err := c.client.SendMessage(&client.SendMessageRequest{
|
||||||
ChatID: chatID,
|
ChatId: chatID,
|
||||||
ReplyToMessageID: reply,
|
ReplyToMessageId: reply,
|
||||||
InputMessageContent: message,
|
InputMessageContent: message,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -628,9 +628,9 @@ func (c *Client) roster(resource string) {
|
||||||
|
|
||||||
func (c *Client) getLastMessages(id int64, query string, from int64, count int32) (*client.Messages, error) {
|
func (c *Client) getLastMessages(id int64, query string, from int64, count int32) (*client.Messages, error) {
|
||||||
return c.client.SearchChatMessages(&client.SearchChatMessagesRequest{
|
return c.client.SearchChatMessages(&client.SearchChatMessagesRequest{
|
||||||
ChatID: id,
|
ChatId: id,
|
||||||
Query: query,
|
Query: query,
|
||||||
Sender: &client.MessageSenderUser{UserID: from},
|
SenderId: &client.MessageSenderUser{UserId: from},
|
||||||
Filter: &client.SearchMessagesFilterEmpty{},
|
Filter: &client.SearchMessagesFilterEmpty{},
|
||||||
Limit: count,
|
Limit: count,
|
||||||
})
|
})
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"dev.narayana.im/narayana/telegabber/config"
|
"dev.narayana.im/narayana/telegabber/config"
|
||||||
"dev.narayana.im/narayana/telegabber/persistence"
|
"dev.narayana.im/narayana/telegabber/persistence"
|
||||||
|
|
||||||
"github.com/godcong/go-tdlib/client"
|
"github.com/zelenin/go-tdlib/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
const testTimeFormat string = "15:04 02/01/2006"
|
const testTimeFormat string = "15:04 02/01/2006"
|
||||||
|
|
Loading…
Reference in a new issue