]> jfr.im git - erebus.git/commitdiff
added code to AUTH and +x
authorzonidjan <redacted>
Thu, 27 Aug 2015 12:39:39 +0000 (07:39 -0500)
committerzonidjan <redacted>
Thu, 27 Aug 2015 12:39:39 +0000 (07:39 -0500)
bot.py
erebus.py

diff --git a/bot.py b/bot.py
index ca7dc37e6f7a1ad13eed7897d9a6ee1dae6976cb..fe9be344525fa60a2a7bbdd47f53eb382f3a7236 100644 (file)
--- a/bot.py
+++ b/bot.py
@@ -9,12 +9,15 @@ import socket, sys
 
 #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()
@@ -43,6 +46,9 @@ class Bot(object):
 
                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)
 
index c1ac5d054a97fcba44d7fd6f1dc2514ca1bf1dfd..94e9c3ae99027573ffa77f0f4afc07f148ecc5a6 100644 (file)
--- a/erebus.py
+++ b/erebus.py
@@ -130,9 +130,9 @@ class Erebus(object):
                        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):
@@ -256,11 +256,11 @@ def setup():
 
        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():