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