Utilities: Add @sort.

This commit is contained in:
Valentin Lorentz 2014-03-20 17:46:47 +00:00
parent 65a7935214
commit bfa45a6da8
2 changed files with 12 additions and 0 deletions

View File

@ -104,6 +104,15 @@ class Utilities(callbacks.Plugin):
irc.reply(' '.join(things))
shuffle = wrap(shuffle, [many('anything')])
@internationalizeDocstring
def sort(self, irc, msg, args, things):
"""<arg> [<arg> ...]
Sorts the arguments given.
"""
irc.reply(' '.join(sorted(things)))
sort = wrap(sort, [many('anything')])
@internationalizeDocstring
def sample(self, irc, msg, args, num, things):
"""<num> <arg> [<arg> ...]

View File

@ -62,6 +62,9 @@ class UtilitiesTestCase(PluginTestCase):
def testShuffle(self):
self.assertResponse('shuffle a', 'a')
def testSort(self):
self.assertResponse('sort abc cab cba bca', 'abc bca cab cba')
def testSample(self):
self.assertResponse('sample 1 a', 'a')
self.assertError('sample moo')