Renamed AI to AutomatedResponse
parent
994f79b7d5
commit
9a390d59ae
107
ai.py → aresp.py
107
ai.py → aresp.py
|
@ -1,32 +1,39 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
"""
|
"""
|
||||||
ai.py - Phenny AI Module (EXPERIMENTAL)
|
ai.py - Phenny AutomatedResponse Module
|
||||||
Copyright 2013, Sfan5
|
Copyright 2013, Sfan5
|
||||||
"""
|
"""
|
||||||
import random
|
import random, time
|
||||||
ai = {}
|
ai = {}
|
||||||
|
|
||||||
ai["enable"] = False
|
ar["enable"] = True
|
||||||
ai["bn"] = "minetestbot" #lowercase bot name
|
ar["bn"] = "minetestbot" #lowercase bot name
|
||||||
|
|
||||||
def aictl(phenny, input):
|
def arctl(phenny, input):
|
||||||
if not input.admin or not input.owner: return
|
if not input.admin or not input.owner: return
|
||||||
arg = input.group(2)
|
arg = input.group(2)
|
||||||
if not arg:
|
if not arg:
|
||||||
return
|
return
|
||||||
if arg == "enable":
|
if arg == "enable":
|
||||||
ai["enable"] = True
|
ar["enable"] = True
|
||||||
phenny.say("AI enabled.")
|
phenny.say("AR enabled.")
|
||||||
elif arg == "disable":
|
elif arg == "disable":
|
||||||
ai["enable"] = False
|
ar["enable"] = False
|
||||||
phenny.say("AI disabled.")
|
phenny.say("AR disabled.")
|
||||||
|
|
||||||
aictl.commands = ['ai']
|
arctl.commands = ['ar']
|
||||||
aictl.priority = 'low'
|
aictl.priority = 'low'
|
||||||
|
|
||||||
def aip(phenny, input):
|
def response(personal, nick, msg):
|
||||||
if not ai["enable"]:
|
if personal:
|
||||||
|
return msg
|
||||||
|
else:
|
||||||
|
return nick + ": " + msg
|
||||||
|
|
||||||
|
def arp(phenny, input):
|
||||||
|
if not ar["enable"]:
|
||||||
return
|
return
|
||||||
|
ar["lm"] = [input.nick, input.bytes.strip(), time.time()]
|
||||||
for x in phenny.bot.commands["high"].values():
|
for x in phenny.bot.commands["high"].values():
|
||||||
if x[0].__name__ == "aa_hook":
|
if x[0].__name__ == "aa_hook":
|
||||||
if x[0](phenny, input):
|
if x[0](phenny, input):
|
||||||
|
@ -36,7 +43,10 @@ def aip(phenny, input):
|
||||||
si = sia.__iter__()
|
si = sia.__iter__()
|
||||||
try:
|
try:
|
||||||
sn = si.next()
|
sn = si.next()
|
||||||
if sn.startswith("minetestbot"): sn = si.next()
|
personal = not input.sender.startswith("#")
|
||||||
|
if sn.startswith("minetestbot"):
|
||||||
|
sn = si.next()
|
||||||
|
personal = True
|
||||||
if sn == "hi" or sn == "hey" or sn == "hello":
|
if sn == "hi" or sn == "hey" or sn == "hello":
|
||||||
try:
|
try:
|
||||||
sn = si.next()
|
sn = si.next()
|
||||||
|
@ -48,33 +58,35 @@ def aip(phenny, input):
|
||||||
return phenny.reply("What are you wondering about?")
|
return phenny.reply("What are you wondering about?")
|
||||||
if sn == "thank":
|
if sn == "thank":
|
||||||
if si.next() == "you":
|
if si.next() == "you":
|
||||||
if si.next().startswith(ai["bn"]):
|
if si.next().startswith(ar["bn"]) or personal:
|
||||||
return phenny.reply("Although i'm only a bot I appreciate your thanks.")
|
return phenny.say(response(personal, input.nick, "Although i'm only a bot I appreciate your thanks."))
|
||||||
if sn == "thanks":
|
if sn == "thanks":
|
||||||
if si.next().startswith(ai["bn"]):
|
if si.next().startswith(ar["bn"]) or personal:
|
||||||
return phenny.reply("Although i'm only a bot I appreciate your thanks.")
|
return phenny.say(response(personal, input.nick, "Although i'm only a bot I appreciate your thanks."))
|
||||||
if sn == "back":
|
if sn == "back":
|
||||||
return phenny.reply("Welcome back!")
|
return phenny.say("Welcome back " + input.nick + "!")
|
||||||
if sn == "should":
|
if sn == "should":
|
||||||
sn == si.next()
|
sn = si.next()
|
||||||
if sn == "i":
|
if sn == "i":
|
||||||
sn = si.next()
|
sn = si.next()
|
||||||
if sn == "eat" or sn == "drink":
|
if sn == "eat" or sn == "drink":
|
||||||
sn = si.next()
|
sn = si.next()
|
||||||
if sn == "a" or sn == "an" or sn == "the": sn = si.next()
|
if sn == "a" or sn == "an" or sn == "the": sn = si.next()
|
||||||
if sn == "kitty" or sn.startswith("kitten") or sn.startswith("cat"):
|
if sn == "kitty" or sn.startswith("kitte") or sn.startswith("cat"):
|
||||||
return phenny.reply("I don't recommend eating kittens")
|
return phenny.reply("I don't recommend eating kittens")
|
||||||
elif sn == "air":
|
elif sn == "air":
|
||||||
return phenny.reply("Eating air won't hurt you")
|
return phenny.reply("Eating air won't hurt you")
|
||||||
elif sn == "bot" or sn == ai["bn"] or sn == "you":
|
elif sn == "bot" or sn == ar["bn"] or (sn == "you" and personal):
|
||||||
return phenny.reply("Don't eat me D:")
|
return phenny.reply("Don't eat me D:")
|
||||||
|
elif sn == "acid":
|
||||||
|
return phenny.say(response(personal, input.nick, "Don't!!"))
|
||||||
else:
|
else:
|
||||||
return phenny.reply("If it's acid, no, otherwise yes")
|
return phenny.reply("You decide")
|
||||||
if sn == "\x01action":
|
if sn == "\x01action":
|
||||||
sn = si.next()
|
sn = si.next()
|
||||||
if sn == "hugs":
|
if sn == "hugs":
|
||||||
sn = si.next()
|
sn = si.next()
|
||||||
if sn != ai["bn"] and random.randint(0,3) == 0:
|
if sn != ar["bn"] and random.randint(0,3) == 0:
|
||||||
return phenny.say("Can I get a hug too? Please")
|
return phenny.say("Can I get a hug too? Please")
|
||||||
else:
|
else:
|
||||||
return phenny.reply(" :D")
|
return phenny.reply(" :D")
|
||||||
|
@ -83,12 +95,16 @@ def aip(phenny, input):
|
||||||
if sn == "a" or sn == "an" or sn == "the": sn = si.next()
|
if sn == "a" or sn == "an" or sn == "the": sn = si.next()
|
||||||
r = sn
|
r = sn
|
||||||
sn = si.next()
|
sn = si.next()
|
||||||
if sn == "on" or sn == "under" or sn == "behind":
|
if sn == "on" or sn == "under" or sn == "behind" or sn == "in" or sn == "above":
|
||||||
sn = si.next()
|
sn = si.next()
|
||||||
if sn.startswith(ai["bn"]):
|
if sn.startswith(ar["bn"]):
|
||||||
if r.startswith("kitt") or r.startswith("cat"):
|
if r.startswith("kitt") or r.startswith("cat"):
|
||||||
return phenny.reply("I don't want it, talk to NekoGloop, he likes kittens")
|
return phenny.reply("I don't want it, talk to NekoGloop, he likes kittens")
|
||||||
|
elif r.startswith("pupp") or r.startswith("dog"):
|
||||||
|
return phenny.reply("Awwwww....")
|
||||||
elif r.startswith("bomb") or r.startswith("explosive") or r.startswith("dynamite"):
|
elif r.startswith("bomb") or r.startswith("explosive") or r.startswith("dynamite"):
|
||||||
|
if random.randint(0,3) == 0:
|
||||||
|
return phenny.say("*shoots " + input.nick + " with an AK-74*")
|
||||||
return phenny.say("*runs away*")
|
return phenny.say("*runs away*")
|
||||||
elif r.startswith("cookie") or r.startswith("cake"):
|
elif r.startswith("cookie") or r.startswith("cake"):
|
||||||
return phenny.say("Ooh! thank you, nom nom nom...")
|
return phenny.say("Ooh! thank you, nom nom nom...")
|
||||||
|
@ -106,21 +122,36 @@ def aip(phenny, input):
|
||||||
if sn == "compile":
|
if sn == "compile":
|
||||||
sn = si.next()
|
sn = si.next()
|
||||||
if sn == "minetest":
|
if sn == "minetest":
|
||||||
return phenny.reply("There is a detailed guide at https://raw.github.com/celeron55/minetest/master/README.txt for compiling minetest on windows and linux, if you have a mac.. ..no luck")
|
return phenny.say(response(personal, input.nick, "There is a detailed guide at https://raw.github.com/celeron55/minetest/master/README.txt for compiling minetest on windows and linux, if you have a mac.. ..no luck"))
|
||||||
if sn == "install":
|
if sn == "install":
|
||||||
sn = si.next()
|
sn = si.next()
|
||||||
if sn == "a" or sn == "an": sn = si.next()
|
if sn == "a" or sn == "an": sn = si.next()
|
||||||
if sn.startswith("mod"):
|
if sn.startswith("mod"):
|
||||||
return phenny.reply("You can usually find installation instruction in the mod topic, http://wiki.minetest.com/wiki/Mods also describes how to install mods")
|
return phenny.say(response(personal, input.nick, "You can usually find installation instruction in the mod topic, http://wiki.minetest.com/wiki/Mods also describes how to install mods"))
|
||||||
if sn == "texture":
|
if sn == "texture":
|
||||||
if si.next().startswith("pack"):
|
if si.next().startswith("pack"):
|
||||||
return phenny.reply("http://wiki.minetest.com/wiki/Texture_Packs provides a good guide on how to install texture packs")
|
return phenny.say(response(personal, input.nick, "http://wiki.minetest.com/wiki/Texture_Packs provides a good guide on how to install texture packs"))
|
||||||
if sn == "craft":
|
if sn == "craft":
|
||||||
sn = si.next()
|
sn = si.next()
|
||||||
if sn == "a" or sn == "an" or sn.endswith("s"):
|
if sn == "a" or sn == "an" or sn.endswith("s"):
|
||||||
return phenny.reply("Take a look at http://wiki.minetest.com/wiki/Crafting ,you should find it there")
|
return phenny.say(response(personal, input.nick, "Take a look at http://wiki.minetest.com/wiki/Crafting ,you should find it there"))
|
||||||
if sn == "where":
|
if sn == "where":
|
||||||
sn = si.next()
|
sn = si.next()
|
||||||
|
r = (False, 0)
|
||||||
|
if sn == "are" or sn == "is":
|
||||||
|
r = (True, 0)
|
||||||
|
if sn == "do" or sn == "did":
|
||||||
|
r = (True, 1)
|
||||||
|
if r[0]:
|
||||||
|
sn = si.next()
|
||||||
|
if (sn == "you" and personal) or (sn == ar["bn"] and not personal):
|
||||||
|
sn = si.next()
|
||||||
|
if sn == "come" and r[1] == 1: sn = si.next()
|
||||||
|
if sn == "from":
|
||||||
|
if random.randint(0,5) == 0:
|
||||||
|
return phenny.say(response(personal, input.nick, "I'm from the Bot Universe and i'm going to destroy you... BEEP BOOP BLEEP BOOP"))
|
||||||
|
else:
|
||||||
|
return phenny.say(response(personal, input.nick, "I come from https://github.com/sfan5/minetestbot-modules"))
|
||||||
if sn == "can" or sn == "could" or sn == "to":
|
if sn == "can" or sn == "could" or sn == "to":
|
||||||
sn = si.next()
|
sn = si.next()
|
||||||
if sn == "i": sn = si.next()
|
if sn == "i": sn = si.next()
|
||||||
|
@ -135,24 +166,24 @@ def aip(phenny, input):
|
||||||
try:
|
try:
|
||||||
sn = si.next()
|
sn = si.next()
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
return phenny.reply("http://www.minetest.net/download.php Please note that it is recommend to compile Minetest yourself if you use GNU/Linux")
|
return phenny.say(response(personal, input.nick, "http://www.minetest.net/download.php Please note that it is recommend to compile Minetest yourself if you use GNU/Linux"))
|
||||||
if sn.startswith("mod"):
|
if sn.startswith("mod"):
|
||||||
return phenny.reply("http://forum.minetest.net/viewforum.php?id=11")
|
return phenny.say(response(personal, input.nick, "http://forum.minetest.net/viewforum.php?id=11"))
|
||||||
if sn.startswith("texture"):
|
if sn.startswith("texture"):
|
||||||
if si.next().startswith("pack"):
|
if si.next().startswith("pack"):
|
||||||
return phenny.reply("http://forum.minetest.net/viewforum.php?id=4")
|
return phenny.say(response(personal, input.nick, "http://forum.minetest.net/viewforum.php?id=4"))
|
||||||
if sn.startswith("server") and r[1] == 1:
|
if sn.startswith("server") and r[1] == 1:
|
||||||
return phenny.reply("http://forum.minetest.net/viewforum.php?id=10 and http://servers.minetest.ru")
|
return phenny.say(response(personal, input.nick, "http://forum.minetest.net/viewforum.php?id=10 and http://servers.minetest.ru"))
|
||||||
elif sn.startswith("server") and r[1] == 0:
|
elif sn.startswith("server") and r[1] == 0:
|
||||||
return phenny.reply("Download Minetest at http://www.minetest.net/download.php and run 'minetest.exe --server' to start a server instance")
|
return phenny.say(response(personal, input.nick, "Download Minetest at http://www.minetest.net/download.php and run 'minetest.exe --server' to start a server instance"))
|
||||||
if sn.startswith("map"):
|
if sn.startswith("map"):
|
||||||
return phenny.reply("http://forum.minetest.net/viewforum.php?id=12")
|
return phenny.say(response(personal, input.nick, "http://forum.minetest.net/viewforum.php?id=12"))
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
|
|
||||||
aip.priority = 'medium'
|
arp.priority = 'medium'
|
||||||
aip.rule = r'.*'
|
arp.rule = r'.*'
|
||||||
aip.event = '*'
|
arp.event = '*'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print __doc__.strip()
|
print __doc__.strip()
|
Loading…
Reference in New Issue