python - 您如何检查特定用户是否对带有许多特定表情符号的特定消息做出反应
问题描述
我目前正在制作汽车经济机器人,我希望能够像游戏一样与机器人互动。我想对按钮使用反应,但问题是当我使用代码时,
confirm_right = await client.wait_for("reaction_add", check=react_check_right)
confirm_left = await client.wait_for("reaction_add", check=react_check_left)
它没有按预期工作,首先它等待confirm_right,然后是confirm_left。
我希望能找到一种方法让它们同时工作。
这是我的检查功能,
def check(message):
return ctx.author.id == message.author.id
def react_check_right(reaction, user):
return user == ctx.author and str(reaction.emoji) in ["➡️"]
解决方案
找到了答案
reaction, user = await client.wait_for('reaction_add', check = lambda reaction, user: reaction.emoji in ["➡️", "⬅️"])
if user == ctx.author:
if reaction.emoji == '➡️':
if car_shown < len(users[str(user.id)]['car']) - 1:
car_shown += 1
else:
car_shown = 0
```
this was basically it
推荐阅读
- c# - C#中的只读数组
- python - 在命令窗口中以彩色打印文本
- java - Java中m1和m2泛型方法的区别
- javascript - 为数组 javascript 赋值
- reactjs - 为什么扩展样式表不呈现?
- java - java如何知道lambda参数的类型?
- solr - Hybris/Solr 多词同义词在 solr admin ui 中工作,但 hybris 查询似乎是问题所在
- mysql - 为什么我的 Spring Batch Task 使用相同的 JOB_INSTANCE_ID 启动多个作业执行?
- javascript - 如何在反应 stepzilla 的某些步骤中隐藏导航按钮
- c# - 构建配置后如何更新 IOptions?