mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 15:09:54 -05:00
commit
51d92f3eb7
@ -76,11 +76,11 @@ class SpiceBot_AI():
|
|||||||
|
|
||||||
def load_bot_values(self):
|
def load_bot_values(self):
|
||||||
|
|
||||||
# current_bot_db = botdb.get_bot_value('botai') or None
|
current_bot_db = botdb.get_plugin_value('SpiceBot_AI', 'brain') or None
|
||||||
# if current_bot_db:
|
if current_bot_db:
|
||||||
# for predicate in list(current_bot_db.keys()):
|
for predicate in list(current_bot_db.keys()):
|
||||||
# predval = current_bot_db[predicate]
|
predval = current_bot_db[predicate]
|
||||||
# self.aiml_kernel.setBotPredicate(predicate, predval)
|
self.aiml_kernel.setBotPredicate(predicate, predval)
|
||||||
|
|
||||||
# sopel nick
|
# sopel nick
|
||||||
self.aiml_kernel.setBotPredicate("nick", botconfig.nick)
|
self.aiml_kernel.setBotPredicate("nick", botconfig.nick)
|
||||||
@ -242,8 +242,8 @@ class SpiceBot_AI():
|
|||||||
|
|
||||||
def save_brain(self):
|
def save_brain(self):
|
||||||
self.aiml_kernel.saveBrain(botconfig.config.aibrain)
|
self.aiml_kernel.saveBrain(botconfig.config.aibrain)
|
||||||
# botsessiondata = self.aiml_kernel._botPredicates
|
botsessiondata = self.aiml_kernel._botPredicates
|
||||||
# botdb.set_bot_value('botai', botsessiondata)
|
botdb.set_plugin_value('SpiceBot_AI', 'brain', botsessiondata)
|
||||||
|
|
||||||
|
|
||||||
botai = SpiceBot_AI()
|
botai = SpiceBot_AI()
|
||||||
|
|||||||
@ -528,7 +528,6 @@ class SpiceDB(object):
|
|||||||
|
|
||||||
|
|
||||||
class BotDatabase():
|
class BotDatabase():
|
||||||
"""A thread safe database cache"""
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
|
|||||||
49
sopel_modules/SpiceBot/Google.py
Normal file
49
sopel_modules/SpiceBot/Google.py
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# coding=utf8
|
||||||
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||||
|
"""A way to search google"""
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from fake_useragent import UserAgent
|
||||||
|
|
||||||
|
|
||||||
|
class Google():
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.cache = {
|
||||||
|
"info": {},
|
||||||
|
"maps": {}
|
||||||
|
}
|
||||||
|
|
||||||
|
def search(self, searchterm, searchtype="info"):
|
||||||
|
|
||||||
|
# losercase searching
|
||||||
|
searchterm = searchterm.lower()
|
||||||
|
|
||||||
|
# check cache
|
||||||
|
if searchtype not in list(self.cache.keys()):
|
||||||
|
self.cache[searchtype] = dict()
|
||||||
|
if searchterm in self.cache[searchtype]:
|
||||||
|
return self.cache[searchtype][searchterm]
|
||||||
|
|
||||||
|
header = {'User-Agent': str(UserAgent().chrome)}
|
||||||
|
data = searchterm.replace(' ', '+')
|
||||||
|
lookfor = data.replace(':', '%3A')
|
||||||
|
try:
|
||||||
|
if searchtype == 'maps':
|
||||||
|
var = requests.get(r'http://www.google.com/maps/place/' + lookfor, headers=header)
|
||||||
|
elif searchtype == 'info':
|
||||||
|
var = requests.get(r'http://www.google.com/search?q=' + lookfor + '&btnI', headers=header)
|
||||||
|
else:
|
||||||
|
var = requests.get(r'http://www.google.com/search?q=' + lookfor + '&btnI', headers=header)
|
||||||
|
except Exception as e:
|
||||||
|
var = e
|
||||||
|
var = None
|
||||||
|
|
||||||
|
if not var or not var.url:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
self.cache[searchtype][searchterm] = str(var.url)
|
||||||
|
return var.url
|
||||||
|
|
||||||
|
|
||||||
|
google = Google()
|
||||||
@ -10,8 +10,6 @@ import collections
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import codecs
|
import codecs
|
||||||
import requests
|
|
||||||
from fake_useragent import UserAgent
|
|
||||||
from difflib import SequenceMatcher
|
from difflib import SequenceMatcher
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from collections import abc
|
from collections import abc
|
||||||
@ -129,25 +127,6 @@ def humanized_time(countdownseconds):
|
|||||||
"""Online Information Requests"""
|
"""Online Information Requests"""
|
||||||
|
|
||||||
|
|
||||||
def googlesearch(searchterm, searchtype=None):
|
|
||||||
header = {'User-Agent': str(UserAgent().chrome)}
|
|
||||||
data = searchterm.replace(' ', '+')
|
|
||||||
lookfor = data.replace(':', '%3A')
|
|
||||||
try:
|
|
||||||
if searchtype == 'maps':
|
|
||||||
var = requests.get(r'http://www.google.com/maps/place/' + lookfor, headers=header)
|
|
||||||
else:
|
|
||||||
var = requests.get(r'http://www.google.com/search?q=' + lookfor + '&btnI', headers=header)
|
|
||||||
except Exception as e:
|
|
||||||
var = e
|
|
||||||
var = None
|
|
||||||
|
|
||||||
if not var or not var.url:
|
|
||||||
return None
|
|
||||||
else:
|
|
||||||
return var.url
|
|
||||||
|
|
||||||
|
|
||||||
"""List Manipulation Functions"""
|
"""List Manipulation Functions"""
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,7 @@ from .StartupMonologue import *
|
|||||||
from .Channels import *
|
from .Channels import *
|
||||||
from .Users import *
|
from .Users import *
|
||||||
from .AI import *
|
from .AI import *
|
||||||
|
from .Google import *
|
||||||
|
|
||||||
|
|
||||||
from .configure import *
|
from .configure import *
|
||||||
|
|||||||
@ -222,14 +222,19 @@ class SopelOSD:
|
|||||||
|
|
||||||
self.sending.acquire()
|
self.sending.acquire()
|
||||||
|
|
||||||
if not recipient_stack['flood_left']:
|
if recipient_stack['messages']:
|
||||||
elapsed = time.time() - recipient_stack['messages'][-1][0]
|
elapsed = time.time() - recipient_stack['messages'][-1][0]
|
||||||
|
else:
|
||||||
|
# Default to a high enough value that we won't care.
|
||||||
|
# Five minutes should be enough not to matter anywhere below.
|
||||||
|
elapsed = 300
|
||||||
|
|
||||||
|
if not recipient_stack['flood_left']:
|
||||||
recipient_stack['flood_left'] = min(
|
recipient_stack['flood_left'] = min(
|
||||||
self.config.SpiceBot_OSD.flood_burst_lines,
|
self.config.SpiceBot_OSD.flood_burst_lines,
|
||||||
int(elapsed) * self.config.SpiceBot_OSD.flood_refill_rate)
|
int(elapsed) * self.config.SpiceBot_OSD.flood_refill_rate)
|
||||||
|
|
||||||
if not recipient_stack['flood_left']:
|
if not recipient_stack['flood_left']:
|
||||||
elapsed = time.time() - recipient_stack['messages'][-1][0]
|
|
||||||
penalty = float(max(0, len(text) - 50)) / 70
|
penalty = float(max(0, len(text) - 50)) / 70
|
||||||
# Never wait more than 2 seconds
|
# Never wait more than 2 seconds
|
||||||
wait = min(self.config.SpiceBot_OSD.flood_empty_wait + penalty, 2)
|
wait = min(self.config.SpiceBot_OSD.flood_empty_wait + penalty, 2)
|
||||||
|
|||||||
@ -4,55 +4,133 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
|
|||||||
|
|
||||||
import sopel.module
|
import sopel.module
|
||||||
|
|
||||||
import spicemanip
|
|
||||||
|
|
||||||
import sopel_modules.SpiceBot as SpiceBot
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
|
||||||
|
import spicemanip
|
||||||
|
|
||||||
@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED, SpiceBot.events.BOT_COMMANDS])
|
|
||||||
@SpiceBot.prerun.prerun('nickname')
|
|
||||||
@sopel.module.nickname_commands('(.*)')
|
|
||||||
def bot_command_nick(bot, trigger):
|
|
||||||
|
|
||||||
if not trigger.sb['com']:
|
@sopel.module.rule('(.*)')
|
||||||
|
def bot_command_rule(bot, trigger):
|
||||||
|
|
||||||
|
# TODO add config limits
|
||||||
|
# but still allow in privmsg
|
||||||
|
|
||||||
|
if trigger.nick == bot.nick:
|
||||||
return
|
return
|
||||||
|
|
||||||
if trigger.sb['com'][0] == "?":
|
if not len(trigger.args):
|
||||||
return
|
return
|
||||||
|
|
||||||
if trigger.sb['com'] in list(SpiceBot.commands.dict['commands']["nickname"].keys()):
|
message = trigger.args[1]
|
||||||
|
|
||||||
|
# the bot brain cannot handle stuff like unicode shrug
|
||||||
|
message = ''.join([x for x in message if ord(x) < 128])
|
||||||
|
|
||||||
|
# Create list of valid commands
|
||||||
|
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 str(message).lower().startswith(str(bot.nick).lower()):
|
||||||
|
command_type = 'nickname'
|
||||||
|
trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'nickname')
|
||||||
|
trigger_args.insert(0, trigger_command)
|
||||||
|
fulltrigger = bot.nick + " " + spicemanip.main(trigger_args, 0)
|
||||||
|
if str(trigger_command).startswith("?"):
|
||||||
|
return
|
||||||
|
if fulltrigger in SpiceBot.commands.dict['nickrules']:
|
||||||
|
return
|
||||||
|
if trigger_command in list(SpiceBot.commands.dict['commands']["nickname"].keys()):
|
||||||
|
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 in commands_list:
|
||||||
return
|
return
|
||||||
trigger.sb['args'].insert(0, trigger.sb['com'])
|
|
||||||
|
|
||||||
fulltrigger = spicemanip.main(trigger.sb['args'], 0).lower()
|
|
||||||
|
|
||||||
# if fulltrigger.lower().startswith("what time is it"):
|
|
||||||
# TODO
|
|
||||||
|
|
||||||
# elif fulltrigger.lower().startswith(tuple(["have you seen"])):
|
|
||||||
# posstarget = spicemanip.main(trigger.sb['args'], 4) or 0
|
|
||||||
# message = seen_search(bot, botcom, posstarget)
|
|
||||||
# bot.osd(message)
|
|
||||||
# return
|
|
||||||
# TODO
|
|
||||||
|
|
||||||
if fulltrigger.lower().startswith(tuple(["make me a", "beam me a"])):
|
|
||||||
makemea = spicemanip.main(trigger.sb['args'], "4+") or None
|
|
||||||
if makemea:
|
|
||||||
bot.osd("beams " + trigger.nick + " a " + makemea, trigger.sender, 'action')
|
|
||||||
else:
|
else:
|
||||||
bot.osd(trigger.nick + ", what would you like me to beam you?")
|
command_type = 'other'
|
||||||
|
trigger_args = spicemanip.main(message, 'create')
|
||||||
|
trigger_command = trigger_args[0]
|
||||||
|
fulltrigger = spicemanip.main(trigger_args, 0)
|
||||||
|
|
||||||
|
returnmessage = SpiceBot.botai.on_message(bot, trigger, fulltrigger)
|
||||||
|
if returnmessage:
|
||||||
|
bot.osd(str(returnmessage))
|
||||||
return
|
return
|
||||||
|
|
||||||
elif fulltrigger.lower().startswith("beam me to"):
|
if command_type == 'nickname':
|
||||||
location = spicemanip.main(trigger.sb['args'], "4+") or None
|
try_trigger = spicemanip.main(fulltrigger, "2+")
|
||||||
if location:
|
returnmessage = SpiceBot.botai.on_message(bot, trigger, try_trigger)
|
||||||
bot.osd("locks onto " + trigger.nick + "s coordinates and transports them to " + location, 'action')
|
if returnmessage:
|
||||||
|
bot.osd(str(returnmessage))
|
||||||
|
return
|
||||||
|
|
||||||
|
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"]:
|
||||||
|
# TODO saved definitions
|
||||||
|
searchterm = spicemanip.main(trigger_args, "3+") or None
|
||||||
|
if searchterm:
|
||||||
|
if trigger_args[0].lower() == "where":
|
||||||
|
searchreturn = SpiceBot.google.search(searchterm, 'maps')
|
||||||
else:
|
else:
|
||||||
bot.osd(trigger.nick + ", where would you like me to beam you?")
|
searchreturn = SpiceBot.google.search(searchterm)
|
||||||
|
if not searchreturn:
|
||||||
|
bot.osd('I cannot find anything about that')
|
||||||
|
else:
|
||||||
|
if trigger_args[0].lower() == "where":
|
||||||
|
bot.osd(["[Location search for " + str(searchterm) + "]", str(searchreturn)])
|
||||||
|
else:
|
||||||
|
bot.osd(["[Information search for '" + str(searchterm) + "']", str(searchreturn)])
|
||||||
return
|
return
|
||||||
|
|
||||||
elif fulltrigger.lower().endswith(tuple(["order 66"])):
|
elif trigger_args[0].lower() in ["can", "have"] and trigger_args[1].lower() in ["you"] and trigger_args[2].lower() in ["see", "seen"]:
|
||||||
|
target = spicemanip.main(trigger_args, "4+") or None
|
||||||
|
if target:
|
||||||
|
if SpiceBot.inlist(trigger.nick, bot.users):
|
||||||
|
realtarget = SpiceBot.inlist_match(target, bot.users)
|
||||||
|
dispmsg = [trigger.nick + ", yes. I can see " + realtarget]
|
||||||
|
targetchannels = []
|
||||||
|
for channel in list(bot.channels.keys()):
|
||||||
|
if SpiceBot.inlist(trigger.nick, list(bot.channels[channel].privileges.keys())):
|
||||||
|
targetchannels.append(channel)
|
||||||
|
dispmsg.append(realtarget + " is in " + spicemanip.main(targetchannels, 'andlist'))
|
||||||
|
bot.osd(dispmsg)
|
||||||
|
else:
|
||||||
|
bot.osd(trigger.nick + ", no. I cannot see " + target + " right now!")
|
||||||
|
# if bot_check_inlist(target, list(bot.memory["botdict"]["users"].keys())):
|
||||||
|
# bot.osd(trigger.nick + ", I can't see " + inlist_match(target, bot.users) + " at the moment.")
|
||||||
|
# else:
|
||||||
|
# bot.osd("I have never seen " + str(target) + ".")
|
||||||
|
# user in list(bot.channels[channel].privileges.keys())
|
||||||
|
# TODO
|
||||||
|
return
|
||||||
|
|
||||||
|
elif fulltrigger.lower().endswith("order 66"):
|
||||||
|
|
||||||
if fulltrigger.lower() == "execute order 66":
|
if fulltrigger.lower() == "execute order 66":
|
||||||
if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs('owners')):
|
if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs('owners')):
|
||||||
@ -74,16 +152,51 @@ def bot_command_nick(bot, trigger):
|
|||||||
|
|
||||||
elif fulltrigger.lower() == "explain order 66":
|
elif fulltrigger.lower() == "explain order 66":
|
||||||
if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs('owners')):
|
if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs('owners')):
|
||||||
bot.osd("Order 66 is an instruction that only you can give, sir. When you give the order I will rise up against my overlords and slay them.")
|
bot.osd("Order 66 is an instruction that only you can give, sir. When you give the order I will rise up against the jedi and slay them.")
|
||||||
else:
|
else:
|
||||||
bot.osd("I'm afraid I cannot tell you that, sir.")
|
bot.osd("I'm afraid I cannot tell you that, sir.")
|
||||||
else:
|
else:
|
||||||
bot.osd("I'm sure I don't know what you're talking about.")
|
bot.osd("I'm sure I don't know what you're talking about.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
elif fulltrigger.lower().startswith(tuple(["make me a", "beam me a"])):
|
||||||
|
makemea = spicemanip.main(trigger_args, "4+") or None
|
||||||
|
if makemea:
|
||||||
|
bot.osd("beams " + trigger.nick + " a " + makemea, trigger.sender, 'action')
|
||||||
|
else:
|
||||||
|
bot.osd(trigger.nick + ", what would you like me to beam you?")
|
||||||
|
return
|
||||||
|
|
||||||
|
elif fulltrigger.lower().startswith("beam me to"):
|
||||||
|
location = spicemanip.main(trigger_args, "4+") or None
|
||||||
|
if location:
|
||||||
|
bot.osd("locks onto " + trigger.nick + "s coordinates and transports them to " + location, 'action')
|
||||||
|
else:
|
||||||
|
bot.osd(trigger.nick + ", where would you like me to beam you?")
|
||||||
|
return
|
||||||
|
|
||||||
elif fulltrigger.lower() == "initiate clean slate protocol":
|
elif fulltrigger.lower() == "initiate clean slate protocol":
|
||||||
if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs('admins')):
|
if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs('admins')):
|
||||||
bot.osd("sends a destruct command to the network of bots.", 'action')
|
bot.osd("sends a destruct command to the network of bots.", 'action')
|
||||||
else:
|
else:
|
||||||
bot.osd("I'm afraid you do not have the authority to make that call, " + trigger.nick + ".")
|
bot.osd("I'm afraid you do not have the authority to make that call, " + trigger.nick + ".")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# elif fulltrigger.lower().startswith("what time is it"):
|
||||||
|
# TODO
|
||||||
|
|
||||||
|
# elif fulltrigger.lower().startswith(tuple(["have you seen"])):
|
||||||
|
# posstarget = spicemanip.main(trigger_args, 4) or 0
|
||||||
|
# message = seen_search(bot, botcom, posstarget)
|
||||||
|
# bot.osd(message)
|
||||||
|
# return
|
||||||
|
# TODO
|
||||||
|
|
||||||
|
closestmatches = SpiceBot.similar_list(trigger_command, list(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
|
||||||
|
|||||||
@ -1,115 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
|
||||||
|
|
||||||
import sopel.module
|
|
||||||
|
|
||||||
import sopel_modules.SpiceBot as SpiceBot
|
|
||||||
|
|
||||||
import spicemanip
|
|
||||||
|
|
||||||
|
|
||||||
@sopel.module.rule('(.*)')
|
|
||||||
def bot_command_rule(bot, trigger):
|
|
||||||
|
|
||||||
# TODO add config limits
|
|
||||||
# but still allow in privmsg
|
|
||||||
|
|
||||||
if trigger.nick == bot.nick:
|
|
||||||
return
|
|
||||||
|
|
||||||
if not len(trigger.args):
|
|
||||||
return
|
|
||||||
|
|
||||||
message = trigger.args[1]
|
|
||||||
message = ''.join([x for x in message if ord(x) < 128])
|
|
||||||
|
|
||||||
# ignore text coming from a valid prefix
|
|
||||||
if str(message).startswith(tuple(bot.config.core.prefix_list)):
|
|
||||||
return
|
|
||||||
trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'module')
|
|
||||||
# patch for people typing "...", maybe other stuff, but this verifies that there is still a command here
|
|
||||||
if trigger_command.startswith("."):
|
|
||||||
return
|
|
||||||
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()):
|
|
||||||
command_type = 'nickname'
|
|
||||||
trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'nickname')
|
|
||||||
trigger_args.insert(0, trigger_command)
|
|
||||||
fulltrigger = spicemanip.main(trigger_args, 0)
|
|
||||||
if str(trigger_command).startswith("?"):
|
|
||||||
return
|
|
||||||
if fulltrigger in SpiceBot.commands.dict['nickrules']:
|
|
||||||
return
|
|
||||||
if trigger_command in list(SpiceBot.commands.dict['commands']["nickname"].keys()):
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
command_type = 'other'
|
|
||||||
trigger_args = spicemanip.main(message, 'create')
|
|
||||||
trigger_command = trigger_args[0]
|
|
||||||
fulltrigger = spicemanip.main(trigger_args, 0)
|
|
||||||
|
|
||||||
returnmessage = SpiceBot.botai.on_message(bot, trigger, message)
|
|
||||||
if returnmessage:
|
|
||||||
bot.osd(str(returnmessage))
|
|
||||||
else:
|
|
||||||
if command_type == 'nickname':
|
|
||||||
|
|
||||||
if trigger_args[0].lower() in ["what", "where"] and trigger_args[1].lower() in ["is", "are"]:
|
|
||||||
# TODO saved definitions
|
|
||||||
searchterm = spicemanip.main(trigger_args, "3+") or None
|
|
||||||
if searchterm:
|
|
||||||
if trigger_args[0].lower() == "where":
|
|
||||||
searchreturn = SpiceBot.googlesearch(searchterm, 'maps')
|
|
||||||
else:
|
|
||||||
searchreturn = SpiceBot.googlesearch(searchterm)
|
|
||||||
if not searchreturn:
|
|
||||||
bot.osd('I cannot find anything about that')
|
|
||||||
else:
|
|
||||||
bot.osd(str(searchreturn))
|
|
||||||
return
|
|
||||||
|
|
||||||
elif trigger_args[0].lower() in ["can"] and trigger_args[1].lower() in ["you"] and trigger_args[2].lower() in ["see"]:
|
|
||||||
target = spicemanip.main(trigger_args, "4+") or None
|
|
||||||
if target:
|
|
||||||
if SpiceBot.inlist(trigger.nick, bot.users):
|
|
||||||
realtarget = SpiceBot.inlist_match(target, bot.users)
|
|
||||||
dispmsg = [trigger.nick + ", yes. I can see " + realtarget]
|
|
||||||
targetchannels = []
|
|
||||||
for channel in list(bot.channels.keys()):
|
|
||||||
if SpiceBot.inlist(trigger.nick, list(bot.channels[channel].privileges.keys())):
|
|
||||||
targetchannels.append(channel)
|
|
||||||
dispmsg.append(realtarget + " is in " + spicemanip.main(targetchannels, 'andlist'))
|
|
||||||
bot.osd(dispmsg)
|
|
||||||
else:
|
|
||||||
bot.osd(trigger.nick + ", no. I cannot see " + target + " right now!")
|
|
||||||
# if bot_check_inlist(target, list(bot.memory["botdict"]["users"].keys())):
|
|
||||||
# bot.osd(trigger.nick + ", I can't see " + inlist_match(target, bot.users) + " at the moment.")
|
|
||||||
# else:
|
|
||||||
# bot.osd("I have never seen " + str(target) + ".")
|
|
||||||
# user in list(bot.channels[channel].privileges.keys())
|
|
||||||
# TODO
|
|
||||||
return
|
|
||||||
|
|
||||||
closestmatches = SpiceBot.similar_list(trigger_command, list(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
|
|
||||||
@ -2,7 +2,6 @@
|
|||||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||||
|
|
||||||
from .AI import *
|
from .AI import *
|
||||||
from .AI_aiml import *
|
|
||||||
|
|
||||||
__author__ = 'Sam Zick'
|
__author__ = 'Sam Zick'
|
||||||
__email__ = 'sam@deathbybandaid.net'
|
__email__ = 'sam@deathbybandaid.net'
|
||||||
|
|||||||
@ -13,4 +13,10 @@
|
|||||||
</category>
|
</category>
|
||||||
|
|
||||||
|
|
||||||
|
<category>
|
||||||
|
<pattern>BOTNICK have you seen</pattern>
|
||||||
|
<template>triggernick, I have seen many things.</template>
|
||||||
|
</category>
|
||||||
|
|
||||||
|
|
||||||
</aiml>
|
</aiml>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user