From 86b736ec0dda93c0a6c9e00bc90576312da4d939 Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Mon, 31 Jan 2022 22:14:06 -0500 Subject: [PATCH] Add /link command to retrieve chat invite link --- telegram/commands.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/telegram/commands.go b/telegram/commands.go index c521190..b8a9c5d 100644 --- a/telegram/commands.go +++ b/telegram/commands.go @@ -44,6 +44,7 @@ var chatCommands = map[string]command{ "block": command{"", "blacklist current user"}, "unblock": command{"", "unblacklist current user"}, "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"}, "ban": command{"id or @username [hours]", "restrict @username from current chat for [hours] or forever"}, "leave": command{"", "leave current chat"}, @@ -536,6 +537,15 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool) if err != nil { 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 case "kick": if len(args) < 1 {