D
D
Demiarius2022-04-17 17:13:29
Python
Demiarius, 2022-04-17 17:13:29

How to get the number of participants in a group chat in Telegram in Python?

To get statistics on several Telegram channels, I use the following code:

import telebot
token = '123'

def get_users_in_telegram(channel):
    bot = telebot.TeleBot(token)
    print(bot.get_chat_member_count(channel))

get_users_in_telegram(channel)


When a link to a channel like "t.me/@namechannel" is taken, when passing "@namechannel" instead of "channel" everything works fine. But what if you need to find out the number of subscribers in a group chat when the link looks like: "t.me/+TdcnGfhUtRNpWVqS"?
When passing the value " +TdcnGfhUtRNpWVqS " errors are thrown.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2022-04-17
@SoreMix

In my opinion, it is impossible to work with invite links through bots. It is possible to get the chat ID through the client API, or, through some chatid bot, find out the channel ID and use it in the future, or, in your bot, throw in a similar functionality that simply returns the channel id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question