2024-10-15 10:50:56 +03:00
---
2024-10-15 10:16:04 +03:00
sidebar_position: 3
2025-05-05 10:07:34 +03:00
description: "Create invitation link" and other functions to work with Telegram in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
2025-05-05 09:49:19 +03:00
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, Telegram]
2024-10-15 10:16:04 +03:00
---
2024-10-15 10:50:56 +03:00
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
2024-10-15 10:16:04 +03:00
# 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`
2024-10-15 15:15:47 +03:00
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| Token | --token | String | ✔ | Bot token |
| ChatID | --chat | String, Number | ✔ | Target chat ID or ChatID*TopicID |
| Title | --title | String | ✖ | Invitation title |
| ExpirationDate | --expire | Date | ✖ | Link expiration date (permanent if not specified) |
| UserLimit | --limit | Number | ✖ | User limit (infinite if not specified) |
2024-10-15 10:16:04 +03:00
Returns: Map Of KeyAndValue - serialized JSON response from Telegram
<br/>
:::tip
2024-11-21 13:27:18 +03:00
Method at API documentation: [createChatInviteLink](https://core.telegram.org/bots/api#createchatinvitelink)
2024-10-15 10:16:04 +03:00
:::
<br/>
2024-12-16 19:38:57 +03:00
2024-10-15 21:15:56 +03:00
```bsl title="1C:Enterprise/OneScript code example"
2024-10-15 10:16:04 +03:00
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);
```
2024-10-20 22:36:03 +03:00
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
oint telegram CreateInvitationLink \
2024-10-22 08:59:24 +03:00
--token "***" \
--chat "@testsichee" \
2025-05-01 20:09:27 +03:00
--expire "2025-05-02T15:46:10.9476699" \
--title "Link 01.05.2025 15:46:10" \
2024-10-22 08:59:24 +03:00
--limit 200
2024-10-20 22:36:03 +03:00
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
oint telegram CreateInvitationLink ^
2024-10-22 08:59:24 +03:00
--token "***" ^
--chat "@testsichee" ^
2025-05-01 20:09:27 +03:00
--expire "2025-05-02T15:46:10.9476699" ^
--title "Link 01.05.2025 15:46:10" ^
2024-10-22 08:59:24 +03:00
--limit 200
2024-10-20 22:36:03 +03:00
```
</TabItem>
</Tabs>
2024-10-15 10:16:04 +03:00
```json title="Result"
{
"ok": true,
"result": {
"invite_link": "https://t.me/+hUgH4yjb_7wyZDBi",
"name": "Link 09.10.2024 8:58:10",
"creator": {
"id": 6129457865,
"is_bot": true,
"first_name": "Бот Виталий",
"username": "sicheebot"
},
"expire_date": 1728547090,
"member_limit": 200,
"creates_join_request": false,
"is_primary": false,
"is_revoked": false
}
}
```