问题是,如果您说出请求的单词,但带有一个额外的字母、单词或短语,它就会忽略它。
在 pycharm 中,我创建了 3 个文件,但最重要的是随机响应,这里是随机响应的代码:
def get_response(消息:str)-> str: p_message = message.lower()
if p_message == '@Madrid':
return 'Reduce on pinging him, wait until he comes online and ask him what you wanted to ask.'
if message == '@madridddsta':
return 'Reduce on pinging him, wait until he comes online and ask him what you wanted to ask.'
if p_message == 'madridddsta#7819':
return 'Reduce on pinging him, wait until he comes online and ask him what you wanted to ask.'
if p_message == '<@949798747586584647>':
return 'Reduce on pinging him, wait until he comes online and ask him what you wanted to ask.'
if p_message == '@XTREditz':
return 'Reduce on pinging him, wait until he comes online and ask him what you wanted to ask.'
if message == '@XTREditz#6250':
return 'Reduce on pinging him, wait until he comes online and ask him what you wanted to ask.'
if p_message == '<@841488565225390080>':
return 'Reduce on pinging him, wait until he comes online and ask him what you wanted to ask.'
我什至不明白你想做什么。据我所知,您似乎正在检查一个字符串是否等于另一个字符串,而您想要检查一个字符串是否在另一个字符串中。例如:
# Instead of this ❌
if message == '@madridddsta':
# ...
# Try this! ✔️
if '@madridddsta' in message:
# ...