NickAuth: refer to "services accounts" instead of "nicks" in help

On modern networks, account names are usually separated from your current nick,
so the idea of registering "nicks" is confusing. For instance, you can be using
a grouped nick that is not your main account name, and WHOIS will only ever
show your main account name.

Also, the bot username is optional in the `add` and `remove` commands - update
the docs to reflect that.
This commit is contained in:
James Lu 2025-04-12 19:13:22 -07:00 committed by Val Lorentz
parent c81ff28697
commit 83d301c604
2 changed files with 26 additions and 24 deletions

View File

@ -48,8 +48,8 @@ class NickAuth(callbacks.Plugin):
This plugin allows users to use their network services account to This plugin allows users to use their network services account to
authenticate to the bot. authenticate to the bot.
They first have to use ``@nickauth nick add <the nick>`` while being They first have to use ``@nickauth nick add <services account name>`` while
identified to the bot and then use ``@auth`` when they want to identified to the bot, and then use ``@auth`` when they want to
identify to the bot. identify to the bot.
""" """
@ -59,12 +59,12 @@ class NickAuth(callbacks.Plugin):
class nick(callbacks.Commands): class nick(callbacks.Commands):
def _check_auth(self, irc, msg, user): def _check_auth(self, irc, msg, user):
if user is None: if user is None:
irc.error(_('You are not authenticated.'), Raise=True) irc.error(_('You are not logged in to the bot.'), Raise=True)
if not user.checkHostmask(msg.prefix): if not user.checkHostmask(msg.prefix):
try: try:
u = ircdb.users.getUser(msg.prefix) u = ircdb.users.getUser(msg.prefix)
except KeyError: except KeyError:
irc.error(_('You are not authenticated.'), irc.error(_('You are not logged in to the bot.'),
Raise=True) Raise=True)
if not u._checkCapability('owner'): if not u._checkCapability('owner'):
irc.error(_('You must be owner to do that.'), irc.error(_('You must be owner to do that.'),
@ -72,11 +72,11 @@ class NickAuth(callbacks.Plugin):
@internationalizeDocstring @internationalizeDocstring
def add(self, irc, msg, args, network, user, nick): def add(self, irc, msg, args, network, user, nick):
"""[<network>] <user> <nick> """[<network>] [<bot username>] <account>
Add <nick> to the list of nicks owned by the <user> on the Add <account> to the list of network services accounts owned by
<network>. You have to register this nick to the network <bot username> on <network>. <bot username> is only required if you
services to be authenticated. are not already logged in to Limnoria.
<network> defaults to the current network. <network> defaults to the current network.
""" """
network = network.network or irc.network network = network.network or irc.network
@ -85,8 +85,8 @@ class NickAuth(callbacks.Plugin):
try: try:
user.addNick(network, nick) user.addNick(network, nick)
except KeyError: except KeyError:
irc.error(_('This nick is already used by someone on this ' irc.error(_('This services account is already used by someone '
'network.'), Raise=True) 'on this network.'), Raise=True)
irc.replySuccess() irc.replySuccess()
add = wrap(add, [optional('networkIrc'), add = wrap(add, [optional('networkIrc'),
optional('otherUser'), optional('otherUser'),
@ -94,10 +94,11 @@ class NickAuth(callbacks.Plugin):
@internationalizeDocstring @internationalizeDocstring
def remove(self, irc, msg, args, network, user, nick): def remove(self, irc, msg, args, network, user, nick):
"""[<network>] <user> <nick> """[<network>] [<bot username>] <account>
Remove <nick> from the list of nicks owned by the <user> on the Remove <account> from the list of network services accounts owned by
<network>. <bot username> on <network>. <bot username> is only required if you
are not already logged in to Limnoria.
<network> defaults to the current network. <network> defaults to the current network.
""" """
network = network.network or irc.network network = network.network or irc.network
@ -106,8 +107,8 @@ class NickAuth(callbacks.Plugin):
try: try:
user.removeNick(network, nick) user.removeNick(network, nick)
except KeyError: except KeyError:
irc.error(_('This nick is not registered to you on this ' irc.error(_('This services account is not registered to you on '
'network.'), Raise=True) 'this network.'), Raise=True)
irc.replySuccess() irc.replySuccess()
remove = wrap(remove, [optional('networkIrc'), remove = wrap(remove, [optional('networkIrc'),
optional('otherUser'), optional('otherUser'),
@ -115,9 +116,10 @@ class NickAuth(callbacks.Plugin):
@internationalizeDocstring @internationalizeDocstring
def list(self, irc, msg, args, network, user): def list(self, irc, msg, args, network, user):
"""[<network>] [<user>] """[<network>] [<bot username>]
Lists nicks of the <user> on the network. Lists services accounts registered to <bot username> on the network,
or your own bot account if no username is given.
<network> defaults to the current network. <network> defaults to the current network.
""" """
network = network.network or irc.network network = network.network or irc.network
@ -135,11 +137,11 @@ class NickAuth(callbacks.Plugin):
raise KeyError raise KeyError
except KeyError: except KeyError:
if user == ircdb.users.getUser(msg.prefix): if user == ircdb.users.getUser(msg.prefix):
irc.error(_('You have no recognized nick on this ' irc.error(_('You have no recognized services accounts on '
'network.'), Raise=True) 'this network.'), Raise=True)
else: else:
irc.error(_('%s has no recognized nick on this ' irc.error(_('%s has no recognized services accounts on this '
'network.') % user.name, Raise=True) 'network.') % user.name, Raise=True)
list = wrap(list, [optional('networkIrc'), list = wrap(list, [optional('networkIrc'),
optional('otherUser')]) optional('otherUser')])
@ -148,7 +150,7 @@ class NickAuth(callbacks.Plugin):
"""takes no argument """takes no argument
Tries to authenticate you using network services. Tries to authenticate you using network services.
If you get no reply, it means you are not authenticated to the If you get no reply, it means you are not authenticated to
network services.""" network services."""
nick = ircutils.toLower(msg.nick) nick = ircutils.toLower(msg.nick)
self._requests[(irc.network, msg.nick)] = (time.time(), msg.prefix, irc) self._requests[(irc.network, msg.nick)] = (time.time(), msg.prefix, irc)
@ -183,7 +185,7 @@ class NickAuth(callbacks.Plugin):
ircdb.users.setUser(user, flush=False) ircdb.users.setUser(user, flush=False)
irc.reply(_('You are now authenticated as %s.') % user.name) irc.reply(_('You are now authenticated as %s.') % user.name)
else: else:
irc.error(_('No user claimed the nick %s on this network. ' irc.error(_('No user claimed the account %s on this network. '
'If this is you, you should connect with an other ' 'If this is you, you should connect with an other '
'method and use the "nickauth nick add" command, ' 'method and use the "nickauth nick add" command, '
'or ask the owner of the bot to do it.') 'or ask the owner of the bot to do it.')

View File

@ -128,7 +128,7 @@ class NickAuthTestCase(PluginTestCase):
def testList(self): def testList(self):
self.assertNotError('register foobar 123') self.assertNotError('register foobar 123')
self.assertRegexp('nick list', 'You have no recognized nick') self.assertRegexp('nick list', 'You have no recognized services accounts')
self.assertNotError('nick add foo') self.assertNotError('nick add foo')
self.assertRegexp('nick list', 'foo') self.assertRegexp('nick list', 'foo')
self.assertNotError('nick add %s bar' % self.nick) self.assertNotError('nick add %s bar' % self.nick)