From be97120c63a8f74f14915d1f0eaec3ad86a75457 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 21 Oct 2003 21:33:27 +0000 Subject: [PATCH] Made the hostmask command default to providing the hostmask of the person asking giving the command if no nick is provided. --- src/Misc.py | 12 ++++++++---- test/test_Misc.py | 3 +++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Misc.py b/src/Misc.py index 6960bd54b..0127d6d23 100755 --- a/src/Misc.py +++ b/src/Misc.py @@ -206,13 +206,17 @@ class Misc(callbacks.Privmsg): irc.error(msg, '%s has no help or syntax description.'%command) def hostmask(self, irc, msg, args): - """ + """[] - Returns the hostmask of . + Returns the hostmask of . If isn't given, return the + hostmask of the person giving the command. """ - nick = privmsgs.getArgs(args) + nick = privmsgs.getArgs(args, needed=0, optional=1) try: - irc.reply(msg, irc.state.nickToHostmask(nick)) + if nick: + irc.reply(msg, irc.state.nickToHostmask(nick)) + else: + irc.reply(msg, msg.prefix) except KeyError: irc.error(msg, 'I haven\'t seen anyone named %r' % nick) diff --git a/test/test_Misc.py b/test/test_Misc.py index 05e286567..22cccc143 100644 --- a/test/test_Misc.py +++ b/test/test_Misc.py @@ -132,6 +132,9 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation): m = self.getMsg('notice [list]') self.assertEqual(m.command, 'NOTICE') + def testHostmask(self): + self.assertResponse('hostmask', self.prefix) + # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: