#!/usr/bin/python
+# Erebus IRC bot - Author: John Runyon
+# "Bot" and "BotConnection" classes (handling a specific "arm")
+
#TODO: error checking
import socket, sys
self.conn = BotConnection(self, bind, server, port)
def connect(self):
- if self.conn.connect():
+
+if self.conn.connect():
self.parent.newfd(self, self.conn.socket.fileno())
def getdata(self):
def parsemsg(self, user, chan, msg):
if msg[0] == '!': #TODO check config for trigger
msg = msg[1:]
-
else:
return
pieces = msg.split()
- cmd = pieces[0].upper()
-
- if cmd == "EVAL":
- try: ret = eval(' '.join(pieces[1:]))
- except: self.msg(chan, "Error: %s %s" % (sys.exc_info()[0], sys.exc_info()[1]))
- else: self.msg(chan, "Done: %r" % (ret))
-
- elif cmd == "EXEC":
- try: exec ' '.join(pieces[1:])
- except: self.msg(chan, "Error: %s %s" % (sys.exc_info()[0], sys.exc_info()[1]))
- else: self.msg(chan, "Done.")
+ cmd = pieces[0].lower()
- #TODO
+ if self.parent.hashook(cmd):
+ self.parent.gethook(cmd)(self, user, chan, *pieces[1:])
def msg(self, target, msg):
if isinstance(target, self.parent.User): self.conn.send("NOTICE %s :%s" % (target.nick, msg))