Services: Add @nickserv and @chanserv command, to message services directly

This is because the recommended method ('owner ircquote nickserv register mypassword bot@example.com')
does not work on charybdis, as Limnoria inserts a colon
before the trailing argument and Charybdis' m_alias module
does not parse commands using the IRC syntax, so it
considers the leading colon to be part of the email address.

The alternative would be to change the recommended command to:
'owner ircquote PRIVMSG nickserv :register mypassword bot@example.com'
but it is prone to typos, so I think we should avoid it.
This commit is contained in:
Valentin Lorentz 2021-06-14 21:47:36 +02:00
parent c8053dad54
commit 4b82934131
2 changed files with 41 additions and 0 deletions

View File

@ -558,6 +558,35 @@ class Services(callbacks.Plugin):
'I\'m able to ghost a nick.'))
ghost = wrap(ghost, [('checkCapability', 'admin'), additional('nick')])
def nickserv(self, irc, msg, args, text):
"""<text>
Sends the <text> to NickServ. For example, to register to NickServ
on Atheme, use: @nickserv REGISTER <password> <email-address>."""
nickserv = self.registryValue('NickServ', network=irc.network)
if nickserv:
irc.replySuccess()
irc.queueMsg(ircmsgs.privmsg(nickserv, text))
else:
irc.error(_('You must set supybot.plugins.Services.NickServ before '
'I\'m able to message NickServ'))
nickserv = wrap(nickserv, ['owner', 'text'])
def chanserv(self, irc, msg, args, text):
"""<text>
Sends the <text> to ChanServ. For example, to register a channel
on Atheme, use: @chanserv REGISTER <#channel>."""
chanserv = self.registryValue('ChanServ', network=irc.network)
if chanserv:
irc.replySuccess()
irc.queueMsg(ircmsgs.privmsg(chanserv, text))
else:
irc.error(_('You must set supybot.plugins.Services.ChanServ before '
'I\'m able to message ChanServ'))
chanserv = wrap(chanserv, ['owner', 'text'])
@internationalizeDocstring
def password(self, irc, msg, args, nick, password):
"""<nick> [<password>]

View File

@ -88,6 +88,18 @@ class ServicesTestCase(PluginTestCase):
finally:
self.assertNotError('services password %s ""' % self.nick)
def testNickserv(self):
self.assertNotError('nickserv foo bar')
m = self.irc.takeMsg()
self.assertEqual(m.command, 'PRIVMSG', m)
self.assertEqual(m.args, ('NickServ', 'foo bar'), m)
def testChanserv(self):
self.assertNotError('chanserv foo bar')
m = self.irc.takeMsg()
self.assertEqual(m.command, 'PRIVMSG', m)
self.assertEqual(m.args, ('ChanServ', 'foo bar'), m)
def testRegisterNoExperimentalExtensions(self):
self.assertRegexp(
"register p4ssw0rd", "error: Experimental IRC extensions")