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