• <i id='I5LWl'><tr id='I5LWl'><dt id='I5LWl'><q id='I5LWl'><span id='I5LWl'><b id='I5LWl'><form id='I5LWl'><ins id='I5LWl'></ins><ul id='I5LWl'></ul><sub id='I5LWl'></sub></form><legend id='I5LWl'></legend><bdo id='I5LWl'><pre id='I5LWl'><center id='I5LWl'></center></pre></bdo></b><th id='I5LWl'></th></span></q></dt></tr></i><div id='I5LWl'><tfoot id='I5LWl'></tfoot><dl id='I5LWl'><fieldset id='I5LWl'></fieldset></dl></div>

    <small id='I5LWl'></small><noframes id='I5LWl'>

  • <legend id='I5LWl'><style id='I5LWl'><dir id='I5LWl'><q id='I5LWl'></q></dir></style></legend>

        • <bdo id='I5LWl'></bdo><ul id='I5LWl'></ul>
        <tfoot id='I5LWl'></tfoot>
      1. 不和谐机器人等待消息

        时间:2023-10-11

        <legend id='v6xQh'><style id='v6xQh'><dir id='v6xQh'><q id='v6xQh'></q></dir></style></legend>

          <small id='v6xQh'></small><noframes id='v6xQh'>

            <i id='v6xQh'><tr id='v6xQh'><dt id='v6xQh'><q id='v6xQh'><span id='v6xQh'><b id='v6xQh'><form id='v6xQh'><ins id='v6xQh'></ins><ul id='v6xQh'></ul><sub id='v6xQh'></sub></form><legend id='v6xQh'></legend><bdo id='v6xQh'><pre id='v6xQh'><center id='v6xQh'></center></pre></bdo></b><th id='v6xQh'></th></span></q></dt></tr></i><div id='v6xQh'><tfoot id='v6xQh'></tfoot><dl id='v6xQh'><fieldset id='v6xQh'></fieldset></dl></div>
            <tfoot id='v6xQh'></tfoot>

                  <tbody id='v6xQh'></tbody>

                  <bdo id='v6xQh'></bdo><ul id='v6xQh'></ul>
                • 本文介绍了不和谐机器人等待消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  因此,正如标题所示,我正在尝试让我的机器人响应某个消息.因此,在用户发送图像后,它会回复赞美,然后如果用户回复该消息并回复谢谢"之类的消息,机器人将继续回复不同的消息,但我正在尝试使用 if 语句使其响应多个版本的谢谢".这是到目前为止的代码:

                  So as the title suggests I'm trying to make my bot respond to a certain message. So after a user sends an image, it'll respond with a compliment, then if the user RESPONDS TO THAT MESSAGE with a message such as "thanks" the bot will then go on to respond with a different message, but I'm trying to make it respond to multiple versions of "thanks" using if statements. This is the code so far:

                  if '.png' in message.content or '.jpg' in message.content or '.jpeg' in message.content:
                              await bot.send_message(message.channel, "woah, very nice!")
                              msg = await bot.wait_for_message(author=message.author)
                              if msg:
                                  if msg.content == 'thanks':
                                      print("test") 
                                      await bot.send_message(message.channel, "hey, gotta compliment nice images right?")
                  

                  我不确定我这样做是否正确,python shell 不打印测试并且机器人在服务器中没有响应.

                  i'm not sure if I'm doing this right, the python shell doesn't print test and the the bot doesn't respond in the server.

                  推荐答案

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

                  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?")
                  

                  这篇关于不和谐机器人等待消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  1. <tfoot id='WBqU5'></tfoot>
                    • <legend id='WBqU5'><style id='WBqU5'><dir id='WBqU5'><q id='WBqU5'></q></dir></style></legend>

                      <small id='WBqU5'></small><noframes id='WBqU5'>

                        • <bdo id='WBqU5'></bdo><ul id='WBqU5'></ul>
                          <i id='WBqU5'><tr id='WBqU5'><dt id='WBqU5'><q id='WBqU5'><span id='WBqU5'><b id='WBqU5'><form id='WBqU5'><ins id='WBqU5'></ins><ul id='WBqU5'></ul><sub id='WBqU5'></sub></form><legend id='WBqU5'></legend><bdo id='WBqU5'><pre id='WBqU5'><center id='WBqU5'></center></pre></bdo></b><th id='WBqU5'></th></span></q></dt></tr></i><div id='WBqU5'><tfoot id='WBqU5'></tfoot><dl id='WBqU5'><fieldset id='WBqU5'></fieldset></dl></div>

                            <tbody id='WBqU5'></tbody>