Add an option to change NickServ's name and the identify command

This commit is contained in:
nyuszika7h 2015-07-27 13:08:52 +02:00
parent 80f5f7d4e8
commit 21060b2bfb
4 changed files with 40 additions and 11 deletions

View File

@ -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 = ""

View File

@ -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):

View File

@ -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)

View File

@ -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)