【问题标题】:Discord.py bot reading bold text in messagesDiscord.py 机器人读取消息中的粗体文本
【发布时间】:2021-07-14 21:50:42
【问题描述】:

我正在尝试做一个简单的机器人。每当有人会说什么,它就会做一些事情。 除非有人使用粗体字,否则它的工作原理...

    if message.channel.id == 1111111111111111:
        if ("something someone said") in message.content.lower():
#something to do

我也尝试使用 if ("**something** someone said") in message.content.lower():,但这不起作用。

当粗体字仅在开头时有效if message.content.startswith('**something** someone said'):

endswith也一样

有人知道为什么if ("**something** someone said") in message.content.lower(): 不起作用或有任何解决方案吗?

【问题讨论】:

  • 你试过打印出粗体字吗?
  • 你能打印message.content.lower()的结果吗?

标签: python discord.py bots message bold


【解决方案1】:

您可以简单地替换消息内容中的所有* 字符

content = message.content.replace("**", "") 
if "something someone said" in content.lower():
    ...

【讨论】:

    猜你喜欢
    • 2022-08-05
    • 2019-12-23
    • 1970-01-01
    • 2021-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-16
    • 1970-01-01
    相关资源
    最近更新 更多