add nickserv support
This commit is contained in:
parent
c9aa98d225
commit
82313c091e
|
@ -59,3 +59,4 @@ docs/_build/
|
||||||
target/
|
target/
|
||||||
|
|
||||||
venv/
|
venv/
|
||||||
|
account.ini
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
[nickserv]
|
||||||
|
username = bensbots
|
||||||
|
password = my super secret password
|
||||||
|
|
17
tracer.py
17
tracer.py
|
@ -22,6 +22,12 @@ config = configparser.ConfigParser(
|
||||||
config.read("config.ini")
|
config.read("config.ini")
|
||||||
bot = config["irc"]
|
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):
|
def grammar(rules):
|
||||||
try:
|
try:
|
||||||
|
@ -45,6 +51,7 @@ def populate():
|
||||||
DB = {}
|
DB = {}
|
||||||
for p in glob.glob("/home/*/.tracery/*"):
|
for p in glob.glob("/home/*/.tracery/*"):
|
||||||
name, ext = os.path.splitext(p)
|
name, ext = os.path.splitext(p)
|
||||||
|
name = os.path.basename(name)
|
||||||
if name.startswith(".") or ext not in (".json", ""):
|
if name.startswith(".") or ext not in (".json", ""):
|
||||||
continue
|
continue
|
||||||
if p in DB:
|
if p in DB:
|
||||||
|
@ -159,13 +166,16 @@ if __name__ == "__main__":
|
||||||
rawsend(f"JOIN {chan}")
|
rawsend(f"JOIN {chan}")
|
||||||
|
|
||||||
if "001" in msg:
|
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"):
|
for c in bot.getlist("channels"):
|
||||||
rawsend(f"JOIN {c}")
|
rawsend(f"JOIN {c}")
|
||||||
rawsend("MODE %s +B" % bot["nick"])
|
rawsend("MODE %s +B" % bot["nick"])
|
||||||
|
|
||||||
m = re.match(
|
m = re.match(":(?P<nick>[^ ]+)!.*PRIVMSG #(?P<chan>\w+) :(?P<msg>.*)", msg)
|
||||||
":(?P<nick>[^ ]+)!.*PRIVMSG #(?P<chan>\w+) :(?P<msg>.*)", msg
|
|
||||||
)
|
|
||||||
if m and m.groupdict():
|
if m and m.groupdict():
|
||||||
m = m.groupdict()
|
m = m.groupdict()
|
||||||
try:
|
try:
|
||||||
|
@ -174,4 +184,3 @@ if __name__ == "__main__":
|
||||||
print("ERROR" + str(m))
|
print("ERROR" + str(m))
|
||||||
print(e)
|
print(e)
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ After=tracer.service
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
WorkingDirectory=/home/ben/workspace/tracer
|
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
|
Restart=always
|
||||||
RestartSec=5
|
RestartSec=5
|
||||||
StartLimitInterval=60s
|
StartLimitInterval=60s
|
||||||
|
|
Loading…
Reference in New Issue