How to manage invite link in private channel?
Asked Answered
G

6

6

What I did:

I developed a Telegram bot using TelegrafJS framework. This bot allow the user to subscribe to a paid channel, this channel is privated.

So after that the payment is completed, the bot send the invitation link to let the user join to the channel.

The problem

Now suppose that the paying user send the invitation link to another user (who didn't pay), the non-paying user will get the access to the paid channel as if it paid.

Before thinking of a solution, it's necessary to know the limit about the invitation links of Telegram:

  • It's not possible to add a user to a channel without invite link;
  • It's not possible to create a single-use invite link;
  • It's not possible to create a personal invite link (that only one user can use);
  • Invite links are cached on Telegram servers and become unstable if you reset them too fast (try resetting a link 2-3 times in 10 seconds using your Telegram app — you'll understand what I mean).

What I thought as solution

I thought to show the invite link behind an inline button, so the user will see CLICK HERE button for 3 seconds then this will be revoked and another link will be created. This doesn't remove the problem of access to the paying channel without pay a subscription, but it makes life for unfair users more difficult.

Possible other problem: When the user click on the link got:

Sorry, this channel doesn't seem to exist.

This means that the invite link to the channel is unstable at the moment. It usually happens after clicking Join several times in row OR if multiple users are trying to join at the same time.

Too many attempts, please try again later

It means that the user has clicked on too many invalid invite links recently. Most likely, he had a lot of messages "Sorry, this channel doesn't seem to exist" right before this one or joined too many channels/groups in a row.

Conclusion

Is there a more secure way to handle this?

Glassware answered 2/2, 2020 at 15:38 Comment(7)
if you have a database of the paid user's tg handles, can't you just kick the unauthorized users as soon a they join ?Quasimodo
@Nijeesh I thought to this, unfortunately the Telegram API doesn't support this feature yet for the channel but only for the group.Glassware
you can ban users from channels. here is the api docQuasimodo
Is there a way to handle the new users joined using webhook?Glassware
as of today that event for new_user_joined is available for groups only i think. but i think, you can write a background job to compare user list with in a specific time interval and do the actions with its result.Quasimodo
@NijeeshJoshy I don't understand why Telegram API doesn't offer a simple feature like thisGlassware
I think the bot can kick user from channel lol. core.telegram.org/bots/api#kickchatmemberMalady
U
2

Given the limitations of the Telegram API, the best option I can think of is having a unique link which redirects to your bot's invite link.

The bitly API might be something cool to look at for this.

Unfreeze answered 7/2, 2020 at 19:33 Comment(1)
Interesting solution but the paying user could share the link to others. So the problem isn't full solved...Glassware
U
2

As for now (Since March 9, 2021) there is a number of methods available to working with limited chat/channel invite links.

You can use createChatInviteLink method to create unique invite link limited to join certain users number.

Please refer to the official Telegram Bot API documentation.

Ucayali answered 3/9, 2021 at 8:4 Comment(0)
A
1

How about you generate a link with an expire time on the website where only paid users have access. When they click on the link your Server responds the invite link with a 302 redirect Response.

Example: [Join telegram] https://myserver.com/generateInviteLink?expiretime={Date.now}+10minutes

Response Http 302 location: T.me/invite/key When the request time is < expiretime, otherwise you throw an error

The endpoint generateinvitelink should be pw protected aswell. And the Key should be encrypted

I know that an User who is tracking it's http requests will be able to get to the URL but for some users it would work.

Archivist answered 26/2, 2021 at 23:6 Comment(0)
U
0

Through userbot API your bot can act as a user who is the creator (unlimited admin) of the secret channel. So, this admin can watch the channel's log of subscribers joining/leaving this channel. This log lasts for 24 hours. As soon as the invited user has joined the secret channel, the joinchat-Button can be deleted, and the joinchat URL can be revoked. ElseIf other users join this secret channel, they can be kicked.

Undercurrent answered 7/2, 2020 at 23:5 Comment(4)
Do you have an example for this? Everyone says that is not possibleGlassware
for which step do you mean?Undercurrent
I mean: could you write some code (at least a simple basic example) to manage this?Glassware
i am not a coder, but have an idea based on my user experience with bots and channels on telegramUndercurrent
R
0

You can count number of members in your private chat (channel or group), when count=count+1 create a new invite link.

Rattoon answered 23/10, 2020 at 12:48 Comment(2)
It would only work if you are sure nobody leave the group.Cecilius
Although bot can catch leave channel events to decrease counter...Thitherto
A
0

Well why not you add them personally from add member option. Ask them to open their privacy setting for a minute and add them. Keep your link private no one will know.

Articulate answered 30/3, 2021 at 17:14 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.