diff options
author | Ben Harris <ben@tilde.team> | 2020-02-24 11:32:56 -0500 |
---|---|---|
committer | Ben Harris <ben@tilde.team> | 2020-02-24 11:32:56 -0500 |
commit | 82313c091e3049fc9cb65a155934abc2d852c64e (patch) | |
tree | c6fe24392a3435a6479de557d2a194a92768236b | |
parent | c9aa98d2258ccdb7a72b39956233e30373ae5b41 (diff) |
add nickserv support irctokens
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | account.ini.sample | 4 | ||||
-rw-r--r-- | tracer.py | 17 | ||||
-rw-r--r-- | tracer.service | 2 |
4 files changed, 19 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore index 6969ff3..876898e 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,4 @@ docs/_build/ target/ venv/ +account.ini diff --git a/account.ini.sample b/account.ini.sample new file mode 100644 index 0000000..7dcf1af --- /dev/null +++ b/account.ini.sample @@ -0,0 +1,4 @@ +[nickserv] +username = bensbots +password = my super secret password + 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<nick>[^ ]+)!.*PRIVMSG #(?P<chan>\w+) :(?P<msg>.*)", msg - ) + m = re.match(":(?P<nick>[^ ]+)!.*PRIVMSG #(?P<chan>\w+) :(?P<msg>.*)", 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() - diff --git a/tracer.service b/tracer.service index 1924bd1..5a7e0fa 100644 --- a/tracer.service +++ b/tracer.service @@ -5,7 +5,7 @@ After=tracer.service [Service] Type=simple WorkingDirectory=/home/ben/workspace/tracer -ExecStart=/home/ben/workspace/tracer/venv/bin/python3 /home/ben/workspace/tracer/tracer.py +ExecStart=/home/ben/workspace/tracer/venv/bin/python3 tracer.py Restart=always RestartSec=5 StartLimitInterval=60s |