Aka: Tell in the help message what channel the aka is for.

This commit is contained in:
Valentin Lorentz 2017-08-20 19:55:28 +02:00
parent 0d7714d490
commit 087fa71d63
2 changed files with 13 additions and 3 deletions

View File

@ -507,8 +507,12 @@ class Aka(callbacks.Plugin):
lock = ' ' + _('Locked by %s at %s') % (locked_by, locked_at)
else:
lock = ''
doc = format(_('<an alias,%s %n>\n\nAlias for %q.%s'),
flexargs, (biggestDollar, _('argument')), original, lock)
if channel == 'global':
doc = format(_('<a global alias,%s %n>\n\nAlias for %q.%s'),
flexargs, (biggestDollar, _('argument')), original, lock)
else:
doc = format(_('<an alias on %s,%s %n>\n\nAlias for %q.%s'),
channel, flexargs, (biggestDollar, _('argument')), original, lock)
f = utils.python.changeFunctionName(f, name, doc)
return f

View File

@ -71,6 +71,12 @@ class AkaChannelTestCase(ChannelPluginTestCase):
self.assertNotError('aka add nonascii echo éé')
self.assertRegexp('help nonascii', "Alias for .*echo éé")
self.assertNotError('aka remove slashdot')
self.assertNotError('aka add --channel %s slashdot foo' % self.channel)
self.assertRegexp('help aka slashdot', "an alias on %s.*Alias for .*foo"
% self.channel)
self.assertNotError('aka remove --channel %s slashdot' % self.channel)
def testShow(self):
self.assertNotError('aka add foo bar')
self.assertResponse('show foo', 'bar $*')
@ -211,7 +217,7 @@ class AkaTestCase(PluginTestCase):
self.assertNotError('register evil_admin foo')
self.assertNotError('aka add slashdot foo')
self.assertRegexp('help aka slashdot', "Alias for .*foo")
self.assertRegexp('help aka slashdot', "a global alias.*Alias for .*foo")
self.assertNotRegexp('help aka slashdot', 'Locked by')
self.assertNotError('aka lock slashdot')
self.assertRegexp('help aka slashdot', 'Locked by evil_admin')