Add automatic alias generation function
This commit is contained in:
parent
56840e0060
commit
15bc195648
|
@ -1,5 +1,6 @@
|
||||||
import main
|
import main
|
||||||
from yaml import dump
|
from yaml import dump
|
||||||
|
import modules.alias as alias
|
||||||
|
|
||||||
class Alias:
|
class Alias:
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
|
@ -35,6 +36,14 @@ class Alias:
|
||||||
else:
|
else:
|
||||||
failure("No such alias: %s" % spl[2])
|
failure("No such alias: %s" % spl[2])
|
||||||
return
|
return
|
||||||
|
elif spl[1] == "add" and spl[2] == "auto":
|
||||||
|
newalias = alias.generate_alias()
|
||||||
|
while newalias["nick"] in main.alias.keys():
|
||||||
|
newalias = alias.generate_alias()
|
||||||
|
main.alias[newalias["nick"]] = newalias
|
||||||
|
success("Successfully created alias: %s" % newalias["nick"])
|
||||||
|
main.saveConf("alias")
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
incUsage("alias")
|
incUsage("alias")
|
||||||
return
|
return
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -20,7 +20,7 @@
|
||||||
"mon": "mon -h",
|
"mon": "mon -h",
|
||||||
"chans": "chans <nick> [<nick> ...]",
|
"chans": "chans <nick> [<nick> ...]",
|
||||||
"users": "users <channel> [<channel> ...]",
|
"users": "users <channel> [<channel> ...]",
|
||||||
"alias": "alias <add|del|list> [<alias> <nickname> <altnick> <ident> <realname> <password>]",
|
"alias": "alias <add|del|list> [<alias> <nickname> <altnick> <ident> <realname> <password> OR auto]",
|
||||||
"relay": "relay <add|del|list> [<relay> <host> <port> <user> <password>]",
|
"relay": "relay <add|del|list> [<relay> <host> <port> <user> <password>]",
|
||||||
"network": "network <add|del|list> [<name> <address> <port> <ssl|plain> <sasl|ns|none>]",
|
"network": "network <add|del|list> [<name> <address> <port> <ssl|plain> <sasl|ns|none>]",
|
||||||
"provision": "provision <relay> <alias> [<network>]",
|
"provision": "provision <relay> <alias> [<network>]",
|
||||||
|
|
1
main.py
1
main.py
|
@ -17,6 +17,7 @@ filemap = {
|
||||||
"relay": ["relay.json", "relay list"],
|
"relay": ["relay.json", "relay list"],
|
||||||
"network": ["network.json", "network list"],
|
"network": ["network.json", "network list"],
|
||||||
"tokens": ["tokens.json", "authentication tokens"],
|
"tokens": ["tokens.json", "authentication tokens"],
|
||||||
|
"aliasdata": ["aliasdata.json", "data for alias generation"]
|
||||||
}
|
}
|
||||||
|
|
||||||
connections = {}
|
connections = {}
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
import main
|
||||||
|
import random
|
||||||
|
import re
|
||||||
|
|
||||||
|
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:]
|
||||||
|
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()
|
||||||
|
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()
|
||||||
|
|
||||||
|
password = "".join([chr(random.randint(0, 74) + 48) for i in range(32)])
|
||||||
|
|
||||||
|
return {"nick": nick, "altnick": altnick, "ident": ident, "realname": realname, "password": password}
|
Loading…
Reference in New Issue