aboutsummaryrefslogtreecommitdiff
path: root/telegram/commands.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-01-17 23:45:40 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-01-17 23:45:40 +0300
commit6eb0e5f15fd9a81bbafb2189dd73b6c093b487e6 (patch)
tree802c64e7e0b2c9a349858d5ea106f983eb1cc6ea /telegram/commands.go
parent0b79d6feb1e3d2f87753a1808acbb148a346eeec (diff)
Migrate back to the upstream go-tdlib
Diffstat (limited to 'telegram/commands.go')
-rw-r--r--telegram/commands.go62
1 files changed, 31 insertions, 31 deletions
diff --git a/telegram/commands.go b/telegram/commands.go
index 9a7cf19..378c666 100644
--- a/telegram/commands.go
+++ b/telegram/commands.go
@@ -11,7 +11,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"
)
const notEnoughArguments string = "Not enough arguments"
@@ -163,7 +163,7 @@ func (c *Client) usernameOrIDToID(username string) (int64, error) {
return 0, err
}
- userID = chat.ID
+ userID = chat.Id
if userID <= 0 {
return 0, errors.New("Not a user")
}
@@ -363,7 +363,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
limit = 1
}
- messages, err := c.getLastMessages(chatID, "", c.me.ID, limit)
+ messages, err := c.getLastMessages(chatID, "", c.me.Id, limit)
if err != nil {
return err.Error(), true
}
@@ -372,13 +372,13 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
var messageIds []int64
for _, message := range messages.Messages {
if message != nil {
- messageIds = append(messageIds, message.ID)
+ messageIds = append(messageIds, message.Id)
}
}
_, err = c.client.DeleteMessages(&client.DeleteMessagesRequest{
- ChatID: chatID,
- MessageIDs: messageIds,
+ ChatId: chatID,
+ MessageIds: messageIds,
Revoke: true,
})
if err != nil {
@@ -393,7 +393,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
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 {
return err.Error(), true
}
@@ -410,8 +410,8 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
if content != nil {
c.client.EditMessageText(&client.EditMessageTextRequest{
- ChatID: chatID,
- MessageID: message.ID,
+ ChatId: chatID,
+ MessageId: message.Id,
InputMessageContent: content,
})
} else {
@@ -436,7 +436,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
gateway.SendPresence(
c.xmpp,
c.jid,
- gateway.SPFrom(strconv.FormatInt(chat.ID, 10)),
+ gateway.SPFrom(strconv.FormatInt(chat.Id, 10)),
gateway.SPType("subscribe"),
)
// 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
case "secret":
_, err := c.client.CreateNewSecretChat(&client.CreateNewSecretChatRequest{
- UserID: chatID,
+ UserId: chatID,
})
if err != nil {
return err.Error(), true
@@ -493,7 +493,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
}
_, err := c.client.CreateNewBasicGroupChat(&client.CreateNewBasicGroupChatRequest{
- UserIDs: []int64{chatID},
+ UserIds: []int64{chatID},
Title: args[0],
})
if err != nil {
@@ -502,7 +502,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
// blacklists current user
case "block":
_, err := c.client.ToggleMessageSenderIsBlocked(&client.ToggleMessageSenderIsBlockedRequest{
- Sender: &client.MessageSenderUser{UserID: chatID},
+ SenderId: &client.MessageSenderUser{UserId: chatID},
IsBlocked: true,
})
if err != nil {
@@ -511,7 +511,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
// unblacklists current user
case "unblock":
_, err := c.client.ToggleMessageSenderIsBlocked(&client.ToggleMessageSenderIsBlockedRequest{
- Sender: &client.MessageSenderUser{UserID: chatID},
+ SenderId: &client.MessageSenderUser{UserId: chatID},
IsBlocked: false,
})
if err != nil {
@@ -529,8 +529,8 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
}
_, err = c.client.AddChatMember(&client.AddChatMemberRequest{
- ChatID: chatID,
- UserID: contact.ID,
+ ChatId: chatID,
+ UserId: contact.Id,
ForwardLimit: 100,
})
if err != nil {
@@ -548,9 +548,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
}
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
- ChatID: chatID,
- UserID: contact.ID,
- Status: c.formatRestrict(false, 0),
+ ChatId: chatID,
+ MemberId: &client.MessageSenderUser{UserId: contact.Id},
+ Status: c.formatRestrict(false, 0),
})
if err != nil {
return err.Error(), true
@@ -575,8 +575,8 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
}
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
- ChatID: chatID,
- UserID: contact.ID,
+ ChatId: chatID,
+ MemberId: &client.MessageSenderUser{UserId: contact.Id},
Status: c.formatRestrict(true, hours),
})
if err != nil {
@@ -585,7 +585,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
// leave current chat
case "leave":
_, err := c.client.LeaveChat(&client.LeaveChatRequest{
- ChatID: chatID,
+ ChatId: chatID,
})
if err != nil {
return err.Error(), true
@@ -603,7 +603,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
if chatType == client.TypeChatTypeSecret {
chatTypeSecret, _ := chat.Type.(*client.ChatTypeSecret)
_, err = c.client.CloseSecretChat(&client.CloseSecretChatRequest{
- SecretChatID: chatTypeSecret.SecretChatID,
+ SecretChatId: chatTypeSecret.SecretChatId,
})
if err != nil {
return err.Error(), true
@@ -614,7 +614,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
// delete current chat
case "delete":
_, err := c.client.DeleteChatHistory(&client.DeleteChatHistoryRequest{
- ChatID: chatID,
+ ChatId: chatID,
RemoveFromChatList: true,
Revoke: true,
})
@@ -658,7 +658,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
var err error
for _ = range make([]struct{}, 2) {
messages, err = c.client.GetChatHistory(&client.GetChatHistoryRequest{
- ChatID: chatID,
+ ChatId: chatID,
Limit: limit,
})
if err != nil {
@@ -680,7 +680,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
}
members, err := c.client.SearchChatMembers(&client.SearchChatMembersRequest{
- ChatID: chatID,
+ ChatId: chatID,
Limit: 9999,
Query: query,
Filter: &client.ChatMembersFilterMembers{},
@@ -692,13 +692,13 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
var entries []string
for _, member := range members.Members {
var senderId int64
- switch member.MemberID.MessageSenderType() {
+ switch member.MemberId.MessageSenderType() {
case client.TypeMessageSenderUser:
- memberUser, _ := member.MemberID.(*client.MessageSenderUser)
- senderId = memberUser.UserID
+ memberUser, _ := member.MemberId.(*client.MessageSenderUser)
+ senderId = memberUser.UserId
case client.TypeMessageSenderChat:
- memberChat, _ := member.MemberID.(*client.MessageSenderChat)
- senderId = memberChat.ChatID
+ memberChat, _ := member.MemberId.(*client.MessageSenderChat)
+ senderId = memberChat.ChatId
}
entries = append(entries, fmt.Sprintf(
"%v | role: %v",