首页 > 解决方案 > “ValueError:找不到 PeerChannel 的输入实体”与 Bot

问题描述

对于我的生活,我无法弄清楚这一点。我创建了一个新的 Telegram Bot 并创建了一个新频道,我在其中将我的 bot 添加为管理员。

在阅读了 100 次文档后,我试图以某种方式“看到”实体,但是:

不知道还能做什么……</p>

我确实在频道中发布了一些消息。

我的代码看起来像:

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)

任何帮助、领导或想法表示赞赏!

标签: pythonbotstelegramtelethon

解决方案


好的,所以,不确定是什么导致了这个问题的解决,但我做到了:

  • 正如@Lonami 建议的那样,在@BotFather 中禁用组隐私模式
  • 在群组中发送其他消息
  • 删除并重新将机器人添加到组

我仍然有问题,但是在清除会话后,它现在可以正常工作了!

感谢@Lonami 的帮助!


推荐阅读