S. Wasta
S. Wasta

Reputation: 638

Telethon trying to to add bot to channel or group

I'm trying to add bot to a channel but every attempts I have this error message:

telethon.errors.rpcerrorlist.BotMethodInvalidError: The API access for bot users is restricted. The method you tried to invoke cannot be executed as a bot

And my code is basically a copy-pase from documentation and this doc

and the code

from telethon.sync import TelegramClient, events, functions, types
from telethon.tl.types import PeerChat, PeerChannel


bot = TelegramClient('bot', api_id, api_hash).start(bot_token=token)

with bot:
    print(bot.get_me())
# I have this link https://telegram.me/joinchat/<HASH>
    result = bot(functions.messages.ImportChatInviteRequest(hash="<HASH>"))
    print(result)

I use @botfather and my configuration is :

I have read bot can't join to channel or group unless you are admin to add bot as admin. If it's true, why to post on docs you can do it with a invitation link? I can't join to group or channel...

Upvotes: 1

Views: 1884

Answers (1)

TheRealShadow
TheRealShadow

Reputation: 71

It's possible for user accounts. Telethon does support the Telegram bots, but this function is meant for personal account automation.

I understand the confusion, but the feature you want to use is for personal automated accounts and not for actual "bot" accounts.

In the first documentation it's also referred: ImportChatInviteRequest Only users can use this method

Upvotes: 3

Related Questions