]> jfr.im git - erebus.git/blobdiff - bot.py
Putting header on files
[erebus.git] / bot.py
diff --git a/bot.py b/bot.py
index 50456b5d1cebaf9a6250d06b8f00c1bf690f3c04..68cd8aeb0416522f2f78b6c40ef865d711c86b1e 100644 (file)
--- a/bot.py
+++ b/bot.py
@@ -1,5 +1,8 @@
 #!/usr/bin/python
 
+# Erebus IRC bot - Author: John Runyon
+# "Bot" and "BotConnection" classes (handling a specific "arm")
+
 #TODO: error checking
 
 import socket, sys
@@ -15,7 +18,8 @@ class Bot(object):
 
                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):
@@ -56,24 +60,14 @@ class Bot(object):
        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))