mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
tests
This commit is contained in:
parent
69cea3c0fd
commit
250b07f293
@ -100,6 +100,14 @@ class MessageLog():
|
||||
|
||||
self.message_display[log_id]["messages"].append(messagedict)
|
||||
|
||||
def messagelog_private(self, log_id, message):
|
||||
|
||||
recipients = [self.message_display[log_id]["trigger"]["nick"]]
|
||||
|
||||
messagedict = {"type": "private", "message": message, "recipients": recipients}
|
||||
|
||||
self.message_display[log_id]["messages"].append(messagedict)
|
||||
|
||||
def messagelog_exit(self, bot, log_id):
|
||||
|
||||
current_messages = []
|
||||
@ -132,6 +140,9 @@ class MessageLog():
|
||||
if messagedict["type"] == 'error':
|
||||
bot.osd(messagedict['message'], self.message_display[log_id]["trigger"]["nick"], 'notice')
|
||||
|
||||
elif messagedict["type"] == 'private':
|
||||
bot.osd(messagedict['message'], messagedict["recipients"], 'notice')
|
||||
|
||||
elif len(messagedict["recipients"]) > 1:
|
||||
bot.osd(messagedict['message'], messagedict["recipients"], 'notice')
|
||||
|
||||
|
||||
@ -445,6 +445,9 @@ def special_handling(botcom):
|
||||
posscom = command
|
||||
botcom.dict["responsekey"] = posscom
|
||||
|
||||
if botcom.dict["responsekey"] != "?default":
|
||||
botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list')
|
||||
|
||||
return botcom
|
||||
|
||||
|
||||
@ -511,7 +514,7 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom):
|
||||
if not len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]):
|
||||
botmessagelog.messagelog(botcom.dict["log_id"], "The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command appears to have no entries!")
|
||||
else:
|
||||
bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command contains:", trigger.nick, 'notice')
|
||||
botmessagelog.messagelog_private(botcom.dict["log_id"], "The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command contains:")
|
||||
listnumb, relist = 0, []
|
||||
for item in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]:
|
||||
listnumb += 1
|
||||
@ -521,20 +524,33 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom):
|
||||
relist.append(str("[#" + str(listnumb) + "] COMPLEX list Entry"))
|
||||
else:
|
||||
relist.append(str("[#" + str(listnumb) + "] " + str(item)))
|
||||
bot.osd(relist, trigger.nick, 'notice')
|
||||
botmessagelog.messagelog_private(botcom.dict["log_id"], relist)
|
||||
return False
|
||||
|
||||
elif botcom.dict["hyphen_arg"] in ['count']:
|
||||
bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command has " + str(len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"])) + " entries.")
|
||||
botmessagelog.messagelog(botcom.dict["log_id"], "The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command has " + str(len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"])) + " entries.")
|
||||
return False
|
||||
|
||||
elif botcom.dict["hyphen_arg"] in ['special', 'options']:
|
||||
elif botcom.dict["hyphen_arg"] in ['special', 'options', 'list']:
|
||||
if not len(botcom.dict["dict"]["nonstockoptions"]):
|
||||
bot.osd("There appear to be no special options for " + str(botcom.dict["realcom"]) + ".")
|
||||
botmessagelog.messagelog(botcom.dict["log_id"], "There appear to be no special options for " + str(botcom.dict["realcom"]) + ".")
|
||||
else:
|
||||
bot.osd("The special options for " + str(botcom.dict["realcom"]) + " command include: " + spicemanip(botcom.dict["dict"]["nonstockoptions"], "andlist") + ".")
|
||||
botmessagelog.messagelog(botcom.dict["log_id"], "The special options for " + str(botcom.dict["realcom"]) + " command include: " + spicemanip(botcom.dict["dict"]["nonstockoptions"], "andlist") + ".")
|
||||
return False
|
||||
|
||||
elif botcom.dict["hyphen_arg"] in ['add', 'del', 'remove']:
|
||||
if botcom.dict["hyphen_arg"] in ['add', 'remove']:
|
||||
directionword = botcom.dict["hyphen_arg"]
|
||||
elif botcom.dict["hyphen_arg"] in ['del']:
|
||||
directionword = "remove"
|
||||
if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]:
|
||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list cannot be updated.")
|
||||
|
||||
fulltext = spicemanip(botcom.dict['args'], 0)
|
||||
if not fulltext:
|
||||
botmessagelog.messagelog(botcom.dict["log_id"], "What would you like to " + directionword + " from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?")
|
||||
return True
|
||||
|
||||
elif botcom.dict["hyphen_arg"] in [
|
||||
'enable', 'disable',
|
||||
'block', 'unblock',
|
||||
|
||||
@ -224,18 +224,11 @@ class BotRead():
|
||||
if "hardcoded_channel_block" not in list(dict_from_file.keys()):
|
||||
dict_from_file["hardcoded_channel_block"] = []
|
||||
|
||||
# ensure creation of '?default'
|
||||
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"] = []
|
||||
|
||||
dict_from_file["nonstockoptions"] = []
|
||||
dict_from_file["nonstockoptions"] = ["?default"]
|
||||
for command in list(dict_from_file.keys()):
|
||||
if command not in prerun_shared.stockoptions:
|
||||
dict_from_file["nonstockoptions"].append(command)
|
||||
@ -250,9 +243,22 @@ class BotRead():
|
||||
if not isinstance(dict_from_file[specialcase], dict):
|
||||
dict_from_file[specialcase] = dict()
|
||||
|
||||
if "responses" not in list(dict_from_file[specialcase].keys()):
|
||||
dict_from_file[specialcase]["responses"] = []
|
||||
|
||||
if "type" not in list(dict_from_file[specialcase].keys()):
|
||||
dict_from_file[specialcase]["type"] = "module"
|
||||
|
||||
# each usecase needs to know if it can be updated. Default is false
|
||||
if "updates_enabled" not in list(dict_from_file[specialcase].keys()):
|
||||
dict_from_file[specialcase]["updates_enabled"] = False
|
||||
if dict_from_file[specialcase]["updates_enabled"]:
|
||||
if dict_from_file[specialcase]["updates_enabled"] not in ["shared", "user"]:
|
||||
dict_from_file[specialcase]["updates_enabled"] = "shared"
|
||||
|
||||
if "?default" in dict_from_file["nonstockoptions"]:
|
||||
dict_from_file["nonstockoptions"].remove("?default")
|
||||
|
||||
return dict_from_file
|
||||
|
||||
|
||||
|
||||
@ -25,7 +25,9 @@ class Botprerun_shared():
|
||||
|
||||
self.valid_hyphen_args = [
|
||||
'check', 'view',
|
||||
'count', 'special', 'options',
|
||||
'count',
|
||||
'special', 'options', 'list',
|
||||
'add', 'del', 'remove',
|
||||
'enable', 'disable',
|
||||
'block', 'unblock',
|
||||
"activate", "deactivate",
|
||||
|
||||
@ -29,23 +29,13 @@ def command_dictcom(bot, trigger, botcom):
|
||||
|
||||
def bot_dictcom_process(bot, trigger, botcom):
|
||||
|
||||
# use the default key, unless otherwise specified
|
||||
if botcom.dict["responsekey"] != "?default":
|
||||
botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list')
|
||||
|
||||
# This allows users to specify which reply by number by using an ! and a digit (first or last in string)
|
||||
botcom.dict["specified"] = None
|
||||
if botcom.dict["hyphen_arg"]:
|
||||
if str(botcom.dict["hyphen_arg"]).isdigit() or botcom.dict["hyphen_arg"] in [-1, 'random']:
|
||||
botcom.dict["specified"] = botcom.dict["hyphen_arg"]
|
||||
else:
|
||||
validspecifides = ['random', 'add', 'del', 'remove']
|
||||
argone = spicemanip(botcom.dict['args'], 1)
|
||||
if str(argone).startswith("--") and len(str(argone)) > 2:
|
||||
if SpiceBot.inlist(str(argone[2:]), validspecifides):
|
||||
botcom.dict["specified"] = str(argone[2:]).lower()
|
||||
if botcom.dict["specified"]:
|
||||
botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list')
|
||||
elif str(botcom.dict["hyphen_arg"]).lower() in ['add', 'del', 'remove']:
|
||||
botcom.dict["specified"] = botcom.dict["hyphen_arg"]
|
||||
|
||||
# commands that can be updated
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]:
|
||||
@ -58,9 +48,6 @@ def bot_dictcom_process(bot, trigger, botcom):
|
||||
|
||||
elif botcom.dict["specified"] == 'add':
|
||||
|
||||
if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]:
|
||||
return bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list cannot be updated.")
|
||||
|
||||
fulltext = spicemanip(botcom.dict['args'], 0)
|
||||
if not fulltext:
|
||||
return bot.osd("What would you like to add to the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?")
|
||||
@ -77,9 +64,6 @@ def bot_dictcom_process(bot, trigger, botcom):
|
||||
|
||||
elif botcom.dict["specified"] in ['del', 'remove']:
|
||||
|
||||
if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]:
|
||||
return bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list cannot be updated.")
|
||||
|
||||
fulltext = spicemanip(botcom.dict['args'], 0)
|
||||
if not fulltext:
|
||||
return bot.osd("What would you like to remove from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user