mirror of https://github.com/Mikaela/Limnoria.git
Abstract registerNick and update configure() to use the abstraction
This commit is contained in:
parent
a8830b5083
commit
d7d1c42ebc
|
@ -58,7 +58,7 @@ def configure(advanced):
|
||||||
nickserv = something('What is your NickServ named?', default='NickServ')
|
nickserv = something('What is your NickServ named?', default='NickServ')
|
||||||
conf.supybot.plugins.Services.nicks.setValue(nick)
|
conf.supybot.plugins.Services.nicks.setValue(nick)
|
||||||
conf.supybot.plugins.Services.NickServ.setValue(nickserv)
|
conf.supybot.plugins.Services.NickServ.setValue(nickserv)
|
||||||
conf.supybot.plugins.Services.NickServ.password.setValue(password)
|
registerNick(nick, password)
|
||||||
conf.supybot.plugins.Services.ChanServ.setValue(chanserv)
|
conf.supybot.plugins.Services.ChanServ.setValue(chanserv)
|
||||||
|
|
||||||
class ValidNickOrEmptyString(registry.String):
|
class ValidNickOrEmptyString(registry.String):
|
||||||
|
@ -68,13 +68,19 @@ class ValidNickOrEmptyString(registry.String):
|
||||||
'Value must be a valid nick or the empty string.'
|
'Value must be a valid nick or the empty string.'
|
||||||
registry.String.setValue(self, v)
|
registry.String.setValue(self, v)
|
||||||
|
|
||||||
|
def registerNick(nick, password=''):
|
||||||
|
p = conf.supybot.plugins.Services.Nickserv.get('password')
|
||||||
|
v = p.register(nick, registry.String(password, '', private=True))
|
||||||
|
if password:
|
||||||
|
v.setValue(password)
|
||||||
|
|
||||||
conf.registerPlugin('Services')
|
conf.registerPlugin('Services')
|
||||||
# Not really ChannelValues: but we can have values for each network. We
|
# Not really ChannelValues: but we can have values for each network. We
|
||||||
# should probably document that this is possible.
|
# should probably document that this is possible.
|
||||||
|
|
||||||
class ValidNickSet(conf.ValidNicks):
|
class ValidNickSet(conf.ValidNicks):
|
||||||
List = ircutils.IrcSet
|
List = ircutils.IrcSet
|
||||||
|
|
||||||
conf.registerGlobalValue(conf.supybot.plugins.Services, 'nicks',
|
conf.registerGlobalValue(conf.supybot.plugins.Services, 'nicks',
|
||||||
ValidNickSet([], """Determines what nicks the bot will use with
|
ValidNickSet([], """Determines what nicks the bot will use with
|
||||||
services."""))
|
services."""))
|
||||||
|
@ -120,7 +126,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.Privmsg.__init__(self)
|
||||||
for nick in self.registryValue('nicks'):
|
for nick in self.registryValue('nicks'):
|
||||||
self._registerNick(nick)
|
registerNick(nick)
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
|
@ -139,12 +145,6 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||||
return None
|
return None
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
def _registerNick(self, nick, password=''):
|
|
||||||
p = self.registryValue('NickServ.password', value=False)
|
|
||||||
v = p.register(nick, registry.String(password, '', private=True))
|
|
||||||
if password:
|
|
||||||
v.setValue(password)
|
|
||||||
|
|
||||||
def _getNick(self):
|
def _getNick(self):
|
||||||
return conf.supybot.nick()
|
return conf.supybot.nick()
|
||||||
|
|
||||||
|
@ -545,7 +545,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.registryValue('nicks').add(nick)
|
self.registryValue('nicks').add(nick)
|
||||||
self._registerNick(nick, password)
|
registerNick(nick, password)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
|
||||||
def nicks(self, irc, msg, args):
|
def nicks(self, irc, msg, args):
|
||||||
|
|
Loading…
Reference in New Issue