test
This commit is contained in:
parent
a2569cab86
commit
4dd78b6755
@ -69,37 +69,37 @@ class Commands():
|
||||
})
|
||||
return commands_list
|
||||
|
||||
def dispatch(self, bot, trigger_dict):
|
||||
def dispatch(self, trigger_dict):
|
||||
if trigger_dict["trigger_type"] == "command":
|
||||
return self.dispatch_command(bot, trigger_dict)
|
||||
return self.dispatch_command(trigger_dict)
|
||||
elif trigger_dict["trigger_type"] == "nickname_command":
|
||||
return self.dispatch_nickname_command(bot, trigger_dict)
|
||||
return self.dispatch_nickname_command(trigger_dict)
|
||||
elif trigger_dict["trigger_type"] == "action_command":
|
||||
return self.dispatch_action_command(bot, trigger_dict)
|
||||
return self.dispatch_action_command(trigger_dict)
|
||||
|
||||
def dispatch_command(self, bot, trigger_dict):
|
||||
def dispatch_command(self, trigger_dict):
|
||||
pretrigger = PreTrigger(
|
||||
bot.nick,
|
||||
self.bot.nick,
|
||||
":%s %s %s :%s%s" % (trigger_dict["trigger_hostmask"], "PRIVMSG", trigger_dict["trigger_sender"],
|
||||
trigger_dict["trigger_prefix"], trigger_dict["trigger_str"])
|
||||
)
|
||||
bot.dispatch(pretrigger)
|
||||
self.bot.dispatch(pretrigger)
|
||||
|
||||
def dispatch_nickname_command(self, bot, trigger_dict):
|
||||
def dispatch_nickname_command(self, trigger_dict):
|
||||
pretrigger = PreTrigger(
|
||||
bot.nick,
|
||||
self.bot.nick,
|
||||
":%s %s %s :%s %s" % (trigger_dict["trigger_hostmask"], "PRIVMSG", trigger_dict["trigger_sender"],
|
||||
trigger_dict["trigger_prefix"], trigger_dict["trigger_str"])
|
||||
)
|
||||
bot.dispatch(pretrigger)
|
||||
self.bot.dispatch(pretrigger)
|
||||
|
||||
def dispatch_action_command(self, bot, trigger_dict):
|
||||
def dispatch_action_command(self, trigger_dict):
|
||||
pretrigger = PreTrigger(
|
||||
bot.nick,
|
||||
self.bot.nick,
|
||||
":%s %s %s :%s%s %s%s" % (trigger_dict["trigger_hostmask"], "PRIVMSG", trigger_dict["trigger_sender"],
|
||||
"\x01", "ACTION", trigger_dict["trigger_str"], "\x01")
|
||||
)
|
||||
bot.dispatch(pretrigger)
|
||||
self.bot.dispatch(pretrigger)
|
||||
|
||||
def get_commands_split(self, trigger, splitkey):
|
||||
commands = []
|
||||
|
||||
@ -18,6 +18,9 @@ def prerun():
|
||||
@functools.wraps(function)
|
||||
def internal_prerun(bot, trigger, comrun, *args, **kwargs):
|
||||
|
||||
if not comrun.continuerun:
|
||||
return
|
||||
|
||||
function(bot, trigger, comrun, *args, **kwargs)
|
||||
|
||||
bot.say(comrun.say)
|
||||
|
||||
@ -9,6 +9,9 @@ def command_args():
|
||||
@functools.wraps(function)
|
||||
def internal_command_args(bot, trigger, comrun, *args, **kwargs):
|
||||
|
||||
if not comrun.continuerun:
|
||||
return
|
||||
|
||||
function(bot, trigger, comrun, *args, **kwargs)
|
||||
|
||||
return internal_command_args
|
||||
|
||||
@ -2,8 +2,9 @@ import functools
|
||||
|
||||
|
||||
class ComRun():
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
self.continuerun = True
|
||||
|
||||
|
||||
def comrun_create():
|
||||
|
||||
@ -21,8 +21,8 @@ def dispatch_multi():
|
||||
comrun.trigger_dict = commands[0]
|
||||
else:
|
||||
for trigger_dict in commands:
|
||||
sb.commands.dispatch(bot, trigger_dict)
|
||||
return
|
||||
sb.commands.dispatch(trigger_dict)
|
||||
comrun.continuerun = False
|
||||
|
||||
return internal_dispatch_multi
|
||||
return actual_decorator
|
||||
|
||||
@ -14,20 +14,20 @@ def pipe_split():
|
||||
@functools.wraps(function)
|
||||
def internal_pipe_split(bot, trigger, comrun, *args, **kwargs):
|
||||
|
||||
if not comrun.continuerun:
|
||||
return
|
||||
|
||||
# Get list of trigger command(s)
|
||||
pipes = sb.commands.get_commands_split(trigger, "|")
|
||||
|
||||
comrun.trigger_dict = pipes[0]
|
||||
del pipes[0]
|
||||
|
||||
if len(pipes) == 1:
|
||||
function(bot, trigger, comrun, *args, **kwargs)
|
||||
else:
|
||||
del pipes[0]
|
||||
|
||||
function(bot, trigger, comrun, *args, **kwargs)
|
||||
function(bot, trigger, comrun, *args, **kwargs)
|
||||
|
||||
if len(pipes) > 1:
|
||||
repipe_trigger_dict = reassemble_pipes(pipes, comrun.say)
|
||||
sb.commands.dispatch(bot, repipe_trigger_dict)
|
||||
sb.commands.dispatch(repipe_trigger_dict)
|
||||
return
|
||||
|
||||
return internal_pipe_split
|
||||
|
||||
Loading…
Reference in New Issue
Block a user