0

I want to add a bot to a Telegram Group, but not via manual approach:

but via API instead, i.e., something like this:

which I had not been able to make it working. I've tried.

https://telegram.me/mybotname?startgroup=mygroupname,

or /start@mybotname within "mygroupname". Neither way get my bot added to the Telegram Group.

The reason I need to add a bot to Telegram Groups via API is that I have over a dozen of such Telegram Groups to add this new bot to.

xpt
  • 20,363
  • 37
  • 127
  • 216
  • Seems that the conclusion is -- _"impossible"_ -- I added them all manually. – xpt Aug 28 '20 at 15:35
  • yeah bot-api doesnt support that. But u can use this function in user account (not bot). – Alen Paul Varghese Aug 29 '20 at 17:49
  • @AlenPaulVarghese, that will do as well, Would you elaborate it (using which function and how) into an answer pls? – xpt Aug 29 '20 at 21:29
  • User-account is using ur account as an instance, i dont know python-telegram-bot supports it but other third party libraries like telethon, pyrogram supports it. Its like automating ur account. There are method for adding users to a channel – Alen Paul Varghese Aug 29 '20 at 22:36

1 Answers1

1

2 years old question but, that's what helped me:

Use user API (not bot API) and messages.addChatUser method.
It works not only for adding users, but also bots.
https://core.telegram.org/method/messages.addChatUser

For getting bot_id use https://api.telegram.org/bot{TOKEN}/getMe (use token from bot father)

Here is example of the code on python:

from telethon.sync import TelegramClient
from telethon.sessions import StringSession
from telethon.tl.functions.messages import AddChatUserRequest

session = StringSession("")  # You should put your string session here
client = TelegramClient(session, api_id, api_hash)

async def run():
    await client.connect()  # This assumes you have already authenticated 

    result = await client(AddChatUserRequest(
        chat_id=chat_id,
        user_id=bot_id,
        fwd_limit=43,
    ))
    print(result)  # prints the result

with client:
    client.loop.run_until_complete(run())
Alexandra
  • 36
  • 3
  • I don't have Python to verify, but I'll make an exception, just to welcome you as a new contributor, with my +25, :) – xpt Feb 13 '23 at 16:35