2019-01-20 19:56:54 +00:00
|
|
|
import main
|
|
|
|
from yaml import dump
|
2019-08-10 10:44:31 +00:00
|
|
|
import modules.alias as alias
|
2019-01-20 19:56:54 +00:00
|
|
|
|
2019-08-09 22:06:34 +00:00
|
|
|
class AliasCommand:
|
2019-01-26 18:58:21 +00:00
|
|
|
def __init__(self, *args):
|
|
|
|
self.alias(*args)
|
2019-01-20 19:56:54 +00:00
|
|
|
|
|
|
|
def alias(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
|
|
|
if authed:
|
2019-01-26 01:57:24 +00:00
|
|
|
if length == 8:
|
2019-01-20 19:56:54 +00:00
|
|
|
if spl[1] == "add":
|
|
|
|
if spl[2] in main.alias.keys():
|
|
|
|
failure("Alias already exists: %s" % spl[2])
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
main.alias[spl[2]] = {"nick": spl[3],
|
2019-01-26 01:57:24 +00:00
|
|
|
"altnick": spl[4],
|
|
|
|
"ident": spl[5],
|
|
|
|
"realname": spl[6],
|
|
|
|
"password": spl[7]}
|
2019-01-20 19:56:54 +00:00
|
|
|
success("Successfully created alias: %s" % spl[2])
|
|
|
|
main.saveConf("alias")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage("alias")
|
|
|
|
return
|
|
|
|
|
|
|
|
elif length == 3:
|
|
|
|
if spl[1] == "del":
|
|
|
|
if spl[2] in main.alias.keys():
|
|
|
|
del main.alias[spl[2]]
|
|
|
|
success("Successfully removed alias: %s" % spl[2])
|
|
|
|
main.saveConf("alias")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
failure("No such alias: %s" % spl[2])
|
|
|
|
return
|
2019-08-10 10:44:31 +00:00
|
|
|
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
|
2019-01-20 19:56:54 +00:00
|
|
|
else:
|
|
|
|
incUsage("alias")
|
|
|
|
return
|
|
|
|
elif length == 2:
|
|
|
|
if spl[1] == "list":
|
|
|
|
info(dump(main.alias))
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage("alias")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage("alias")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage(None)
|