diff options
Diffstat (limited to 'telegram/commands.go')
-rw-r--r-- | telegram/commands.go | 26 |
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", ¬ForPM}, "link": command{0, []string{}, "get invite link for current chat", ¬ForPM}, "kick": command{1, []string{"id or @username"}, "remove user from current chat", ¬ForPM}, - "mute": command{1, []string{"id or @username", "hours"}, "mute user in current chat", ¬ForPM}, - "unmute": command{1, []string{"id or @username"}, "unrestrict user from current chat", ¬ForPM}, + "mute": command{1, []string{"id or @username", "hours"}, "mute user in current chat", ¬ForPMAndBasic}, + "unmute": command{1, []string{"id or @username"}, "unrestrict user from current chat", ¬ForPMAndBasic}, "ban": command{1, []string{"id or @username", "hours"}, "restrict @username from current chat for [hours] or forever", ¬ForPM}, "unban": command{1, []string{"id or @username"}, "unbans @username in current chat (and devotes from admins)", ¬ForPM}, "promote": command{1, []string{"id or @username", "title"}, "promote user to admin in current chat", ¬ForPM}, @@ -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(), )) } |