我正在尝试使用电报机器人从组中获取用户。为此,我正在使用 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 已经是该组的管理员。