squery nickserv when possible
This commit is contained in:
parent
6bdd3915e1
commit
f7a7dc40dc
|
@ -26,6 +26,7 @@ class config(config):
|
|||
nickserv_mask = (
|
||||
"NickServ!NickServ@services.libera.chat" # the mask you receive from server
|
||||
)
|
||||
nickserv_squery = True
|
||||
nickserv_path = "NickServ@services." # the mask you actually send commands to
|
||||
# get password from secret file
|
||||
nickserv_pass = open("pass.txt", "r").read().strip()
|
||||
|
|
30
stuff.py
30
stuff.py
|
@ -37,12 +37,25 @@ def stuff(bot, sock):
|
|||
# TODO: on most network can probably do "PRIVMSG NickServ@services. :help"
|
||||
# TODO: support actually checking the nickserv mask properly
|
||||
if nickserv_auth:
|
||||
util.mesg(f"IDENTIFY {nick} {passwd}", config.server.nickserv_path)
|
||||
nick_override = True
|
||||
util.mesg(
|
||||
f"{config.server.nickserv_recover} {nick}",
|
||||
config.server.nickserv_path,
|
||||
)
|
||||
if config.server.nickserv_squery:
|
||||
util.send(
|
||||
irctokens.build(
|
||||
"SQUERY", ["NickServ", f"IDENTIFY {nick} {passwd}"]
|
||||
).format()
|
||||
)
|
||||
util.send(
|
||||
irctokens.build(
|
||||
"SQUERY",
|
||||
["NickServ", f"{config.server.nickserv_recover} {nick}"],
|
||||
).format()
|
||||
)
|
||||
else:
|
||||
util.mesg(f"IDENTIFY {nick} {passwd}", config.server.nickserv_path)
|
||||
util.mesg(
|
||||
f"{config.server.nickserv_recover} {nick}",
|
||||
config.server.nickserv_path,
|
||||
)
|
||||
# attempt to re-nick just in case
|
||||
send(irctokens.build("NICK", [config.self.nick]).format())
|
||||
|
||||
|
@ -107,15 +120,10 @@ def stuff(bot, sock):
|
|||
send(f"PONG :{line.params[0]}")
|
||||
|
||||
if mode == "init":
|
||||
if line.command == "NOTICE":
|
||||
# if line.source.startswith("NickServ!"):
|
||||
if line.command == "NOTICE" and line.source != None:
|
||||
if util.maskmatch(line.source, config.server.nickserv_mask):
|
||||
if config.server.nickserv_auth == True:
|
||||
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 (
|
||||
|
|
3
util.py
3
util.py
|
@ -86,8 +86,9 @@ class Util:
|
|||
t, msg = self._m(msg, t)
|
||||
self.send(irctokens.build("NOTICE", [t, str(msg)]).format())
|
||||
|
||||
def maskmatch(self, string, hostmask):
|
||||
def maskmatch(self, string: str, hostmask: str):
|
||||
"""DOES NOT HANDLE CASEMAPPING (yet), just dumb case-sensitive match, only ? and * are special"""
|
||||
print("string is", string, "and hostmask is", hostmask)
|
||||
pat = "[[]".join(
|
||||
[x.replace("]", "[]]") for x in hostmask.split("[")]
|
||||
) # escape all [ and ] into [[] and []]
|
||||
|
|
Loading…
Reference in New Issue
Block a user