test
This commit is contained in:
parent
c809332507
commit
cf46c0e3bb
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
from sopel.trigger import PreTrigger
|
from sopel.trigger import PreTrigger, Trigger
|
||||||
|
|
||||||
|
|
||||||
class Commands():
|
class Commands():
|
||||||
@ -80,13 +80,17 @@ class Commands():
|
|||||||
return commands_list
|
return commands_list
|
||||||
|
|
||||||
def dispatch(self, trigger_dict):
|
def dispatch(self, trigger_dict):
|
||||||
|
pretrigger = self.get_pretrigger(trigger_dict)
|
||||||
|
self.bot.dispatch(pretrigger)
|
||||||
|
|
||||||
|
def get_pretrigger(self, trigger_dict):
|
||||||
if trigger_dict["trigger_type"] == "command":
|
if trigger_dict["trigger_type"] == "command":
|
||||||
pretrigger = self.generate_pretrigger_command(trigger_dict)
|
pretrigger = self.generate_pretrigger_command(trigger_dict)
|
||||||
elif trigger_dict["trigger_type"] == "nickname_command":
|
elif trigger_dict["trigger_type"] == "nickname_command":
|
||||||
pretrigger = self.generate_pretrigger_nickname_command(trigger_dict)
|
pretrigger = self.generate_pretrigger_nickname_command(trigger_dict)
|
||||||
elif trigger_dict["trigger_type"] == "action_command":
|
elif trigger_dict["trigger_type"] == "action_command":
|
||||||
pretrigger = self.generate_pretrigger_action_command(trigger_dict)
|
pretrigger = self.generate_pretrigger_action_command(trigger_dict)
|
||||||
self.bot.dispatch(pretrigger)
|
return pretrigger
|
||||||
|
|
||||||
def generate_pretrigger_command(self, trigger_dict):
|
def generate_pretrigger_command(self, trigger_dict):
|
||||||
# @time=2022-02-23T15:04:01.447Z :
|
# @time=2022-02-23T15:04:01.447Z :
|
||||||
@ -164,14 +168,13 @@ class Commands():
|
|||||||
command_aliases = function.action_commands
|
command_aliases = function.action_commands
|
||||||
return command_aliases
|
return command_aliases
|
||||||
|
|
||||||
def get_command_match(self, function, trigger):
|
def get_new_trigger(self, test_rule, trigger_dict):
|
||||||
command_type = self.what_command_type(trigger)
|
test_rule = plugins.rules.Command.from_callable(settings, tested_func)
|
||||||
command_aliases = self.get_command_aliases(function, command_type)
|
parse_results = list(test_rule.parse(msg))
|
||||||
command_match = None
|
match = parse_results[0]
|
||||||
print((dir))
|
pretrigger = self.get_pretrigger(trigger_dict)
|
||||||
# for command in command_aliases:
|
trigger = Trigger(self.bot.config, pretrigger, match)
|
||||||
# True
|
return trigger
|
||||||
return None
|
|
||||||
|
|
||||||
def get_commands_nosplit(self, trigger):
|
def get_commands_nosplit(self, trigger):
|
||||||
commands = []
|
commands = []
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
import functools
|
import functools
|
||||||
|
|
||||||
|
from sopel import plugins
|
||||||
|
from sopel.trigger import Trigger
|
||||||
|
|
||||||
from sopel_SpiceBot_Core_1 import sb
|
from sopel_SpiceBot_Core_1 import sb
|
||||||
|
|
||||||
|
|
||||||
@ -49,7 +52,7 @@ def prerun():
|
|||||||
return
|
return
|
||||||
|
|
||||||
# At this point, we update the re.match for trigger
|
# At this point, we update the re.match for trigger
|
||||||
comrun.trigger = rebuild_trigger(comrun, trigger)
|
# comrun.trigger = rebuild_trigger(comrun, function)
|
||||||
|
|
||||||
# Run function
|
# Run function
|
||||||
function(bot, trigger, comrun, *args, **kwargs)
|
function(bot, trigger, comrun, *args, **kwargs)
|
||||||
@ -61,11 +64,12 @@ def prerun():
|
|||||||
return actual_decorator
|
return actual_decorator
|
||||||
|
|
||||||
|
|
||||||
def rebuild_trigger(comrun, trigger):
|
def rebuild_trigger(comrun, tested_func):
|
||||||
matchlist = [x for x in dir(trigger.match) if not x.startswith("__")]
|
test_rule = plugins.rules.Command.from_callable(sb.settings, tested_func)
|
||||||
for x in matchlist:
|
parse_results = list(test_rule.parse(""))
|
||||||
print(x)
|
match = parse_results[0]
|
||||||
print(eval("trigger.match.%s" % x))
|
pretrigger = sb.commands.get_pretrigger(comrun.command)
|
||||||
|
trigger = Trigger(comrun.bot.config, pretrigger, match)
|
||||||
return trigger
|
return trigger
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -30,3 +30,8 @@ def commands_test_c(bot, trigger, comrun):
|
|||||||
bot.say("test c")
|
bot.say("test c")
|
||||||
|
|
||||||
bot.say("test c: %s" % trigger.raw)
|
bot.say("test c: %s" % trigger.raw)
|
||||||
|
|
||||||
|
|
||||||
|
@plugin.command('fart box')
|
||||||
|
def fart_box(bot, trigger, comrun):
|
||||||
|
bot.say("fart box")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user