|
@@ -1,7 +1,7 @@
|
|
|
import importlib
|
|
|
|
|
|
import db
|
|
|
-from config import PLUGINS, ALIASES, BOTS_LOOKUP
|
|
|
+from config import PLUGINS, ALIASES, RESPONSES, BOTS_LOOKUP
|
|
|
from command_system import RollbotResponse, RollbotFailure
|
|
|
|
|
|
|
|
@@ -40,16 +40,20 @@ class Rollbot:
|
|
|
self.logger.warn(f"Tried to run non-command message {message.message_id}")
|
|
|
return
|
|
|
|
|
|
- if message.command in ALIASES:
|
|
|
- plugin = self.commands.get(ALIASES[message.command], None)
|
|
|
- else:
|
|
|
- plugin = self.commands.get(message.command, None)
|
|
|
+ # if this command is aliased, resolve that first, otherwise use the literal command
|
|
|
+ cmd = ALIASES.get(message.command, message.command)
|
|
|
+
|
|
|
+ if cmd in RESPONSES:
|
|
|
+ return RollbotResponse(message, txt=RESPONSES[cmd])
|
|
|
+
|
|
|
+ plugin = self.commands.get(cmd, None)
|
|
|
|
|
|
if plugin is None:
|
|
|
- response = RollbotResponse(message, failure=RollbotFailure.INVALID_COMMAND)
|
|
|
- else:
|
|
|
- with db.session_scope() as session:
|
|
|
- response = plugin.on_command(session, message)
|
|
|
+ self.logger.warn(f"Message {message.message_id} had a command {message.command} (resolved to {cmd}) that could not be run.")
|
|
|
+ return RollbotResponse(message, failure=RollbotFailure.INVALID_COMMAND)
|
|
|
+
|
|
|
+ with db.session_scope() as session:
|
|
|
+ response = plugin.on_command(session, message)
|
|
|
|
|
|
if not response.is_success:
|
|
|
self.logger.warn(f"Message {message.message_id} caused failure")
|