Aka: Add @show command. Closes GH-572. Closes GH-710.

This commit is contained in:
Valentin Lorentz 2014-07-13 21:19:48 +02:00
parent fee33c1272
commit 0a1bf6db22
2 changed files with 23 additions and 0 deletions

View File

@ -631,6 +631,23 @@ class Aka(callbacks.Plugin):
'channel': 'somethingWithoutSpaces',
}), 'user', 'something'])
def show(self, irc, msg, args, optlist, name):
"""<command>
This command shows the content of an Aka.
"""
channel = 'global'
for (option, arg) in optlist:
if option == 'channel':
if not ircutils.isChannel(arg):
irc.error(_('%r is not a valid channel.') % arg,
Raise=True)
channel = arg
command = self._db.get_alias(channel, name)
irc.reply(command)
show = wrap(show, [getopts({'channel': 'somethingWithoutSpaces'}),
'text'])
def importaliasdatabase(self, irc, msg, args):
"""takes no arguments

View File

@ -70,6 +70,12 @@ class AkaChannelTestCase(ChannelPluginTestCase):
self.assertNotError('aka add nonascii echo éé')
self.assertRegexp('help nonascii', "Alias for .*echo éé")
def testShow(self):
self.assertNotError('aka add foo bar')
self.assertResponse('show foo', 'bar $*')
self.assertNotError('aka add "foo bar" baz')
self.assertResponse('show "foo bar"', 'baz $*')
def testRemove(self):
self.assertNotError('aka add foo echo bar')
self.assertResponse('foo', 'bar')