首页 > 解决方案 > How to solve error on sending game action

问题描述

Im trying to send gaming action but i got this error :

Connot cast event to any kind of peer

This is my code :

gaming = "on"
@client.on(events.NewMessage)
def handler(event):
    global gaming
    if gaming == "on":
        async with client.action("game",event):
            await asyncio.sleep(5)

标签: pythontelethon

解决方案


的第一个参数client.action是您要发送操作的聊天(“实体”),而不是操作本身。"game"不是一个有效的实体(没有人有这个用户名):

async with client.action(event.chat_id, "game"):
    await asyncio.sleep(5)

推荐阅读