Removed wordoftheday, updated password.py
This commit is contained in:
parent
49e53620a8
commit
fa63329509
2 changed files with 14 additions and 19 deletions
|
@ -1,15 +1,16 @@
|
||||||
# Password generation code by <TheNoodle>
|
# based on password generation code by TheNoodle
|
||||||
from util import hook
|
from util import hook
|
||||||
import string
|
import string
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
|
||||||
def gen_password(types):
|
@hook.command
|
||||||
# Password Generator - The Noodle http://bowlofnoodles.net
|
def password(inp, notice=None):
|
||||||
|
"password <length> [types] -- Generates a password of <length> (default 10). [types] can include 'alpha', 'no caps', 'numeric', 'symbols' or any combination of the inp, eg. 'numbers symbols'"
|
||||||
okay = []
|
okay = []
|
||||||
|
|
||||||
# find the length needed for the password
|
# find the length needed for the password
|
||||||
numb = types.split(" ")
|
numb = inp.split(" ")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
length = int(numb[0])
|
length = int(numb[0])
|
||||||
|
@ -17,35 +18,29 @@ def gen_password(types):
|
||||||
length = 10
|
length = 10
|
||||||
|
|
||||||
# add alpha characters
|
# add alpha characters
|
||||||
if "alpha" in types or "letter" in types:
|
if "alpha" in inp or "letter" in inp:
|
||||||
okay = okay + string.ascii_lowercase
|
okay = okay + list(string.ascii_lowercase)
|
||||||
#adds capital characters if not told not to
|
#adds capital characters if not told not to
|
||||||
if "no caps" not in types:
|
if "no caps" not in inp:
|
||||||
okay = okay + string.ascii_uppercase
|
okay = okay + list(string.ascii_uppercase)
|
||||||
|
|
||||||
# add numbers
|
# add numbers
|
||||||
if "numeric" in types or "numbers" in types:
|
if "numeric" in inp or "number" in inp:
|
||||||
okay = okay + [str(x) for x in range(0, 10)]
|
okay = okay + [str(x) for x in xrange(0, 10)]
|
||||||
|
|
||||||
# add symbols
|
# add symbols
|
||||||
if "symbols" in types:
|
if "symbol" in inp:
|
||||||
sym = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', '_', '+', '[', ']', '{', '}', '\\', '|', ';', ':', "'", '.', '>', ',', '<', '/', '?', '`', '~', '"']
|
sym = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', '_', '+', '[', ']', '{', '}', '\\', '|', ';', ':', "'", '.', '>', ',', '<', '/', '?', '`', '~', '"']
|
||||||
okay += okay + sym
|
okay += okay + sym
|
||||||
|
|
||||||
# defaults to lowercase alpha password if the okay list is empty
|
# defaults to lowercase alpha password if the okay list is empty
|
||||||
if not okay:
|
if not okay:
|
||||||
okay = okay + string.ascii_lowercase
|
okay = okay + list(string.ascii_lowercase)
|
||||||
|
|
||||||
password = ""
|
password = ""
|
||||||
|
|
||||||
# generates password
|
# generates password
|
||||||
for x in range(length):
|
for x in range(length):
|
||||||
password = password + random.choice(okay)
|
password = password + random.choice(okay)
|
||||||
return password
|
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
|
||||||
def password(inp, notice=None):
|
|
||||||
"password <length> [types] -- Generates a password of <length> (default 10). [types] can include 'alpha', 'no caps', 'numeric', 'symbols' or any combination of the types, eg. 'numbers symbols'"
|
|
||||||
password = gen_password(inp)
|
|
||||||
notice(password)
|
notice(password)
|
||||||
|
|
Reference in a new issue