29 lines
921 B
Go
29 lines
921 B
Go
|
package telegram
|
||
|
|
||
|
import (
|
||
|
json "github.com/pquerna/ffjson/ffjson"
|
||
|
http "github.com/valyala/fasthttp"
|
||
|
)
|
||
|
|
||
|
// ExportChatInviteLink export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns exported invite link as String on success.
|
||
|
func (bot *Bot) ExportChatInviteLink(chat interface{}) (string, error) {
|
||
|
var args http.Args
|
||
|
switch id := chatID.(type) {
|
||
|
case int64: // Unique identifier for the target chat...
|
||
|
args.Add("chat_id", strconv.FormatInt(id, 10))
|
||
|
case string: // ...or username of the target supergroup or channel (in the format @username)
|
||
|
args.Add("chat_id", id)
|
||
|
default:
|
||
|
return nil, errors.New(errorInt64OrString)
|
||
|
}
|
||
|
|
||
|
resp, err := bot.post("exportChatInviteLink", &args)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
var data string
|
||
|
err = json.Unmarshal(*resp.Result, &data)
|
||
|
return data, err
|
||
|
}
|