tucnak / telebot

Telebot is a Telegram bot framework in Go.
MIT License
4.04k stars 469 forks source link

Getting group list #646

Closed rydjnet closed 9 months ago

rydjnet commented 9 months ago

I couldn't find any way to extract ChatId that my bot was added to before launching the application. Is this just something that hasn't been implemented yet?

schnz commented 9 months ago

I don't know whether I interpret your question correctly. In general, you are limited with what the Telegram Bot API provides (obviously). The API doesn't provide a method that returns a list of chat ids to which your bot was added in the past. If you need that, you have to keep track of that by yourself. I believe there is no event being sent to the bot when he is invited to a channel/group/chat. But as soon as he receives a message, you can extract the chat_id. Positive chat_ids are private chats (i.e. chat_id is equal to user Id) , negative ids represent groups.