mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
test new query system
This commit is contained in:
parent
8793a518e1
commit
5005bb40fb
@ -88,6 +88,79 @@ def prerun(t_command_type='module', t_command_subtype=None):
|
|||||||
return actual_decorator
|
return actual_decorator
|
||||||
|
|
||||||
|
|
||||||
|
def prerun_q(t_command_type='module'):
|
||||||
|
|
||||||
|
def actual_decorator(function):
|
||||||
|
|
||||||
|
@functools.wraps(function)
|
||||||
|
def internal_prerun(bot, trigger, *args, **kwargs):
|
||||||
|
|
||||||
|
trigger_command_type = str(t_command_type)
|
||||||
|
|
||||||
|
# Primary command used for trigger, and a list of all words
|
||||||
|
trigger_args, trigger_command = make_trigger_args(trigger.args[1], trigger_command_type)
|
||||||
|
|
||||||
|
# Argsdict Defaults
|
||||||
|
argsdict_default = {}
|
||||||
|
argsdict_default["type"] = trigger_command_type
|
||||||
|
argsdict_default["com"] = trigger_command
|
||||||
|
|
||||||
|
# messagelog ID
|
||||||
|
argsdict_default["log_id"] = botmessagelog.messagelog_assign()
|
||||||
|
|
||||||
|
argsdict_default["realcom"] = "query_command"
|
||||||
|
|
||||||
|
if argsdict_default["type"] == 'nickname':
|
||||||
|
argsdict_default["comtext"] = "'" + bot.nick + " ?query_command'"
|
||||||
|
argsdict_default["realcomtext"] = "'" + bot.nick + " ?query_command'"
|
||||||
|
else:
|
||||||
|
argsdict_default["comtext"] = "'?query_command'"
|
||||||
|
argsdict_default["realcomtext"] = "'?query_command'"
|
||||||
|
|
||||||
|
argsdict_default["realcomref"] = "query_query"
|
||||||
|
|
||||||
|
argsdict_default["dict"] = {
|
||||||
|
"author": "deathbybandaid",
|
||||||
|
"contributors": [],
|
||||||
|
"example": "",
|
||||||
|
"exampleresponse": "",
|
||||||
|
"description": "",
|
||||||
|
"privs": [],
|
||||||
|
"filename": "",
|
||||||
|
"filepath": "",
|
||||||
|
"foldername": "",
|
||||||
|
"folderpath": "",
|
||||||
|
"validcoms": [],
|
||||||
|
}
|
||||||
|
|
||||||
|
# split into && groupings
|
||||||
|
and_split = trigger_and_split(trigger_args)
|
||||||
|
|
||||||
|
# Create dict listings for trigger.sb
|
||||||
|
argsdict_list = trigger_argsdict_list(argsdict_default, and_split)
|
||||||
|
|
||||||
|
# Run the function for all splits
|
||||||
|
botmessagelog.messagelog_start(bot, trigger, argsdict_default["log_id"])
|
||||||
|
runcount = 0
|
||||||
|
for argsdict in argsdict_list:
|
||||||
|
runcount += 1
|
||||||
|
trigger.sb = copy.deepcopy(argsdict)
|
||||||
|
|
||||||
|
trigger.sb["runcount"] = runcount
|
||||||
|
|
||||||
|
trigger.sb["args"], trigger.sb["hyphen_arg"] = trigger_hyphen_args(trigger.sb["args"])
|
||||||
|
if not trigger.sb["hyphen_arg"]:
|
||||||
|
# check if anything prohibits the nick from running the command
|
||||||
|
if trigger_runstatus(bot, trigger):
|
||||||
|
function(bot, trigger, *args, **kwargs)
|
||||||
|
else:
|
||||||
|
trigger_hyphen_arg_handler(bot, trigger)
|
||||||
|
botmessagelog.messagelog_exit(bot, argsdict_default["log_id"])
|
||||||
|
|
||||||
|
return internal_prerun
|
||||||
|
return actual_decorator
|
||||||
|
|
||||||
|
|
||||||
def make_trigger_args(triggerargs_one, trigger_command_type='module'):
|
def make_trigger_args(triggerargs_one, trigger_command_type='module'):
|
||||||
trigger_args = spicemanip.main(triggerargs_one, 'create')
|
trigger_args = spicemanip.main(triggerargs_one, 'create')
|
||||||
if trigger_command_type in ['nickname']:
|
if trigger_command_type in ['nickname']:
|
||||||
|
|||||||
@ -12,8 +12,14 @@ import spicemanip
|
|||||||
import sopel_modules.SpiceBot as SpiceBot
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
|
||||||
|
|
||||||
|
@SpiceBot.prerun_q('nickname')
|
||||||
|
@sopel.module.nickname_commands('query')
|
||||||
|
def query_trigger(bot, trigger):
|
||||||
|
bot.osd("I have been programmed to help find new commands by using `?`.")
|
||||||
|
|
||||||
|
|
||||||
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS])
|
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS])
|
||||||
@SpiceBot.prerun('nickname_match')
|
@SpiceBot.prerun_q('nickname')
|
||||||
@sopel.module.nickname_commands('(.*)')
|
@sopel.module.nickname_commands('(.*)')
|
||||||
def query_detection_nick(bot, trigger):
|
def query_detection_nick(bot, trigger):
|
||||||
|
|
||||||
@ -79,7 +85,7 @@ def query_detection_nick(bot, trigger):
|
|||||||
|
|
||||||
|
|
||||||
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS])
|
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS])
|
||||||
@SpiceBot.prerun('query')
|
@SpiceBot.prerun_q('module')
|
||||||
@sopel.module.rule('^\?(.*)')
|
@sopel.module.rule('^\?(.*)')
|
||||||
def query_detection(bot, trigger):
|
def query_detection(bot, trigger):
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user