"ValueError: Could not find the input entity for PeerChannel" with Bot

Viewed 846

For the life of me, I can't figure out this one out. I have created a new Telegram Bot and created a new channel, in which I added my bot as an Admin.

After reading 100 times the docs, I tried to have the entity "seen" somehow but :

  • get_dialogs() is not allowed for bots
  • client.get_entity('') is not allowed for bots

Not sure what else to do…

I do have published some messages in the channel.

My code looks something like :

from telethon import TelegramClient

telethon_client = TelegramClient(
    api_id=int(config['TELETHON_API_ID']),
    api_hash=config['TELETHON_API_HASH'],
    session=config['TELETHON_SESSION']
).start(bot_token=config['TELEGRAM_BOT_TOKEN'])

with telethon_client:
   telethon_client.loop.run_until_complete(__async_get_users(chat_id))

async def __async_get_users(chat_id):
    channel = await telethon_client.get_entity(chat_id) # -100xxxxx
    tg_users = await telethon_client.get_participants(channel)

Any help, lead, or idea appreciated !

1 Answers

Ok, so, not sure what lead to the resolution of this issue but I did :

  • disable group privacy mode in @BotFather as @Lonami advised
  • Sent other messages in the group
  • Removed and re-added the bot to the group

I still had the issue, but after clearing the session, it now works OK!

Thanks @Lonami for the help!

Related