added nickserv auth

This commit is contained in:
jan6 2022-02-07 18:28:19 +02:00
parent d39b1fddbc
commit 526dca8c86
5 changed files with 29 additions and 15 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
venv venv
pass.txt
# ---> Python # ---> Python
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/

View File

@ -228,15 +228,16 @@ class Command:
@cmd @cmd
def weather(self, prefix, cmd, pm, line, admin, mesg): def weather(self, prefix, cmd, pm, line, admin, mesg):
"""crude weather command""" """crude weather command"""
cmd=" ".join(cmd.split(" ", 1)[1:]) cmd = " ".join(cmd.split(" ", 1)[1:])
loc=cmd.split("?")[0].strip() loc = cmd.split("?")[0].strip()
mf="m" #celsius by default mf = "m" # celsius by default
if(len(cmd.split("?"))>=2): if len(cmd.split("?")) >= 2:
argsplit=cmd.split("?")[1].split() argsplit = cmd.split("?")[1].split()
if "f" in argsplit or "u" in argsplit: mf="u" #farenheit if "f" in argsplit or "u" in argsplit:
a=__import__("http.client").client.HTTPSConnection("wttr.in") mf = "u" # farenheit
a.request("GET",f"/{loc}?A&T&0&n&F&{mf}") a = __import__("http.client").client.HTTPSConnection("wttr.in")
b=a.getresponse().read().decode("utf-8") 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(" ".join(b.split("\n")[3].strip().split(" ")[-2:]))
#mesg(cmd.split(" ", 1)[1]) # mesg(cmd.split(" ", 1)[1])

View File

@ -1,7 +1,7 @@
class config: class config:
class self: class self:
nick = "bot6" 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" realname = "jan6's bot"
source = "https://tildegit.org/jan6/bot6" source = "https://tildegit.org/jan6/bot6"
@ -10,8 +10,11 @@ class config:
host = "irc.libera.chat" host = "irc.libera.chat"
port = 6697 port = 6697
ssl = True ssl = True
nickserv_auth = True
# get password from secret file
nickserv_pass = open("pass.txt", "r").read().strip()
channel = "##jan6" channel = "##jan6"
autojoin = ["##share","#1337331"] autojoin = ["##share", "#1337331", "#opsec"]
class admin: class admin:
accounts = ["jan6"] accounts = ["jan6"]

View File

@ -79,6 +79,13 @@ def stuff(bot, sock):
send(f"PONG :{line.params[0]}") send(f"PONG :{line.params[0]}")
if mode == "init": 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": if line.command == "433":
util.nick(config.self.nick + "_") util.nick(config.self.nick + "_")
if line.command == "376": if line.command == "376":

View File

@ -29,13 +29,15 @@ class YouTube:
h = m // 60 h = m // 60
m = round((m / 60 - h) * 60) m = round((m / 60 - h) * 60)
return f"{h}h {m}m {s}s" return f"{h}h {m}m {s}s"
elif h==0 and m==0 and s==0: return "LIVE" elif h == 0 and m == 0 and s == 0:
elif m==0 and s!=0: return f"{s}s" return "LIVE"
elif m == 0 and s != 0:
return f"{s}s"
else: else:
return f"{m}m {s}s" return f"{m}m {s}s"
def yt(self, url): def yt(self, url):
url=url.rstrip("\x01") url = url.rstrip("\x01")
global y, z global y, z
y, z = {}, {} y, z = {}, {}
p = self.parseprop() p = self.parseprop()