diff options
author | jomo <github@jomo.tv> | 2014-06-10 01:31:03 +0200 |
---|---|---|
committer | jomo <github@jomo.tv> | 2014-06-10 01:31:03 +0200 |
commit | 98620428ec0a1116a0530eab8feca3d48f75fb96 (patch) | |
tree | 16f04601bb18586e4f41a3ce66600a7da37c6a21 /webtoken.py | |
parent | e466d5426cd6cdcc1d250f44b6f16c215b3affc9 (diff) |
HUGE code cleanup
Diffstat (limited to 'webtoken.py')
-rw-r--r-- | webtoken.py | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/webtoken.py b/webtoken.py index 51973f0..4a15b2e 100644 --- a/webtoken.py +++ b/webtoken.py @@ -1,3 +1,4 @@ +#pylint: disable=F0401 import mysqlhack import thread from re import match @@ -41,18 +42,13 @@ def generate_token(length): token += vows[randrange(5)] return token -def set_token(uuid): - token = generate_token(6) - # REPLACE INTO website.register_token uuid={uuid}, token={token}; - return token - def get_token(uuid): # ae795aa86327408e92ab25c8a59f3ba1 results = mysql_query("SELECT DISTINCT `token`, `email` FROM register_tokens WHERE `uuid` = ? LIMIT 1", (uuid,)) return results[0] if len(results) == 1 else None - - -def token_command(sender, args, foo): + + +def token_command(sender): plugHeader(sender, "Website Token") if isPlayer(sender): try: @@ -68,13 +64,13 @@ def token_command(sender, args, foo): else: msg(sender, "&cThis is only for players..") -def tokengen_command(sender, args, foo): +def tokengen_command(sender, args): plugHeader(sender, "Website Token") if isPlayer(sender): if checkargs(sender, args, 1, -1): # email regex, needs something followed by an @ followed by something mail = " ".join(args) # email may contain spaces - if match("^.+@(.+\..{2,}|\[[0-9a-fA-F:.]+\])$", mail) != None: + if match("^.+@(.+\\..{2,}|\\[[0-9a-fA-F:.]+\\])$", mail) != None: token = generate_token(6) uuid = sender.getUniqueId().toString().replace("-", "") try: @@ -94,17 +90,17 @@ def tokengen_command(sender, args, foo): @hook.command("token") -def onCommand(sender, args): - thread.start_new_thread(token_command, (sender, args, "foo")) +def onTokenCommand(sender, args): + thread.start_new_thread(token_command, (sender,)) return True - + @hook.command("tokengen") -def onCommand(sender, args): - thread.start_new_thread(tokengen_command, (sender, args, "foo")) +def onTokengenCommand(sender, args): + thread.start_new_thread(tokengen_command, (sender, args)) return True - - - - - - + + + + + + |