#!/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):
+# Erebus IRC bot - Author: John Runyon
+# "Config" class (reading/providing access to bot.config)
+
import ConfigParser
class Config(object):
+# Erebus IRC bot - Author: John Runyon
+# module loading/unloading/tracking code
+
import sys
import modlib
#!/usr/bin/python
+# Erebus IRC bot - Author: John Runyon
+# main startup code
+
#TODO: tons
import os, sys, select, MySQLdb, MySQLdb.cursors
+# Erebus IRC bot - Author: John Runyon
+# module helper functions, see modules/modtest.py for usage
+# This file is released into the public domain; see http://unlicense.org/
+
class error(object):
def __init__(self, desc):
self.errormsg = desc
return self.errormsg
class modlib(object):
+ #access levels
+ MANAGER = 3
+ ADMIN = 2
+ STAFF = 1
+ AUTHED = 0
+ ANYONE = -1
+
def __init__(self, name):
self.hooks = {}
self.parent = None
+# Erebus IRC bot - Author: John Runyon
+# !EVAL and !EXEC commands
+
# module info
modinfo = {
'author': 'John Runyon (DimeCadmium)',
import sys
-@lib.hook('eval')
+@lib.hook('eval', lib.MANAGER)
def cmd_eval(bot, user, chan, *args):
try: ret = eval(' '.join(args))
except: bot.msg(chan, "Error (%s): %s" % (sys.exc_info()[0], sys.exc_info()[1]))
else: bot.msg(chan, "Done: %r" % (ret))
-@lib.hook('exec')
+@lib.hook('exec', lib.MANAGER)
def cmd_exec(bot, user, chan, *args):
try: exec ' '.join(args)
except: bot.msg(chan, "Error: %s %s" % (sys.exc_info()[0], sys.exc_info()[1]))
+# Erebus IRC bot - Author: John Runyon
+# simple module example
+# This file is released into the public domain; see http://unlicense.org/
+
# module info
modinfo = {
'author': 'John Runyon (DimeCadmium)',
#!/bin/sh
+# Erebus IRC bot - Author: John Runyon
+# Startup script
+
python -B "$(dirname $(readlink -f $0))/erebus.py"