2019-05-25 20:40:06 +00:00
|
|
|
#--depends-on commands
|
|
|
|
#--depends-on permissions
|
|
|
|
|
2018-10-03 12:22:37 +00:00
|
|
|
from src import EventManager, ModuleManager, utils
|
2016-03-29 11:56:58 +00:00
|
|
|
|
2018-09-26 17:27:17 +00:00
|
|
|
class Module(ModuleManager.BaseModule):
|
2019-04-15 15:53:52 +00:00
|
|
|
def _execute(self, server):
|
|
|
|
commands = server.get_setting("perform", [])
|
2016-03-29 11:56:58 +00:00
|
|
|
for i, command in enumerate(commands):
|
|
|
|
command = command.split("%%")
|
|
|
|
for j, part in enumerate(command[:]):
|
2019-04-15 15:53:52 +00:00
|
|
|
command[j] = part.replace("%nick%", server.nickname)
|
2016-03-29 11:56:58 +00:00
|
|
|
command = "%".join(command)
|
2019-04-16 12:47:06 +00:00
|
|
|
server.send_raw(command)
|
2019-04-15 15:53:52 +00:00
|
|
|
|
|
|
|
@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"])
|