From 21060b2bfb36ccf83d93f3f9c5e9fe64810da47c Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Mon, 27 Jul 2015 13:08:52 +0200 Subject: [PATCH] Add an option to change NickServ's name and the identify command --- botconfig.py.example | 18 ++++++++++++++++++ oyoyo/client.py | 19 +++++++++++-------- src/handler.py | 8 +++++--- src/settings.py | 6 ++++++ 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/botconfig.py.example b/botconfig.py.example index cabc7ed..a815a6f 100644 --- a/botconfig.py.example +++ b/botconfig.py.example @@ -12,6 +12,7 @@ CHANNEL = "##mywolfgame" CMD_CHAR = "!" + OWNERS = ("unaffiliated/wolfbot_admin1",) # The comma is required at the end if there is only one owner. ADMINS = ("unaffiliated/wolfbot_admin2", "unaffiliated/wolfbot_test*") @@ -38,3 +39,20 @@ USE_UTC = True # If True, logs will use the UTC time, else local time. # %Y is the year, %m is the month, %d is the day, %H = hour, %M = minute, and %S = seconds. # {tzname} and {tzoffset} can both be used - the timezone name (like UTC) and offset (+0000), respectively. TIMESTAMP_FORMAT = "[%Y-%m-%d %H:%M:%S{tzoffset}]" + + +# This doesn't need to be changed unless you're running the bot on a network with a non-standard +# services setup. +# +# An example configuration for Undernet is provided below; if you're running the bot on Undernet, +# you can simply uncomment the following lines. For other networks, you can set the appropriate +# values manually. +# +# Note: Do not put the account and password here; they will be automatically substituted +# from the USERNAME (or NICK) and PASS variables on the top of the file. + +#NICKSERV = "x@channels.undernet.org" +#NICKSERV_IDENTIFY_COMMAND = "LOGIN {account} {password}" +#NICKSERV_GHOST_COMMAND = "" +#NICKSERV_RELEASE_COMMAND = "" +#NICKSERV_REGAIN_COMMAND = "" diff --git a/oyoyo/client.py b/oyoyo/client.py index 52301e4..23339fe 100644 --- a/oyoyo/client.py +++ b/oyoyo/client.py @@ -272,14 +272,17 @@ class IRCClient(object): self.send("PART {0} :{1}".format(chan, msg)) def kick(self, chan, nick, msg=""): self.send("KICK", chan, nick, ":"+msg) - def ns_identify(self, passwd): - self.msg("NickServ", "IDENTIFY {0} {1}".format(self.nickname, passwd)) - def ns_ghost(self): - self.msg("NickServ", "GHOST "+self.nickname) - def ns_release(self): - self.msg("NickServ", "RELEASE "+self.nickname) - def ns_regain(self): - self.msg("NickServ", "REGAIN "+self.nickname) + def ns_identify(self, passwd, nickserv, command): + self.msg(nickserv, command.format(account=self.nickname, password=passwd)) + def ns_ghost(self, nickserv, command): + if command: + self.msg(nickserv, command.format(nick=self.nickname)) + def ns_release(self, nickserv="NickServ", command="RELEASE {nick}"): + if command: + self.msg(nickserv, command.format(nick=self.nickname)) + def ns_regain(self, nickserv="NickServ", command="REGAIN {nick}"): + if command: + self.msg(nickserv, command.format(nick=self.nickname)) def user(self, ident, rname): self.send("USER", ident, self.host, self.host, ":{0}".format(rname or ident)) def mainLoop(self): diff --git a/src/handler.py b/src/handler.py index b12c88c..4633eab 100644 --- a/src/handler.py +++ b/src/handler.py @@ -104,7 +104,9 @@ def connect_callback(cli): def prepare_stuff(*args): # just in case we haven't managed to successfully auth yet if not botconfig.SASL_AUTHENTICATION: - cli.ns_identify(botconfig.PASS) + cli.ns_identify(botconfig.PASS, + nickserv=var.NICKSERV, + command=var.NICKSERV_IDENTIFY_COMMAND) channels = {botconfig.CHANNEL} @@ -128,12 +130,12 @@ def connect_callback(cli): def mustregain(cli, *blah): if not botconfig.PASS: return - cli.ns_regain() + cli.ns_regain(nickserv=var.NICKSERV, command=var.NICKSERV_REGAIN_COMMAND) def mustrelease(cli, *rest): if not botconfig.PASS: return # prevents the bot from trying to release without a password - cli.ns_release() + cli.ns_release(nickserv=var.NICKSERV, command=var.NICKSERV_RELEASE_COMMAND) cli.nick(botconfig.NICK) @hook("unavailresource", hookid=239) diff --git a/src/settings.py b/src/settings.py index b4ed174..d2becc7 100644 --- a/src/settings.py +++ b/src/settings.py @@ -142,6 +142,12 @@ ACCOUNTS_ONLY = False # If True, will use only accounts for everything DISABLE_ACCOUNTS = False # If True, all account-related features are disabled. Automatically set if we discover we do not have proper ircd support for accounts # This will override ACCOUNTS_ONLY if it is set +NICKSERV = "NickServ" +NICKSERV_IDENTIFY_COMMAND = "IDENTIFY {account} {password}" +NICKSERV_GHOST_COMMAND = "GHOST {nick}" +NICKSERV_RELEASE_COMMAND = "RELEASE {nick}" +NICKSERV_REGAIN_COMMAND = "REGAIN {nick}" + STASISED = defaultdict(int) STASISED_ACCS = defaultdict(int)