Made the hostmask command default to providing the hostmask of the person asking giving the command if no nick is provided.

This commit is contained in:
Jeremy Fincher 2003-10-21 21:33:27 +00:00
parent cad2269ba5
commit be97120c63
2 changed files with 11 additions and 4 deletions

View File

@ -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):
"""<nick>
"""[<nick>]
Returns the hostmask of <nick>.
Returns the hostmask of <nick>. If <nick> 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)

View File

@ -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: