且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

不和谐的机器人等待消息

更新时间:2023-01-18 07:37:19

我们可以编写一个函数来检查许多不同的变化,然后将该函数作为 check 参数传递给 wait_for_message

We can write a function that checks for many different variations, then pass that function to wait_for_message as our check argument.

thanks = ['thanks', 'thank you', 'thx']

def thanks_check(message):
    content = message.content.lower()
    return any(t in content for t in thanks)

@bot.event
async def on_message(message):
    content = message.content.lower()
    if '.png' in content or '.jpg' in content or '.jpeg' in content:
                await bot.send_message(message.channel, "woah, very nice!")
                print("Waiting for test")
                msg = await bot.wait_for_message(author=message.author, check=thanks_check)
                if msg:
                    print("test") 
                    await bot.send_message(message.channel, "hey, gotta compliment nice images right?")