From e50f3ccbac3d0e20850b956a11dfb6ca781fb137 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 22 Apr 2004 03:39:38 +0000 Subject: [PATCH] Added Utilities.last. --- ChangeLog | 4 ++++ plugins/Utilities.py | 12 ++++++++++++ test/test_Utilities.py | 3 +++ 3 files changed, 19 insertions(+) diff --git a/ChangeLog b/ChangeLog index dd07c2be9..f2db09434 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ + * Added Utilities.last, which replies with the last string + given. This is useful for sequencing commands and then replying + with the output of the last commnad. + * Updated RSS.info to accept a feed name as well as a url. * Added a signal handler for SIGTERM, so you folks killing your diff --git a/plugins/Utilities.py b/plugins/Utilities.py index cf93de023..c2ddf4d50 100644 --- a/plugins/Utilities.py +++ b/plugins/Utilities.py @@ -64,6 +64,18 @@ class Utilities(callbacks.Privmsg): """ irc.replySuccess() + def last(self, irc, msg, args): + """ [ ...] + + Returns the last argument given. Useful when you'd like multiple + nested commands to run, but only the output of the last one to be + returned. + """ + if args: + irc.reply(args[-1]) + else: + raise callbacks.Error + def strjoin(self, irc, msg, args): """ [ ...] diff --git a/test/test_Utilities.py b/test/test_Utilities.py index 3d7335c7c..c8c29c77c 100644 --- a/test/test_Utilities.py +++ b/test/test_Utilities.py @@ -41,6 +41,9 @@ class UtilitiesTestCase(PluginTestCase): self.assertNotError('success 1') self.assertError('success [re m/foo bar]') + def testLast(self): + self.assertResponse('utilities last foo bar baz', 'baz') + def testStrjoin(self): self.assertResponse('strjoin + foo bar baz', 'foo+bar+baz')