mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-12 22:49:53 -05:00
test new logic
This commit is contained in:
parent
29318afd6c
commit
708561ffe9
@ -22,29 +22,17 @@ def bot_command_rule(bot, trigger):
|
|||||||
return
|
return
|
||||||
|
|
||||||
message = trigger.args[1]
|
message = trigger.args[1]
|
||||||
|
|
||||||
|
# the bot brain cannot handle stuff like unicode shrug
|
||||||
message = ''.join([x for x in message if ord(x) < 128])
|
message = ''.join([x for x in message if ord(x) < 128])
|
||||||
|
|
||||||
# ignore text coming from a valid prefix
|
# Create list of valid commands
|
||||||
if str(message).startswith(tuple(bot.config.core.prefix_list)):
|
commands_list = []
|
||||||
return
|
for commandstype in list(SpiceBot.commands.dict['commands'].keys()):
|
||||||
trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'module')
|
if commandstype not in ['rule', 'nickname']:
|
||||||
# patch for people typing "...", maybe other stuff, but this verifies that there is still a command here
|
for com in list(SpiceBot.commands.dict['commands'][commandstype].keys()):
|
||||||
if trigger_command.startswith("."):
|
if com not in commands_list:
|
||||||
return
|
commands_list.append(com)
|
||||||
commands_list = []
|
|
||||||
for commandstype in list(SpiceBot.commands.dict['commands'].keys()):
|
|
||||||
if commandstype not in ['rule', 'nickname']:
|
|
||||||
for com in list(SpiceBot.commands.dict['commands'][commandstype].keys()):
|
|
||||||
if com not in commands_list:
|
|
||||||
commands_list.append(com)
|
|
||||||
if trigger_command not in commands_list:
|
|
||||||
if not SpiceBot.letters_in_string(trigger_command):
|
|
||||||
return
|
|
||||||
invalid_display = ["I don't seem to have a command for " + str(trigger_command) + "!"]
|
|
||||||
# invalid_display.append("If you have a suggestion for this command, you can run .feature ." + str(trigger_command))
|
|
||||||
# invalid_display.append("ADD DESCRIPTION HERE!")
|
|
||||||
bot.osd(invalid_display, trigger.nick, 'notice')
|
|
||||||
return
|
|
||||||
|
|
||||||
if str(message).lower().startswith(str(bot.nick).lower()):
|
if str(message).lower().startswith(str(bot.nick).lower()):
|
||||||
command_type = 'nickname'
|
command_type = 'nickname'
|
||||||
@ -57,6 +45,20 @@ def bot_command_rule(bot, trigger):
|
|||||||
return
|
return
|
||||||
if trigger_command in list(SpiceBot.commands.dict['commands']["nickname"].keys()):
|
if trigger_command in list(SpiceBot.commands.dict['commands']["nickname"].keys()):
|
||||||
return
|
return
|
||||||
|
elif str(message).lower().startswith("?"):
|
||||||
|
# no query commands detection here
|
||||||
|
return
|
||||||
|
elif str(message).startswith(tuple(bot.config.core.prefix_list)):
|
||||||
|
command_type = 'module'
|
||||||
|
trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'module')
|
||||||
|
trigger_args.insert(0, trigger_command)
|
||||||
|
fulltrigger = spicemanip.main(trigger_args, 0)
|
||||||
|
# patch for people typing "...", maybe other stuff, but this verifies that there is still a command here
|
||||||
|
if trigger_command.startswith(tuple(bot.config.core.prefix_list)):
|
||||||
|
return
|
||||||
|
# If valid command don't continue further
|
||||||
|
if trigger_command not in commands_list:
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
command_type = 'other'
|
command_type = 'other'
|
||||||
trigger_args = spicemanip.main(message, 'create')
|
trigger_args = spicemanip.main(message, 'create')
|
||||||
@ -67,7 +69,20 @@ def bot_command_rule(bot, trigger):
|
|||||||
if returnmessage:
|
if returnmessage:
|
||||||
bot.osd(str(returnmessage))
|
bot.osd(str(returnmessage))
|
||||||
else:
|
else:
|
||||||
if command_type == 'nickname':
|
|
||||||
|
if command_type == 'module':
|
||||||
|
# return # TODO
|
||||||
|
if trigger_command not in commands_list:
|
||||||
|
if not SpiceBot.letters_in_string(trigger_command):
|
||||||
|
return
|
||||||
|
invalid_display = ["I don't seem to have a command for " + str(trigger_command) + "!"]
|
||||||
|
# TODO
|
||||||
|
# invalid_display.append("If you have a suggestion for this command, you can run .feature ." + str(trigger_command))
|
||||||
|
# invalid_display.append("ADD DESCRIPTION HERE!")
|
||||||
|
bot.osd(invalid_display, trigger.nick, 'notice')
|
||||||
|
return
|
||||||
|
|
||||||
|
elif command_type == 'nickname':
|
||||||
|
|
||||||
if trigger_args[0].lower() in ["what", "where"] and trigger_args[1].lower() in ["is", "are"]:
|
if trigger_args[0].lower() in ["what", "where"] and trigger_args[1].lower() in ["is", "are"]:
|
||||||
# TODO saved definitions
|
# TODO saved definitions
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user