Fix User.hostmasks so it correctly checks capability and doesn't display

the hostmasks as an IrcSet
This commit is contained in:
James Vega 2004-12-30 16:37:45 +00:00
parent 9246b169e1
commit 69d98609fc

View File

@ -302,22 +302,25 @@ class User(callbacks.Privmsg):
Returns the hostmasks of the user specified by <name>; if <name> isn't Returns the hostmasks of the user specified by <name>; if <name> isn't
specified, returns the hostmasks of the user calling the command. specified, returns the hostmasks of the user calling the command.
""" """
def getHostmasks(user):
hostmasks = map(repr, user.hostmasks)
hostmasks.sort()
return utils.commaAndify(hostmasks)
try: try:
user = ircdb.users.getUser(msg.prefix) user = ircdb.users.getUser(msg.prefix)
if name: if name:
if name != user.name and not user.checkCapability('owner'): if name != user.name and \
not ircdb.checkCapability(msg.prefix, 'owner'):
irc.error('You may only retrieve your own hostmasks.', irc.error('You may only retrieve your own hostmasks.',
Raise=True) Raise=True)
else: else:
try: try:
user = ircdb.users.getUser(name) user = ircdb.users.getUser(name)
hostmasks = map(repr, user.hostmasks) irc.reply(getHostmasks(user))
hostmasks.sort()
irc.reply(utils.commaAndify(hostmasks))
except KeyError: except KeyError:
irc.errorNoUser() irc.errorNoUser()
else: else:
irc.reply(repr(user.hostmasks)) irc.reply(getHostmasks(user))
except KeyError: except KeyError:
irc.errorNotRegistered() irc.errorNotRegistered()
hostmasks = wrap(hostmasks, ['private', additional('something')]) hostmasks = wrap(hostmasks, ['private', additional('something')])