mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
test
This commit is contained in:
parent
454019d799
commit
a1f4608523
@ -105,7 +105,7 @@ def prerun(t_command_type='module', t_command_subtype=None):
|
||||
botcom.dict["args"], botcom.dict["hyphen_arg"] = trigger_hyphen_args(botcom.dict["args"])
|
||||
|
||||
# special handling
|
||||
botcom.dict["responsekey"] = "?default"
|
||||
botcom = special_handling(botcom)
|
||||
|
||||
args_pass = trigger_hyphen_arg_handler(bot, trigger, botcom)
|
||||
|
||||
@ -118,6 +118,20 @@ def prerun(t_command_type='module', t_command_subtype=None):
|
||||
return actual_decorator
|
||||
|
||||
|
||||
def special_handling(botcom):
|
||||
botcom.dict["responsekey"] = "?default"
|
||||
|
||||
# handling for special cases
|
||||
posscom = spicemanip(botcom.dict['args'], 1)
|
||||
if posscom.lower() in [command.lower() for command in botcom.dict["dict"]["nonstockoptions"]]:
|
||||
for command in botcom.dict["dict"]["nonstockoptions"]:
|
||||
if command.lower() == posscom.lower():
|
||||
posscom = command
|
||||
botcom.dict["responsekey"] = posscom
|
||||
|
||||
return botcom
|
||||
|
||||
|
||||
def prerun_query(t_command_type='module', t_command_subtype=None):
|
||||
|
||||
def actual_decorator(function):
|
||||
|
||||
@ -228,6 +228,10 @@ class BotRead():
|
||||
if "?default" not in list(dict_from_file.keys()):
|
||||
dict_from_file["?default"] = {}
|
||||
|
||||
# check that type is set, use cases will inherit this if not set
|
||||
if "type" not in list(dict_from_file.keys()):
|
||||
dict_from_file["type"] = 'module'
|
||||
|
||||
if "responses" not in list(dict_from_file["?default"].keys()):
|
||||
dict_from_file["?default"]["responses"] = []
|
||||
|
||||
@ -236,6 +240,19 @@ class BotRead():
|
||||
if command not in prerun_shared.stockoptions:
|
||||
dict_from_file["nonstockoptions"].append(command)
|
||||
|
||||
for specialcase in dict_from_file["nonstockoptions"]:
|
||||
|
||||
# All of the above need to be in the dict if not
|
||||
if specialcase not in list(dict_from_file.keys()):
|
||||
dict_from_file[specialcase] = dict()
|
||||
|
||||
# verify if already there, that the key is a dict
|
||||
if not isinstance(dict_from_file[specialcase], dict):
|
||||
dict_from_file[specialcase] = dict()
|
||||
|
||||
if "type" not in list(dict_from_file[specialcase].keys()):
|
||||
dict_from_file[specialcase]["type"] = "module"
|
||||
|
||||
return dict_from_file
|
||||
|
||||
|
||||
|
||||
@ -31,17 +31,8 @@ def command_dictcom(bot, trigger, botcom):
|
||||
def bot_dictcom_process(bot, trigger, botcom):
|
||||
|
||||
# use the default key, unless otherwise specified
|
||||
botcom.dict["responsekey"] = "?default"
|
||||
|
||||
# handling for special cases
|
||||
posscom = spicemanip(botcom.dict['args'], 1)
|
||||
if posscom.lower() in [command.lower() for command in list(botcom.dict["dict"].keys())]:
|
||||
for command in botcom.dict["dict"].keys():
|
||||
if command.lower() == posscom.lower():
|
||||
posscom = command
|
||||
botcom.dict["responsekey"] = posscom
|
||||
if botcom.dict["responsekey"] != "?default":
|
||||
botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list')
|
||||
botcom.dict["dict"][botcom.dict["responsekey"]]["type"] = botcom.dict["dict"][botcom.dict["responsekey"]]["type"]
|
||||
|
||||
# This allows users to specify which reply by number by using an ! and a digit (first or last in string)
|
||||
validspecifides = ['last', 'random', 'count', 'add', 'del', 'remove']
|
||||
@ -52,7 +43,7 @@ def bot_dictcom_process(bot, trigger, botcom):
|
||||
botcom.dict["specified"] = int(argone[2:])
|
||||
elif SpiceBot.inlist(str(argone[2:]), validspecifides):
|
||||
botcom.dict["specified"] = str(argone[2:]).lower()
|
||||
elif SpiceBot.inlist(str(argone[2:]), botcom.dict["nonstockoptions"]):
|
||||
elif SpiceBot.inlist(str(argone[2:]), botcom.dict["dict"]["nonstockoptions"]):
|
||||
botcom.dict["specified"] = str(argone[2:]).lower()
|
||||
botcom.dict["responsekey"] = botcom.dict["specified"]
|
||||
else:
|
||||
@ -296,7 +287,7 @@ def bot_dictcom_reply_shared(bot, trigger, botcom):
|
||||
|
||||
# display special options for this command
|
||||
if "$specialoptions" in rply:
|
||||
nonstockoptions = spicemanip(botcom.dict["nonstockoptions"], "andlist")
|
||||
nonstockoptions = spicemanip(botcom.dict["dict"]["nonstockoptions"], "andlist")
|
||||
rply = rply.replace("$specialoptions", nonstockoptions)
|
||||
|
||||
# saying, or action?
|
||||
|
||||
Loading…
Reference in New Issue
Block a user