- main.newbot('Erebus', 'erebus', None, 'irc.quakenet.org', 6667, 'Erebus', ['#dimetest'])
- main.bot('erebus').connect()
+ main.db = MySQLdb.connect(host=cfg.dbhost, user=cfg.dbuser, passwd=cfg.dbpass, db=cfg.dbname, cursorclass=MySQLdb.cursors.DictCursor)
+ c = main.db.cursor()
+ c.execute("SELECT nick, user, bind FROM bots WHERE active = 1")
+ rows = c.fetchall()
+ c.close()
+ for row in rows:
+ c2 = main.db.cursor()
+ c2.execute("SELECT chname FROM chans WHERE bot = %s AND active = 1", (row['nick'],))
+ chans = [chdic['chname'] for chdic in c2.fetchall()]
+ c2.close()
+ main.newbot(row['nick'], row['user'], row['bind'], cfg.host, cfg.port, cfg.realname, chans)
+ main.connectall()