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

  1. <tfoot id='0uahK'></tfoot>
      • <bdo id='0uahK'></bdo><ul id='0uahK'></ul>
    1. <small id='0uahK'></small><noframes id='0uahK'>

      <legend id='0uahK'><style id='0uahK'><dir id='0uahK'><q id='0uahK'></q></dir></style></legend>

      如何在 discord.py 中转义 @everyone?

      时间:2023-10-10
      <legend id='v4B9K'><style id='v4B9K'><dir id='v4B9K'><q id='v4B9K'></q></dir></style></legend>

        1. <tfoot id='v4B9K'></tfoot>
            <bdo id='v4B9K'></bdo><ul id='v4B9K'></ul>

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

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

                  <tbody id='v4B9K'></tbody>
                本文介绍了如何在 discord.py 中转义 @everyone?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在 Python 中开发一个 Discord 机器人,它根据用户输入输出文本.我想避免用户让它说 @everyone(和 @here),这会标记和惹恼所有人.

                I'm developing a Discord bot in Python which outputs text based on user input. I want to avoid users getting it to say @everyone (and @here) which would tag and annoy everyone.

                我尝试使用 @everyone@everyone 相比,它不会使文本本身变成蓝色,但它仍然会触发 ping 并突出显示该行黄色.这不仅会在我使用机器人发送消息时发生,而且在我直接使用 Discord 时也会发生.

                I tried using @everyone which in contrast to @everyone does not make the text itself blue, but it still triggers a ping and highlights the line in yellow. This does not only happen when I send a message with the bot but also if I use Discord directly.

                推荐答案

                我一直使用的解决方案是插入一个 零宽度空格在@"之后.这不会改变文本外观(零宽度"),但额外的字符会阻止 ping.它具有 unicode 代码点 200b(十六进制):

                The solution I've been using is to insert a zero-width space after the '@'. This will not change the text appearance ('zero-width') but the extra character prevents the ping. It has unicode codepoint 200b (in hex):

                message_str = message_str.replace('@', '@​u200b') 
                

                更明确地说,discord.py 库本身有 escape_mentions 用于此目的:

                More explicitly, the discord.py library itself has escape_mentions for that purpose:

                message_str = discord.utils.escape_mentions(message_str)
                

                实现几乎相同:

                def escape_mentions(text):
                    return re.sub(r'@(everyone|here|[!&]?[0-9]{17,21})', '@u200b\1', text)
                

                这篇关于如何在 discord.py 中转义 @everyone?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:是否可以将某个语音频道中的用户静音,而不是 下一篇:如果用户在具有特定角色时离开服务器,则禁止

                相关文章

                最新文章

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

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

                  <tfoot id='wedqM'></tfoot>

                  1. <legend id='wedqM'><style id='wedqM'><dir id='wedqM'><q id='wedqM'></q></dir></style></legend>

                    • <bdo id='wedqM'></bdo><ul id='wedqM'></ul>