SpiceBot/sopel_SpiceBot_Core_Prerun/rule_match.py
deathbybandaid 120372c8cf test
2022-02-22 16:27:07 -05:00

33 lines
1.0 KiB
Python

import functools
from sopel_SpiceBot_Core_1 import sb
def rule_match():
"""This Detects --arguments to commands."""
def actual_decorator(function):
@functools.wraps(function)
def internal_rule_match(bot, trigger, comrun, *args, **kwargs):
returnfunc = True
if comrun.rulematch:
if comrun.trigger_dict["trigger_type"] == "command":
commands_list = sb.commands.valid_sopel_commands
elif comrun.trigger_dict["trigger_type"] == "nickname_command":
commands_list = sb.commands.valid_sopel_nickname_commands
elif comrun.trigger_dict["trigger_type"] == "action_command":
commands_list = sb.commands.valid_sopel_action_commands
if comrun.trigger_dict["trigger_command"] in commands_list:
returnfunc = False
if returnfunc:
function(bot, trigger, comrun, *args, **kwargs)
return internal_rule_match
return actual_decorator