python - 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)
解决方案
的第一个参数client.action
是您要发送操作的聊天(“实体”),而不是操作本身。"game"
不是一个有效的实体(没有人有这个用户名):
async with client.action(event.chat_id, "game"):
await asyncio.sleep(5)
推荐阅读
- typescript - 为什么索引映射类型对于 0 深度元组和所有深度对象的行为似乎相同,但对于 > 0 深度元组则不然?
- rest - Azure Sphere 公共 API:删除设备组方法不起作用
- python - 在 Python 3 中,如何同时运行两个函数?
- css - 溢出滚动可用时
- python - 将Twitter JSON对象从一个文件/多个文件解析为python的最佳方法
- hive - 对 Hive 中的数组值列执行数值运算
- html - 在移动设备中使用浏览器时,我的网站显示不同
- rust - 使用 impl fmt::Display 将枚举转换为字符串
- javascript - 无法将行复制到另一个
- python - 用于调用 python 函数的 AWS Lambda 给出了关键错误