Added unregister command.

This commit is contained in:
Jeremy Fincher 2003-09-13 13:44:13 +00:00
parent 358533b335
commit e31d2d8b85

View File

@ -56,12 +56,9 @@ class UserCommands(callbacks.Privmsg):
Registers <name> with the given password <password> and the current
hostmask of the person registering.
"""
(name, password) = privmsgs.getArgs(args, optional=1)
(name, password) = privmsgs.getArgs(args, needed=2)
if not self._checkNotChannel(irc, msg, password):
return
if ircutils.isChannel(msg.args[0]):
irc.error(msg, conf.replyRequiresPrivacy)
return
try:
ircdb.users.getUserId(name)
irc.error(msg, 'That name is alrady assigned to someone.')
@ -78,6 +75,26 @@ class UserCommands(callbacks.Privmsg):
ircdb.users.setUser(id, user)
irc.reply(msg, conf.replySuccess)
def unregister(self, irc, msg, args):
"""<name> <password>
Unregisters <name> from the user database.
"""
(name, password) = privmsgs.getArgs(args, needed=2)
if not self._checkNotChannel(irc, msg, password):
return
try:
id = ircdb.users.getUserId(name)
user = ircdb.users.getUser(id)
except KeyError:
irc.error(msg, 'That username isn\'t registered.')
return
if user.checkPassword(password):
ircdb.users.delUser(id)
irc.reply(msg, conf.replySuccess)
else:
irc.error(msg, conf.replyIncorrectAuth)
def addhostmask(self, irc, msg, args):
"""<name> <hostmask> [<password>]