aboutsummaryrefslogtreecommitdiff
path: root/modules/perform.py
diff options
context:
space:
mode:
authorGravatar jesopo2019-04-15 16:53:52 +0100
committerGravatar jesopo2019-04-15 16:53:52 +0100
commit81e95488273afd99c25634432276ec23f8e42e4d (patch)
treea6b3a516f35f1d5784cabf2599d84ce527f7e636 /modules/perform.py
parentOnly allow 'current channel' !config logic when we're in a channel (diff)
signature
Allow adding perform.py commands through chat and add !performexecute, to
execute all perform commands post-connect
Diffstat (limited to 'modules/perform.py')
-rw-r--r--modules/perform.py34
1 files changed, 28 insertions, 6 deletions
diff --git a/modules/perform.py b/modules/perform.py
index f2de9a86..3dfe34d2 100644
--- a/modules/perform.py
+++ b/modules/perform.py
@@ -1,13 +1,35 @@
from src import EventManager, ModuleManager, utils
class Module(ModuleManager.BaseModule):
- @utils.hook("received.001", priority=EventManager.PRIORITY_URGENT)
- def on_connect(self, event):
- commands = event["server"].get_setting("perform", [])
+ def _execute(self, server):
+ commands = server.get_setting("perform", [])
for i, command in enumerate(commands):
command = command.split("%%")
for j, part in enumerate(command[:]):
- command[j] = part.replace("%nick%", event["server"
- ].nickname)
+ command[j] = part.replace("%nick%", server.nickname)
command = "%".join(command)
- event["server"].send(utils.irc.parse_line(command))
+ server.send(utils.irc.parse_line(command))
+
+ @utils.hook("received.001", priority=EventManager.PRIORITY_URGENT)
+ def on_connect(self, event):
+ self._execute(event["server"])
+
+ @utils.hook("received.command.performadd", min_args=1)
+ def perform_add(self, event):
+ """
+ :help: Add command to be executed on connect
+ :usage: <raw command>
+ :permission: perform
+ """
+ perform = event["server"].get_setting("perform", [])
+ perform.append(event["args"])
+ event["server"].set_setting("perform", perform)
+ event["stdout"].write("Added command")
+
+ @utils.hook("received.command.performexecute")
+ def perform_execute(self, event):
+ """
+ :help: Execute all saved commands
+ :permission: perform
+ """
+ self._execute(event["server"])