Changed delhostmask to removehostmask and fixed a bug.

This commit is contained in:
Jeremy Fincher 2003-09-14 02:52:40 +00:00
parent 0293a2ba0d
commit 2d0671b6f6
2 changed files with 8 additions and 4 deletions

View File

@ -134,10 +134,10 @@ class UserCommands(callbacks.Privmsg):
irc.error(msg, conf.replyIncorrectAuth) irc.error(msg, conf.replyIncorrectAuth)
return return
def delhostmask(self, irc, msg, args): def removehostmask(self, irc, msg, args):
"""<name> <hostmask> [<password>] """<name> <hostmask> [<password>]
Deletes the hostmask <hostmask> from the record of the user specified Removes the hostmask <hostmask> from the record of the user specified
by <name>. The <password> may only be required if the user is not by <name>. The <password> may only be required if the user is not
recognized by his hostmask. recognized by his hostmask.
""" """
@ -151,7 +151,11 @@ class UserCommands(callbacks.Privmsg):
irc.error(msg, conf.replyNoUser) irc.error(msg, conf.replyNoUser)
return return
if user.checkHostmask(msg.prefix) or user.checkPassword(password): if user.checkHostmask(msg.prefix) or user.checkPassword(password):
try:
user.removeHostmask(hostmask) user.removeHostmask(hostmask)
except ValueError:
irc.error(msg, 'There was no such hostmask.')
return
ircdb.users.setUser(id, user) ircdb.users.setUser(id, user)
irc.reply(msg, conf.replySuccess) irc.reply(msg, conf.replySuccess)
else: else:

View File

@ -223,7 +223,7 @@ class IrcUser(object):
self.hostmasks.append(hostmask) self.hostmasks.append(hostmask)
def removeHostmask(self, hostmask): def removeHostmask(self, hostmask):
self.hostmasks = [s for s in self.hostmasks if s != hostmask] self.hostmasks.remove(hostmask)
def hasHostmask(self, hostmask): def hasHostmask(self, hostmask):
return hostmask in self.hostmasks return hostmask in self.hostmasks