2018-02-23 22:05:40 +00:00
|
|
|
from core.main import *
|
|
|
|
|
|
|
|
class Mod:
|
|
|
|
def __init__(self, register):
|
|
|
|
register("mod", self.mod)
|
|
|
|
|
|
|
|
def mod(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
|
|
|
if authed:
|
|
|
|
toUnset = False
|
|
|
|
if length == 2:
|
|
|
|
if not spl[1] in pool.keys():
|
|
|
|
failure("Name does not exist: %s" % spl[1])
|
|
|
|
return
|
|
|
|
optionMap = ["Viewing options for %s" % spl[1]]
|
|
|
|
for i in pool[spl[1]].keys():
|
2018-02-24 12:42:27 +00:00
|
|
|
optionMap.append(" %s: %s" % (i, pool[spl[1]][i]))
|
2018-02-23 22:05:40 +00:00
|
|
|
info("\n".join(optionMap))
|
|
|
|
return
|
|
|
|
|
|
|
|
elif length == 3:
|
|
|
|
if not spl[1] in pool.keys():
|
|
|
|
failure("Name does not exist: %s" % spl[1])
|
|
|
|
return
|
|
|
|
if not spl[2] in pool[spl[1]].keys():
|
|
|
|
failure("No such key: %s" % spl[2])
|
|
|
|
return
|
|
|
|
info("%s: %s" % (spl[2], pool[spl[1]][spl[2]]))
|
|
|
|
return
|
|
|
|
|
|
|
|
elif length == 4:
|
|
|
|
if not spl[1] in pool.keys():
|
|
|
|
failure("Name does not exist: %s" % spl[1])
|
|
|
|
return
|
|
|
|
if not spl[2] in pool[spl[1]].keys():
|
|
|
|
failure("No such key: %s" % spl[2])
|
|
|
|
return
|
|
|
|
|
|
|
|
if spl[2] == "protocol":
|
|
|
|
if not spl[3] in ["ssl", "plain"]:
|
|
|
|
failure("Protocol must be ssl or plain, not %s" % spl[3])
|
|
|
|
return
|
|
|
|
if spl[3] == pool[spl[1]][spl[2]]:
|
|
|
|
failure("Value already exists: %s" % spl[3])
|
|
|
|
return
|
|
|
|
|
|
|
|
if spl[3].lower() in ["none", "nil"]:
|
|
|
|
spl[3] = None
|
|
|
|
toUnset = True
|
|
|
|
|
|
|
|
if spl[2] in ["port", "timeout", "maxdelay"]:
|
|
|
|
try:
|
|
|
|
spl[3] = int(spl[3])
|
|
|
|
except:
|
|
|
|
failure("Value must be an integer, not %s" % spl[3])
|
|
|
|
return
|
|
|
|
|
|
|
|
if spl[2] in ["initialdelay", "factor", "jitter"]:
|
|
|
|
try:
|
|
|
|
spl[3] = float(spl[3])
|
|
|
|
except:
|
|
|
|
failure("Value must be a floating point integer, not %s" % spl[3])
|
|
|
|
return
|
|
|
|
|
|
|
|
if spl[2] == "authtype":
|
|
|
|
if not toUnset:
|
|
|
|
if not spl[3] in ["sp", "ns"]:
|
|
|
|
failure("Authtype must be sp or ns, not %s" % spl[3])
|
|
|
|
return
|
|
|
|
if spl[2] == "enabled":
|
|
|
|
failure("Use the enable and disable commands to manage this")
|
|
|
|
return
|
|
|
|
if spl[2] == "autojoin":
|
|
|
|
spl[3] = spl[3].split(",")
|
|
|
|
|
|
|
|
pool[spl[1]][spl[2]] = spl[3]
|
|
|
|
if spl[1] in IRCPool.keys():
|
|
|
|
IRCPool[spl[1]].refresh()
|
|
|
|
saveConf("pool")
|
|
|
|
if toUnset:
|
|
|
|
success("Successfully unset key %s on %s" % (spl[2], spl[1]))
|
|
|
|
else:
|
|
|
|
success("Successfully set key %s to %s on %s" % (spl[2], spl[3], spl[1]))
|
|
|
|
return
|
|
|
|
|
|
|
|
else:
|
|
|
|
incUsage("mod")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage(None)
|