2019-01-20 19:56:54 +00:00
|
|
|
import main
|
|
|
|
from yaml import dump
|
|
|
|
|
|
|
|
class Alias:
|
|
|
|
def __init__(self, register):
|
|
|
|
register("alias", self.alias)
|
|
|
|
|
|
|
|
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
|
|
|
|
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)
|