2

我正在尝试使用电报机器人从组中获取用户。为此,我正在使用 python 的 Telethon 库。这是代码和完整的错误消息 -

from telethon import TelegramClient, events
API_ID = 123
API_HASH = '##'  
BOT_TOKEN  ="##" 
bot = TelegramClient('bot', API_ID, API_HASH)
bot.start(bot_token=BOT_TOKEN) 
async def Get_Random():
    users = await bot.get_participants(-123)
    print(users[0].first_name)
    for user in users:
        if user.username is not None:
            print(user.username)
bot.loop.run_until_complete(Get_Random())

完全错误 -

telethon.errors.rpcerrorlist.PeerIdInvalidError: An invalid Peer was used. Make sure to pass the right peer type and that the value is valid (for instance, bots cannot start conversations) (caused by GetFullChatRequest)

Bot 已经是该组的管理员。

4

1 回答 1

0

该错误本身就是解释性的。您传递给该方法的对等点的 ID 无效。

您应该确保您传递的聊天 ID 是正确的。

于 2022-03-03T15:44:52.920 回答