Adding the halbot module

master
Dafydd Crosby 2011-06-04 09:36:47 -06:00
parent 78ec273046
commit 2a03d0e065
1 changed files with 27 additions and 0 deletions

27
modules/halbot.py Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env python
"""
halbot.py - A module to connect to Halpy AI module
Copyright (c) 2011 Dafydd Crosby - http://www.dafyddcrosby.com
Licensed under the Eiffel Forum License 2.
"""
from megahal import *
megahal = MegaHAL()
def learn(phenny,input):
"""Listens in on the room, gradually learning new phrases"""
megahal.learn(input.group())
learn.rule = r'(.*)'
learn.priority = 'low'
def megahalbot(phenny, input):
"""Responds when someone mentions the bot nickname"""
# Clean the input so Halpy does not get confused
inp = input.group().replace(phenny.nick,'')
inp = inp.replace("\'","")
inp = inp.replace("\"","")
phenny.say(input.nick + ": " + megahal.get_reply(inp))
megahal.sync()
megahalbot.rule = r'(.*)$nickname(.*)'
megahalbot.priority = 'low'