crude refactor to allow re-authing with nickserv if lost auth (e.g. some netsplits/server maintenances)

This commit is contained in:
jan6 2022-08-30 02:35:21 +03:00
parent 2d6d86fdb7
commit e07f7bfe68
2 changed files with 18 additions and 8 deletions

View File

@ -95,7 +95,7 @@ class Command:
def preq_cmd(self): # command prequisites / triggers
cmd = self.line
#self.mesg(f"attempting command: {cmd}")
# self.mesg(f"attempting command: {cmd}")
if cmd == "help" or cmd.startswith("help "):
command = "help"
elif cmd.startswith("echo "):
@ -108,7 +108,7 @@ class Command:
command = "dbg"
elif cmd == "dbg2" or cmd.startswith("dbg2 "):
command = "dbg2"
elif cmd.startswith("yt ") or self.YouTube.match_urls(self.YouTube,cmd)!=[]:
elif cmd.startswith("yt ") or self.YouTube.match_urls(self.YouTube, cmd) != []:
command = "yt"
elif cmd.startswith("\x01") or self.is_ctcp:
command = "ctcp"
@ -153,7 +153,7 @@ class Command:
if cmd.startswith("yt "):
cmd = cmd[3:]
# cmd=cmd.split()[0]
urls = YouTube.match_urls(YouTube,cmd)
urls = YouTube.match_urls(YouTube, cmd)
for video in urls:
try:
a = YouTube.yt(YouTube, video)

View File

@ -25,6 +25,15 @@ def stuff(bot, sock):
is_pm = False
mode = "init"
def auth(
nick=config.self.nick,
passwd=config.server.nickserv_pass,
auth="nickserv",
):
if auth.lower() == "nickserv": # line.source.split("!")[0]
# TODO: on most network can probably do "PRIVMSG NickServ@services. :help"
util.mesg(f"IDENTIFY {nick} {passwd}", "NickServ")
def configure():
config = importlib.reload(sys.modules["config"]).config
util = Util(config, sock)
@ -85,10 +94,11 @@ def stuff(bot, sock):
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],
)
auth()
# mesg(
# f"IDENTIFY {config.self.nick} {config.server.nickserv_pass}",
# line.source.split("!")[0],
# )
if line.command == "433": # 433 is ERR_NICKNAMEINUSE
util.nick(config.self.nick + "_")
if (
@ -141,7 +151,7 @@ def stuff(bot, sock):
or cmd[0] in prefixes
or "https://" in cmd
or "http://" in cmd
# or cmd.startswith("https://")
# or cmd.startswith("https://")
):
try:
# if message in a channel, remove prefixes