Skip to main content

Create invitation link

Creates a link for joining a closed chat

Function CreateInvitationLink(Val Token, Val ChatID, Val Title = "", Val ExpirationDate = "", Val UserLimit = 0) Export

ParameterCLI optionTypeDescription
Token--tokenStringBot token
ChatID--chatString, NumberTarget chat ID or ChatID*TopicID
Title--titleStringInvitation title
ExpirationDate--expireDateLink expiration date (permanent if not specified)
UserLimit--limitNumberUser limit (infinite if not specified)

Returns: Map Of KeyAndValue - Serialized JSON response from Telegram


Code example
  Token = "6129457865:AAFyzNYOAFbu...";
ChannelID = "@testsichee";
Day = 86400;
CurrentDate = OPI_Tools.GetCurrentDate();

Title = "Link " + String(CurrentDate);
Expiration = CurrentDate + Day;
UnixExpiration = OPI_Tools.UNIXTime(Expiration);

Result = OPI_Telegram.CreateInvitationLink(Token, ChannelID, Title, Expiration, 200);
CLI command example
    
oint telegram CreateInvitationLink --token "6129457865:AAFyzNYOAFbu..." --chat %chat% --title "Link + String(CurrentDate)" --expire %expire% --limit %limit%

Result
{
"ok": true,
"result": {
"invite_link": "https://t.me/+W-9MzjOejStiYzYy",
"name": "Link 05/30/2024 12:34:59",
"creator": {
"id": 6129457865,
"is_bot": true,
"first_name": "Vitaly The Bot",
"username": "sicheebot"
},
"expire_date": 1717155300,
"member_limit": 200,
"creates_join_request": false,
"is_primary": false,
"is_revoked": false
}
}