Open mazanur opened 2 years ago
Hi! You must provide youre code first, if you want help
But it looks like that youre use it wrong way
You must use Request method and provide tgbotapi.CreateChatInviteLinkConfig for it
Hi, that's exactly what I did.
But I want to use the Send method to create a link and return a Message, where the ChatInviteLink field will be
Works for me like so:
response, err := bot.Request(createInviteLinkConfig)
if err != nil {
return msg, err
}
var dat map[string]interface{}
json.Unmarshal(response.Result, &dat)
// just a simple demo that works
import (
"encoding/json"
"fmt"
"time"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
)
func gen_link(){
var (
chatCfg = tgbotapi.ChatConfig{ChatID: req.ChatID}
resMap map[string]interface{}
)
chatInviteLinkConfig := tgbotapi.CreateChatInviteLinkConfig{
ChatConfig: chatCfg,
Name: "invite test",
ExpireDate: int(time.Now().Add(1 * time.Minute).Unix()),
MemberLimit: 1,
CreatesJoinRequest: false,
}
response, _ := bot.Request(chatInviteLinkConfig)
err = json.Unmarshal(response.Result, &resMap)
fmt.Println("resMap:", resMap)
fmt.Println("invite_link:",resMap["invite_link"])
}
Response from telegram
{"invite_link":"https://t.me/+SEgfYrEGlSwzMjAy", "creator":{"id":1295847044,"is_bot":true,"first_name":"***","username":"*"},"member_limit":1,"creates_join_request":false,"is_primary":false,"is_revoked":false}
After Unmarshal, message has not inviteLink