Created
June 16, 2011 22:00
-
-
Save pirogoeth/1030402 to your computer and use it in GitHub Desktop.
nick dropping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def drop(msg, args = None): | |
""" drop a nickname and all registered channels from the database. """ | |
if args is None or len(args.split()) < 1: | |
msg.notice(msg.params, "Syntax: /msg %s \x02DROP\x02 <account> <password>" % (var.bots[msg.params].data['nick'])) | |
return False | |
if not msg.origin.logged_in or var.users[str(msg.origin)]['account'] == '*': | |
msg.origin.notice(msg.params, "You are not currently logged in.") | |
return False | |
try: | |
args = args.split() | |
account = args[0] | |
password = args[1] | |
except: | |
args = args.split() | |
key = args[0] | |
if account != var.users[str(msg.origin)]['account']: | |
msg.origin.notice(msg.params, 'You cannot drop an account that does not belong to you.') | |
return False | |
valid = var.database.validate_pass(account, password) | |
if valid is False: | |
var.failed_logins.update({account: []}) | |
var.failed_logins[account].append(var.users[str(msg.origin)]['asmhost']) | |
msg.origin.notice(msg.params, "Drop request for \x02%s\x02 has failed." % (account)) | |
var.protocol.notice(config('main', 'logchan'), "\x02failed drop request: \x02\x034 account %s by %s" % (account, var.users[str(msg.origin)]['asmhost'])) | |
return False | |
elif valid is True: | |
key = core.get_random_string(9) | |
var.drop_requests({key: account}) | |
msg.origin.notice(msg.params, "Please do \x0310/msg \x02%s\x02 DROP %s\x03 to confirm account deregistration." % (account, key)) | |
var.protocol.notice(config('main', 'logchan'), "\x02account deregistration queued: %s, key %s" % (account, key)) | |
return False | |
elif key in var.drop_requests and var.drop_requests[key] == var.users[str(msg.origin)]['account']: | |
msg.origin.logout() | |
var.database.deregister_user(account) | |
msg.origin.notice(msg.params, "Account \x02%s\x02 has been dropped." % (account)) | |
var.protocol.notice(config('main', 'logchan'), "\x02drop: \x02\x034 account %s by %s" % (username, var.users[str(msg.origin)]['asmhost'])) | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment