From def5c3f6c93386674489b85a2c7af19e5247413a Mon Sep 17 00:00:00 2001 From: Mikhail Markov Date: Mon, 17 Jul 2017 20:48:51 +0300 Subject: [PATCH] Add exportChatInviteLink method --- bot.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bot.go b/bot.go index 9bee899..9d2adab 100644 --- a/bot.go +++ b/bot.go @@ -834,3 +834,21 @@ func (bot *BotAPI) DeleteMessage(config DeleteMessageConfig) (APIResponse, error return bot.MakeRequest(config.method(), v) } + +// GetInviteLink get InviteLink for a chat +func (bot *BotAPI) GetInviteLink(config ChatConfig) (string, error) { + v := url.Values{} + + if config.SuperGroupUsername == "" { + v.Add("chat_id", strconv.FormatInt(config.ChatID, 10)) + } else { + v.Add("chat_id", config.SuperGroupUsername) + } + + resp, err := bot.MakeRequest("exportChatInviteLink", v) + + var inviteLink string + err = json.Unmarshal(resp.Result, &inviteLink) + + return inviteLink, err +}