monolith/modules/alias.py

75 lines
1.9 KiB
Python

import main
import random
import re
def generate_password():
return "".join([chr(random.randint(0, 74) + 48) for i in range(32)])
def generate_alias():
nick = random.choice(main.aliasdata["stubs"])
rand = random.randint(1, 2)
if rand == 1:
nick = nick.capitalize()
rand = random.randint(1, 4)
while rand == 1:
split = random.randint(0, len(nick) - 1)
nick = nick[:split] + nick[split + 1 :] # noqa: E203
rand = random.randint(1, 4)
rand = random.randint(1, 3)
if rand == 1 or rand == 4:
nick = random.choice(main.aliasdata["stubs"]) + nick
if rand == 2 or rand == 5:
nick = random.choice(main.aliasdata["stubs"]).capitalize() + nick
if rand > 2:
nick = nick + str(random.randint(0, 100))
nick = nick[:11]
altnick = nick
rand = random.randint(1, 3)
if rand == 1:
altnick += "_"
elif rand == 2:
altnick += "1"
else:
altnick = "_" + altnick
namebase = random.choice(main.aliasdata["realnames"])
ident = nick[:10]
rand = random.randint(1, 7)
if rand == 1:
ident = "quassel"
elif rand == 2:
ident = ident.lower()
elif rand == 3:
ident = re.sub("[0-9]", "", nick)
ident = ident[:10]
elif rand == 4:
ident = namebase.split(" ")[0].lower()
ident = ident[:10]
elif rand == 5:
ident = namebase.split(" ")[0]
ident = ident[:10]
elif rand == 6:
ident = re.sub("\s", "", namebase).lower() # noqa: W605
ident = ident[:10]
realname = nick
rand = random.randint(1, 5)
if rand == 1:
realname = namebase
elif rand == 2 or rand == 3:
realname = re.sub("[0-9]", "", realname)
if rand == 3 or rand == 4:
realname = realname.capitalize()
return {
"nick": nick,
"altnick": altnick,
"ident": ident,
"realname": realname,
"emails": [],
}