From 82313c091e3049fc9cb65a155934abc2d852c64e Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Mon, 24 Feb 2020 11:32:56 -0500 Subject: add nickserv support --- tracer.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'tracer.py') diff --git a/tracer.py b/tracer.py index bef3ee0..196bed7 100644 --- a/tracer.py +++ b/tracer.py @@ -22,6 +22,12 @@ config = configparser.ConfigParser( config.read("config.ini") bot = config["irc"] +# read account info if it exists +if os.path.isfile("account.ini"): + account = configparser.ConfigParser() + account.read("account.ini") + account = account["nickserv"] + def grammar(rules): try: @@ -45,6 +51,7 @@ def populate(): DB = {} for p in glob.glob("/home/*/.tracery/*"): name, ext = os.path.splitext(p) + name = os.path.basename(name) if name.startswith(".") or ext not in (".json", ""): continue if p in DB: @@ -159,13 +166,16 @@ if __name__ == "__main__": rawsend(f"JOIN {chan}") if "001" in msg: + if account is not None: + rawsend( + "SQUERY NickServ IDENTIFY %s %s" + % (account["username"], account["password"]) + ) for c in bot.getlist("channels"): rawsend(f"JOIN {c}") rawsend("MODE %s +B" % bot["nick"]) - m = re.match( - ":(?P[^ ]+)!.*PRIVMSG #(?P\w+) :(?P.*)", msg - ) + m = re.match(":(?P[^ ]+)!.*PRIVMSG #(?P\w+) :(?P.*)", msg) if m and m.groupdict(): m = m.groupdict() try: @@ -174,4 +184,3 @@ if __name__ == "__main__": print("ERROR" + str(m)) print(e) traceback.print_exc() - -- cgit 1.4.1