Add /link command to retrieve chat invite link

This commit is contained in:
Bohdan Horbeshko 2022-01-31 22:14:06 -05:00
parent bd281385c3
commit 86b736ec0d

View file

@ -44,6 +44,7 @@ var chatCommands = map[string]command{
"block": command{"", "blacklist current user"}, "block": command{"", "blacklist current user"},
"unblock": command{"", "unblacklist current user"}, "unblock": command{"", "unblacklist current user"},
"invite": command{"id or @username", "add user to current chat"}, "invite": command{"id or @username", "add user to current chat"},
"link": command{"", "get invite link for current chat"},
"kick": command{"id or @username", "remove user to current chat"}, "kick": command{"id or @username", "remove user to current chat"},
"ban": command{"id or @username [hours]", "restrict @username from current chat for [hours] or forever"}, "ban": command{"id or @username [hours]", "restrict @username from current chat for [hours] or forever"},
"leave": command{"", "leave current chat"}, "leave": command{"", "leave current chat"},
@ -536,6 +537,15 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
if err != nil { if err != nil {
return err.Error(), true return err.Error(), true
} }
// get link to current chat
case "link":
link, err := c.client.CreateChatInviteLink(&client.CreateChatInviteLinkRequest{
ChatId: chatID,
})
if err != nil {
return err.Error(), true
}
return link.InviteLink, true
// kick @username from current group chat // kick @username from current group chat
case "kick": case "kick":
if len(args) < 1 { if len(args) < 1 {