Spaces:
Running
Running
Fixed: on_message KeyError: rule['response']
Browse files- discord_bot.py +1 -2
discord_bot.py
CHANGED
@@ -108,7 +108,6 @@ async def on_message(message):
|
|
108 |
for rule in json_data["message"]:
|
109 |
rule_type = rule["type"]
|
110 |
content = rule["content"]
|
111 |
-
response = rule["response"]
|
112 |
|
113 |
# 根据规则类型动态调用对应的判断函数
|
114 |
if check_functions.get(rule_type, lambda c, m: False)(content, message):
|
@@ -120,7 +119,7 @@ async def on_message(message):
|
|
120 |
await message.channel.send(result)
|
121 |
# 否则发送预定义的响应消息
|
122 |
elif "response" in rule:
|
123 |
-
await message.channel.send(response)
|
124 |
|
125 |
# 确保命令系统正常工作
|
126 |
await bot.process_commands(message)
|
|
|
108 |
for rule in json_data["message"]:
|
109 |
rule_type = rule["type"]
|
110 |
content = rule["content"]
|
|
|
111 |
|
112 |
# 根据规则类型动态调用对应的判断函数
|
113 |
if check_functions.get(rule_type, lambda c, m: False)(content, message):
|
|
|
119 |
await message.channel.send(result)
|
120 |
# 否则发送预定义的响应消息
|
121 |
elif "response" in rule:
|
122 |
+
await message.channel.send(rule["response"])
|
123 |
|
124 |
# 确保命令系统正常工作
|
125 |
await bot.process_commands(message)
|