This commit is contained in:
deathbybandaid 2019-06-04 12:40:32 -04:00
parent 2cbc2b9041
commit 8e314f2aed
2 changed files with 28 additions and 0 deletions

View File

@ -22,6 +22,8 @@ class BotCommands():
self.lock = threading.Lock()
self.dict = {
"counts": 0,
'nickrules': [],
'nickaiml': [],
"commands": {
'module': {},
'nickname': {},
@ -30,9 +32,17 @@ class BotCommands():
'disabled': {}
}
self.module_files_parse()
self.nickrules()
for comtype in ['module', 'nickname', 'rule']:
logs.log('SpiceBot_Commands', "Found " + str(len(self.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True)
def nickrules(self):
for command in self.dict['commands']['rule'].keys():
if command.startswith("$nickname"):
command = command.split("$nickname")[-1]
if command not in self.dict['nickrules']:
self.dict['nickrules'].append(command)
def find_command_type(self, command):
for commandstype in self.dict['commands'].keys():
if commandstype not in ['rule']:

View File

@ -6,6 +6,8 @@ import sopel.module
import sopel_modules.SpiceBot as SpiceBot
import spicemanip
@sopel.module.rule('(.*)')
def bot_command_rule(bot, trigger):
@ -27,9 +29,25 @@ def bot_command_rule(bot, trigger):
if str(message).lower().startswith(str(bot.nick).lower()):
trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'nickname')
if str(trigger_command).startswith("?"):
return
fulltrigger = spicemanip.main(trigger_args, 0)
if fulltrigger in SpiceBot.commands.dict['nickrules']:
return
if trigger_command in SpiceBot.commands.dict['commands']["nickname"].keys():
return
else:
trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'module')
returnmessage = SpiceBot.botai.on_message(bot, trigger, message)
if returnmessage:
bot.osd(str(returnmessage))
else:
closestmatches = SpiceBot.similar_list(bot, trigger_command, SpiceBot.commands.dict['commands']["nickname"].keys(), 3, 'reverse')
if len(closestmatches):
closestmatches = spicemanip.main(closestmatches, "andlist")
bot.osd("I don't know what you are asking me to do! Did you mean: " + str(closestmatches) + "?")
return
else:
bot.osd("I don't know what you are asking me to do!")
return