python - “ValueError:找不到 PeerChannel 的输入实体”与 Bot
问题描述
对于我的生活,我无法弄清楚这一点。我创建了一个新的 Telegram Bot 并创建了一个新频道,我在其中将我的 bot 添加为管理员。
在阅读了 100 次文档后,我试图以某种方式“看到”实体,但是:
- 机器人不允许使用 get_dialogs()
- 机器人不允许 client.get_entity('')
不知道还能做什么……</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)
任何帮助、领导或想法表示赞赏!
解决方案
好的,所以,不确定是什么导致了这个问题的解决,但我做到了:
- 正如@Lonami 建议的那样,在@BotFather 中禁用组隐私模式
- 在群组中发送其他消息
- 删除并重新将机器人添加到组
我仍然有问题,但是在清除会话后,它现在可以正常工作了!
感谢@Lonami 的帮助!
推荐阅读
- php - PHP,Laravel 8 后端
- typescript - 在类之间的共享函数中输入 `this` 参数
- linux - 在 unix 上列出文件以及文件格式(unix 或 dos)
- java - 如何动态处理两个布局android
- javascript - 如何打开 .eml 文件而不是使用 javascript 下载
- c# - Collection DropdownList 在渲染视图时失去其价值 - Asp.net MVC
- oracle - SET_ROWID_THRESHOLD - ORA-29971
- flutter - Flutter Syncfusion 范围指针 SweepGradient 渐变颜色
- java - 在使用 this 作为形式参数的情况下,无法在实际参数中传递对象的引用变量
- python - 由于来自另一个 pandas 列的值,从作为 datetime 列的时间差(以分钟为单位)