This commit is contained in:
deathbybandaid 2019-09-19 09:47:47 -04:00
parent dcdf2c43a1
commit b3b628a51d
4 changed files with 25 additions and 16 deletions

View File

@ -12,6 +12,7 @@ from .Config import config as botconfig
from .Read import read as botread from .Read import read as botread
from .Commands import commands as botcommands from .Commands import commands as botcommands
from .Database import db as botdb from .Database import db as botdb
from .Prerun import prerun_shared
import os import os
import copy import copy
@ -104,6 +105,11 @@ class BotDictCommands():
if otherkeys != []: if otherkeys != []:
dict_from_file = self.dictcom_load_usecases(maincom, dict_from_file, otherkeys) dict_from_file = self.dictcom_load_usecases(maincom, dict_from_file, otherkeys)
dict_from_file["nonstockoptions"] = []
for command in list(dict_from_file["dict"].keys()):
if command not in prerun_shared.stockoptions:
dict_from_file["nonstockoptions"].append(command)
botcommands.register(dict_from_file) botcommands.register(dict_from_file)
def dictcom_load_usecases(self, maincom, dict_from_file, process_list): def dictcom_load_usecases(self, maincom, dict_from_file, process_list):

View File

@ -28,7 +28,7 @@ class Botprerun_shared():
self.valid_hyphen_args = [ self.valid_hyphen_args = [
'check', 'view', 'check', 'view',
'count', 'count', 'special',
'enable', 'disable', 'enable', 'disable',
'block', 'unblock', 'block', 'unblock',
"activate", "deactivate", "activate", "deactivate",
@ -47,6 +47,12 @@ class Botprerun_shared():
"last": -1 "last": -1
} }
self.stockoptions = [
"?default", "validcoms", "contributors", "author", "type",
"filepath", "filename", "hardcoded_channel_block", "description",
"exampleresponse", "example", "usage", "privs"
]
prerun_shared = Botprerun_shared() prerun_shared = Botprerun_shared()
@ -540,6 +546,10 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom):
bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command has " + str(len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"])) + " entries.") bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command has " + str(len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"])) + " entries.")
return False return False
elif botcom.dict["hyphen_arg"] in ['special']:
bot.osd("The special options for " + str(botcom.dict["realcom"]) + " command include: " + str(botcom.dict["nonstockoptions"]) + ".")
return False
elif botcom.dict["hyphen_arg"] in [ elif botcom.dict["hyphen_arg"] in [
'enable', 'disable', 'enable', 'disable',
'block', 'unblock', 'block', 'unblock',

View File

@ -12,6 +12,7 @@ from fake_useragent import UserAgent
from .Logs import logs from .Logs import logs
from .Config import config as botconfig from .Config import config as botconfig
from .Prerun import prerun_shared
class BotRead(): class BotRead():
@ -230,6 +231,11 @@ class BotRead():
if "responses" not in list(dict_from_file["?default"].keys()): if "responses" not in list(dict_from_file["?default"].keys()):
dict_from_file["?default"]["responses"] = [] dict_from_file["?default"]["responses"] = []
dict_from_file["nonstockoptions"] = []
for command in list(dict_from_file["dict"].keys()):
if command not in prerun_shared.stockoptions:
dict_from_file["nonstockoptions"].append(command)
return dict_from_file return dict_from_file

View File

@ -43,13 +43,8 @@ def bot_dictcom_process(bot, trigger, botcom):
botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list') botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list')
botcom.dict["dict"][botcom.dict["responsekey"]]["type"] = botcom.dict["dict"][botcom.dict["responsekey"]]["type"] botcom.dict["dict"][botcom.dict["responsekey"]]["type"] = botcom.dict["dict"][botcom.dict["responsekey"]]["type"]
botcom.dict["nonstockoptions"] = []
for command in list(botcom.dict["dict"].keys()):
if command not in ["?default", "validcoms", "type", "hardcoded_channel_block"]:
botcom.dict["nonstockoptions"].append(command)
# This allows users to specify which reply by number by using an ! and a digit (first or last in string) # 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', 'special'] validspecifides = ['last', 'random', 'count', 'add', 'del', 'remove']
botcom.dict["specified"] = None botcom.dict["specified"] = None
argone = spicemanip(botcom.dict['args'], 1) argone = spicemanip(botcom.dict['args'], 1)
if str(argone).startswith("--") and len(str(argone)) > 2: if str(argone).startswith("--") and len(str(argone)) > 2:
@ -78,10 +73,6 @@ def bot_dictcom_process(bot, trigger, botcom):
SpiceBot.dictcoms.adjust_nick_array(str(trigger.nick), 'sayings', botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), botcom.dict["dict"][botcom.dict["responsekey"]]["responses"], 'startup') SpiceBot.dictcoms.adjust_nick_array(str(trigger.nick), 'sayings', botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), botcom.dict["dict"][botcom.dict["responsekey"]]["responses"], 'startup')
botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = SpiceBot.db.get_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = SpiceBot.db.get_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or []
if botcom.dict["specified"] == 'special':
nonstockoptions = spicemanip(botcom.dict["nonstockoptions"], "andlist")
return bot.osd("The special options for " + str(botcom.dict["realcom"]) + " command include: " + str(nonstockoptions) + ".")
elif botcom.dict["specified"] == 'add': elif botcom.dict["specified"] == 'add':
if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]:
@ -305,11 +296,7 @@ def bot_dictcom_reply_shared(bot, trigger, botcom):
# display special options for this command # display special options for this command
if "$specialoptions" in rply: if "$specialoptions" in rply:
nonstockoptions = [] nonstockoptions = spicemanip(botcom.dict["nonstockoptions"], "andlist")
for command in list(botcom.dict["dict"].keys()):
if command not in ["?default", "validcoms", "contributors", "author", "type", "filepath", "filename", "hardcoded_channel_block", "description", "exampleresponse", "example", "usage", "privs"]:
nonstockoptions.append(command)
nonstockoptions = spicemanip(nonstockoptions, "andlist")
rply = rply.replace("$specialoptions", nonstockoptions) rply = rply.replace("$specialoptions", nonstockoptions)
# saying, or action? # saying, or action?