From 526dca8c86677192c51341fb16392615acd5faeb Mon Sep 17 00:00:00 2001 From: jan6 Date: Mon, 7 Feb 2022 18:28:19 +0200 Subject: [PATCH] added nickserv auth --- .gitignore | 1 + commands.py | 21 +++++++++++---------- config.py | 7 +++++-- stuff.py | 7 +++++++ youtube.py | 8 +++++--- 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 4521c9a..535b467 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ venv +pass.txt # ---> Python # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/commands.py b/commands.py index 1942057..09d4a6a 100644 --- a/commands.py +++ b/commands.py @@ -228,15 +228,16 @@ class Command: @cmd def weather(self, prefix, cmd, pm, line, admin, mesg): """crude weather command""" - cmd=" ".join(cmd.split(" ", 1)[1:]) - loc=cmd.split("?")[0].strip() + cmd = " ".join(cmd.split(" ", 1)[1:]) + loc = cmd.split("?")[0].strip() - mf="m" #celsius by default - if(len(cmd.split("?"))>=2): - argsplit=cmd.split("?")[1].split() - if "f" in argsplit or "u" in argsplit: mf="u" #farenheit - a=__import__("http.client").client.HTTPSConnection("wttr.in") - a.request("GET",f"/{loc}?A&T&0&n&F&{mf}") - b=a.getresponse().read().decode("utf-8") + mf = "m" # celsius by default + if len(cmd.split("?")) >= 2: + argsplit = cmd.split("?")[1].split() + if "f" in argsplit or "u" in argsplit: + mf = "u" # farenheit + a = __import__("http.client").client.HTTPSConnection("wttr.in") + a.request("GET", f"/{loc}?A&T&0&n&F&{mf}") + b = a.getresponse().read().decode("utf-8") mesg(" ".join(b.split("\n")[3].strip().split(" ")[-2:])) - #mesg(cmd.split(" ", 1)[1]) + # mesg(cmd.split(" ", 1)[1]) diff --git a/config.py b/config.py index 3a04eed..4187618 100644 --- a/config.py +++ b/config.py @@ -1,7 +1,7 @@ class config: class self: nick = "bot6" - username = "jan6_bot" #you can set it to your username + username = "jan6_bot" # you can set it to your username realname = "jan6's bot" source = "https://tildegit.org/jan6/bot6" @@ -10,8 +10,11 @@ class config: host = "irc.libera.chat" port = 6697 ssl = True + nickserv_auth = True + # get password from secret file + nickserv_pass = open("pass.txt", "r").read().strip() channel = "##jan6" - autojoin = ["##share","#1337331"] + autojoin = ["##share", "#1337331", "#opsec"] class admin: accounts = ["jan6"] diff --git a/stuff.py b/stuff.py index d3ca040..8edc5d5 100755 --- a/stuff.py +++ b/stuff.py @@ -79,6 +79,13 @@ def stuff(bot, sock): send(f"PONG :{line.params[0]}") if mode == "init": + if line.command == "NOTICE": + if line.source.startswith("NickServ!NickServ@"): + if config.server.nickserv_auth == True: + mesg( + f"IDENTIFY {config.self.nick} {config.server.nickserv_pass}", + line.source.split("!")[0], + ) if line.command == "433": util.nick(config.self.nick + "_") if line.command == "376": diff --git a/youtube.py b/youtube.py index 240ac93..06760d6 100644 --- a/youtube.py +++ b/youtube.py @@ -29,13 +29,15 @@ class YouTube: h = m // 60 m = round((m / 60 - h) * 60) return f"{h}h {m}m {s}s" - elif h==0 and m==0 and s==0: return "LIVE" - elif m==0 and s!=0: return f"{s}s" + elif h == 0 and m == 0 and s == 0: + return "LIVE" + elif m == 0 and s != 0: + return f"{s}s" else: return f"{m}m {s}s" def yt(self, url): - url=url.rstrip("\x01") + url = url.rstrip("\x01") global y, z y, z = {}, {} p = self.parseprop()