monolith/commands/alias.py

53 lines
1.9 KiB
Python
Raw Normal View History

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:
if length == 8:
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],
"altnick": spl[4],
"ident": spl[5],
"realname": spl[6],
"password": spl[7]}
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)