#bots = {'erebus': bot.Bot(nick='Erebus', user='erebus', bind='', server='irc.quakenet.org', port=6667, realname='Erebus')}
class Bot(object):
- def __init__(self, parent, nick, user, bind, server, port, realname):
+ def __init__(self, parent, nick, user, bind, authname, authpass, server, port, realname):
self.parent = parent
self.nick = nick
self.user = user
self.realname = realname
+ self.authname = authname
+ self.authpass = authpass
+
curs = self.parent.db.cursor()
if curs.execute("SELECT chname FROM chans WHERE bot = %s AND active = 1", (self.nick,)):
chansres = curs.fetchall()
if pieces[1] == "001":
self.conn.registered(True)
+ self.conn.send("MODE %s +x" % (pieces[2]))
+ if self.authname is not None and self.authpass is not None:
+ self.conn.send("AUTH %s %s" % (self.authname, self.authpass))
for c in self.chans:
self.join(c.name)
self.potype = "select"
self.fdlist = []
- def newbot(self, nick, user, bind, server, port, realname):
+ def newbot(self, nick, user, bind, authname, authpass, server, port, realname):
if bind is None: bind = ''
- obj = bot.Bot(self, nick, user, bind, server, port, realname)
+ obj = bot.Bot(self, nick, user, bind, authname, authpass, server, port, realname)
self.bots[nick.lower()] = obj
def newfd(self, obj, fileno):
dbsetup()
c = main.db.cursor()
- if c.execute("SELECT nick, user, bind FROM bots WHERE active = 1"):
+ if c.execute("SELECT nick, user, bind, authname, authpass FROM bots WHERE active = 1"):
rows = c.fetchall()
c.close()
for row in rows:
- main.newbot(row['nick'], row['user'], row['bind'], cfg.host, cfg.port, cfg.realname)
+ main.newbot(row['nick'], row['user'], row['bind'], row['authname'], row['authpass'], cfg.host, cfg.port, cfg.realname)
main.connectall()
def loop():