aboutsummaryrefslogtreecommitdiff
path: root/telegram/commands.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2024-02-18 10:48:02 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2024-02-18 10:48:02 +0300
commit0b1cbda1cc20361b90846b6e8534e016288c301f (patch)
tree14455753c1627b18be5c1ea5834c4c0fdf315df1 /telegram/commands.go
parent9b5fee88262f22ad14acf621e992167966af278a (diff)
Show member dropdowns in chat administration forms
Diffstat (limited to 'telegram/commands.go')
-rw-r--r--telegram/commands.go26
1 files changed, 7 insertions, 19 deletions
diff --git a/telegram/commands.go b/telegram/commands.go
index a01a80e..3c899ed 100644
--- a/telegram/commands.go
+++ b/telegram/commands.go
@@ -70,6 +70,7 @@ var transportCommands = map[string]command{
var notForGroups = []ChatType{ChatTypeBasicGroup, ChatTypeSupergroup, ChatTypeChannel}
var notForPM = []ChatType{ChatTypePrivate, ChatTypeSecret}
+var notForPMAndBasic = []ChatType{ChatTypePrivate, ChatTypeSecret, ChatTypeBasicGroup}
var onlyForSecret = []ChatType{ChatTypePrivate, ChatTypeBasicGroup, ChatTypeSupergroup, ChatTypeChannel}
var chatCommands = map[string]command{
@@ -93,8 +94,8 @@ var chatCommands = map[string]command{
"invite": command{1, []string{"id or @username"}, "add user to current chat", &notForPM},
"link": command{0, []string{}, "get invite link for current chat", &notForPM},
"kick": command{1, []string{"id or @username"}, "remove user from current chat", &notForPM},
- "mute": command{1, []string{"id or @username", "hours"}, "mute user in current chat", &notForPM},
- "unmute": command{1, []string{"id or @username"}, "unrestrict user from current chat", &notForPM},
+ "mute": command{1, []string{"id or @username", "hours"}, "mute user in current chat", &notForPMAndBasic},
+ "unmute": command{1, []string{"id or @username"}, "unrestrict user from current chat", &notForPMAndBasic},
"ban": command{1, []string{"id or @username", "hours"}, "restrict @username from current chat for [hours] or forever", &notForPM},
"unban": command{1, []string{"id or @username"}, "unbans @username in current chat (and devotes from admins)", &notForPM},
"promote": command{1, []string{"id or @username", "title"}, "promote user to admin in current chat", &notForPM},
@@ -1100,30 +1101,17 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
query = args[0]
}
- members, err := c.client.SearchChatMembers(&client.SearchChatMembersRequest{
- ChatId: chatID,
- Limit: 9999,
- Query: query,
- Filter: &client.ChatMembersFilterMembers{},
- })
+ members, err := c.GetChatMembers(chatID, false, query, MembersListMembers)
if err != nil {
return err.Error(), true
}
var entries []string
- for _, member := range members.Members {
- var senderId int64
- switch member.MemberId.MessageSenderType() {
- case client.TypeMessageSenderUser:
- memberUser, _ := member.MemberId.(*client.MessageSenderUser)
- senderId = memberUser.UserId
- case client.TypeMessageSenderChat:
- memberChat, _ := member.MemberId.(*client.MessageSenderChat)
- senderId = memberChat.ChatId
- }
+ for _, member := range members {
+ senderId := c.GetSenderId(member.MemberId)
entries = append(entries, fmt.Sprintf(
"%v | role: %v",
- c.formatContact(senderId),
+ c.FormatContact(senderId),
member.Status.ChatMemberStatusType(),
))
}