Import the main module properly and fix some oddities in Twisted to prevent it from discarding some data
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
import core.helper as helper
|
||||
|
||||
class Add:
|
||||
@@ -27,32 +27,32 @@ class Add:
|
||||
|
||||
toFail = False
|
||||
if length < 6:
|
||||
if config["Default"]["nickname"] == None:
|
||||
if main.config["Default"]["nickname"] == None:
|
||||
failure("Choose a nickname, or configure one in defaults")
|
||||
toFail = True
|
||||
else:
|
||||
nickname = config["Default"]["nickname"]
|
||||
nickname = main.config["Default"]["nickname"]
|
||||
|
||||
if length < 5:
|
||||
if config["Default"]["protocol"] == None:
|
||||
if main.config["Default"]["protocol"] == None:
|
||||
failure("Choose a protocol, or configure one in defaults")
|
||||
toFail = True
|
||||
else:
|
||||
protocol = config["Default"]["protocol"]
|
||||
protocol = main.config["Default"]["protocol"]
|
||||
|
||||
if length < 4:
|
||||
if config["Default"]["port"] == None:
|
||||
if main.config["Default"]["port"] == None:
|
||||
failure("Choose a port, or configure one in defaults")
|
||||
toFail = True
|
||||
else:
|
||||
port = config["Default"]["port"]
|
||||
port = main.config["Default"]["port"]
|
||||
|
||||
if length < 3:
|
||||
if config["Default"]["host"] == None:
|
||||
if main.config["Default"]["host"] == None:
|
||||
failure("Choose a host, or configure one in defaults")
|
||||
toFail = True
|
||||
else:
|
||||
host = config["Default"]["host"]
|
||||
host = main.config["Default"]["host"]
|
||||
if toFail:
|
||||
failure("Stopping due to previous error(s)")
|
||||
return
|
||||
@@ -61,7 +61,7 @@ class Add:
|
||||
incUsage("add")
|
||||
return
|
||||
|
||||
if name in pool.keys():
|
||||
if name in main.pool.keys():
|
||||
failure("Name already exists: %s" % name)
|
||||
return
|
||||
|
||||
@@ -77,34 +77,34 @@ class Add:
|
||||
failure("Port must be an integer, not %s" % port)
|
||||
return
|
||||
|
||||
pool[name] = { "host": host,
|
||||
main.pool[name] = { "host": host,
|
||||
"port": port,
|
||||
"protocol": protocol,
|
||||
"bind": config["Default"]["bind"],
|
||||
"timeout": config["Default"]["timeout"],
|
||||
"maxdelay": config["Default"]["maxdelay"],
|
||||
"initialdelay": config["Default"]["initialdelay"],
|
||||
"factor": config["Default"]["factor"],
|
||||
"jitter": config["Default"]["jitter"],
|
||||
"bind": main.config["Default"]["bind"],
|
||||
"timeout": main.config["Default"]["timeout"],
|
||||
"maxdelay": main.config["Default"]["maxdelay"],
|
||||
"initialdelay": main.config["Default"]["initialdelay"],
|
||||
"factor": main.config["Default"]["factor"],
|
||||
"jitter": main.config["Default"]["jitter"],
|
||||
"nickname": nickname,
|
||||
"username": config["Default"]["username"],
|
||||
"realname": config["Default"]["realname"],
|
||||
"userinfo": config["Default"]["userinfo"],
|
||||
"finger": config["Default"]["finger"],
|
||||
"version": config["Default"]["version"],
|
||||
"source": config["Default"]["source"],
|
||||
"autojoin": config["Default"]["autojoin"],
|
||||
"authtype": config["Default"]["authtype"],
|
||||
"password": config["Default"]["password"],
|
||||
"authentity": config["Default"]["authentity"],
|
||||
"key": config["Default"]["key"],
|
||||
"certificate": config["Default"]["certificate"],
|
||||
"enabled": config["ConnectOnCreate"],
|
||||
"username": main.config["Default"]["username"],
|
||||
"realname": main.config["Default"]["realname"],
|
||||
"userinfo": main.config["Default"]["userinfo"],
|
||||
"finger": main.config["Default"]["finger"],
|
||||
"version": main.config["Default"]["version"],
|
||||
"source": main.config["Default"]["source"],
|
||||
"autojoin": main.config["Default"]["autojoin"],
|
||||
"authtype": main.config["Default"]["authtype"],
|
||||
"password": main.config["Default"]["password"],
|
||||
"authentity": main.config["Default"]["authentity"],
|
||||
"key": main.config["Default"]["key"],
|
||||
"certificate": main.config["Default"]["certificate"],
|
||||
"enabled": main.config["ConnectOnCreate"],
|
||||
}
|
||||
if config["ConnectOnCreate"] == True:
|
||||
helper.addBot(name)
|
||||
success("Successfully created bot")
|
||||
saveConf("pool")
|
||||
main.saveConf("pool")
|
||||
return
|
||||
else:
|
||||
incUsage(None)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
|
||||
class Default:
|
||||
def __init__(self, register):
|
||||
@@ -9,18 +9,18 @@ class Default:
|
||||
toUnset = False
|
||||
if length == 1:
|
||||
optionMap = ["Viewing defaults"]
|
||||
for i in config["Default"].keys():
|
||||
optionMap.append("%s: %s" % (i, config["Default"][i]))
|
||||
for i in main.config["Default"].keys():
|
||||
optionMap.append("%s: %s" % (i, main.config["Default"][i]))
|
||||
info("\n".join(optionMap))
|
||||
return
|
||||
elif length == 2:
|
||||
if not spl[1] in config["Default"].keys():
|
||||
if not spl[1] in main.config["Default"].keys():
|
||||
failure("No such key: %s" % spl[1])
|
||||
return
|
||||
info("%s: %s" % (spl[1], config["Default"][spl[1]]))
|
||||
info("%s: %s" % (spl[1], main.config["Default"][spl[1]]))
|
||||
return
|
||||
elif length == 3:
|
||||
if not spl[1] in config["Default"].keys():
|
||||
if not spl[1] in main.config["Default"].keys():
|
||||
failure("No such key: %s" % spl[1])
|
||||
return
|
||||
|
||||
@@ -48,7 +48,7 @@ class Default:
|
||||
failure("Protocol must be ssl or plain, not %s" % spl[2])
|
||||
return
|
||||
|
||||
if spl[2] == config["Default"][spl[1]]:
|
||||
if spl[2] == main.config["Default"][spl[1]]:
|
||||
failure("Value already exists: %s" % spl[2])
|
||||
return
|
||||
|
||||
@@ -58,7 +58,7 @@ class Default:
|
||||
failure("Authtype must be sp or ns, not %s" % spl[2])
|
||||
return
|
||||
if spl[1] == "enabled":
|
||||
failure("Use the ConnectOnCreate config parameter to set this")
|
||||
failure("Use the ConnectOnCreate main.config parameter to set this")
|
||||
return
|
||||
if spl[1] == "autojoin":
|
||||
if not toUnset:
|
||||
@@ -66,8 +66,8 @@ class Default:
|
||||
else:
|
||||
spl[2] = []
|
||||
|
||||
config["Default"][spl[1]] = spl[2]
|
||||
saveConf("config")
|
||||
main.config["Default"][spl[1]] = spl[2]
|
||||
main.saveConf("main.config")
|
||||
if toUnset:
|
||||
success("Successfully unset key %s" % spl[1])
|
||||
else:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
|
||||
class Delete:
|
||||
def __init__(self, register):
|
||||
@@ -7,20 +7,20 @@ class Delete:
|
||||
def delete(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
if length == 2:
|
||||
if not spl[1] in pool.keys():
|
||||
if not spl[1] in main.pool.keys():
|
||||
failure("Name does not exist: %s" % spl[1])
|
||||
return
|
||||
del pool[spl[1]]
|
||||
if spl[1] in ReactorPool.keys():
|
||||
if spl[1] in FactoryPool.keys():
|
||||
FactoryPool[spl[1]].stopTrying()
|
||||
ReactorPool[spl[1]].disconnect()
|
||||
if spl[1] in IRCPool.keys():
|
||||
del IRCPool[spl[1]]
|
||||
del ReactorPool[spl[1]]
|
||||
del FactoryPool[spl[1]]
|
||||
if spl[1] in main.ReactorPool.keys():
|
||||
if spl[1] in main.FactoryPool.keys():
|
||||
main.FactoryPool[spl[1]].stopTrying()
|
||||
main.ReactorPool[spl[1]].disconnect()
|
||||
if spl[1] in main.IRCPool.keys():
|
||||
del main.IRCPool[spl[1]]
|
||||
del main.ReactorPool[spl[1]]
|
||||
del main.FactoryPool[spl[1]]
|
||||
success("Successfully removed bot")
|
||||
saveConf("pool")
|
||||
main.saveConf("pool")
|
||||
return
|
||||
else:
|
||||
incUsage("del")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
|
||||
class Disable:
|
||||
def __init__(self, register):
|
||||
@@ -7,19 +7,19 @@ class Disable:
|
||||
def disable(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
if length == 2:
|
||||
if not spl[1] in pool.keys():
|
||||
if not spl[1] in main.pool.keys():
|
||||
failure("Name does not exist: %s" % spl[1])
|
||||
return
|
||||
pool[spl[1]]["enabled"] = False
|
||||
saveConf("pool")
|
||||
if spl[1] in ReactorPool.keys():
|
||||
if spl[1] in FactoryPool.keys():
|
||||
FactoryPool[spl[1]].stopTrying()
|
||||
ReactorPool[spl[1]].disconnect()
|
||||
if spl[1] in IRCPool.keys():
|
||||
del IRCPool[spl[1]]
|
||||
del ReactorPool[spl[1]]
|
||||
del FactoryPool[spl[1]]
|
||||
main.pool[spl[1]]["enabled"] = False
|
||||
main.saveConf("pool")
|
||||
if spl[1] in main.ReactorPool.keys():
|
||||
if spl[1] in main.FactoryPool.keys():
|
||||
main.FactoryPool[spl[1]].stopTrying()
|
||||
main.ReactorPool[spl[1]].disconnect()
|
||||
if spl[1] in main.IRCPool.keys():
|
||||
del main.IRCPool[spl[1]]
|
||||
del main.ReactorPool[spl[1]]
|
||||
del main.FactoryPool[spl[1]]
|
||||
success("Successfully disabled bot %s" % spl[1])
|
||||
return
|
||||
else:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
from subprocess import run, PIPE
|
||||
|
||||
class Dist:
|
||||
@@ -7,9 +7,9 @@ class Dist:
|
||||
|
||||
def dist(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
if config["Dist"]["Enabled"]:
|
||||
rtrn = run([config["Dist"]["File"]], shell=True, stdout=PIPE)
|
||||
if config["Dist"]["SendOutput"]:
|
||||
if main.config["Dist"]["Enabled"]:
|
||||
rtrn = run([main.config["Dist"]["File"]], shell=True, stdout=PIPE)
|
||||
if main.config["Dist"]["SendOutput"]:
|
||||
info("Exit code: %s -- Stdout: %s" % (rtrn.returncode, rtrn.stdout))
|
||||
else:
|
||||
info("Exit code: %s" % rtrn.returncode)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
import core.helper as helper
|
||||
|
||||
class Enable:
|
||||
@@ -11,9 +11,9 @@ class Enable:
|
||||
if not spl[1] in pool.keys():
|
||||
failure("Name does not exist: %s" % spl[1])
|
||||
return
|
||||
pool[spl[1]]["enabled"] = True
|
||||
saveConf("pool")
|
||||
if not spl[1] in IRCPool.keys():
|
||||
main.pool[spl[1]]["enabled"] = True
|
||||
main.saveConf("pool")
|
||||
if not spl[1] in main.IRCPool.keys():
|
||||
helper.addBot(spl[1])
|
||||
else:
|
||||
pass
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
|
||||
class Get:
|
||||
def __init__(self, register):
|
||||
@@ -7,13 +7,13 @@ class Get:
|
||||
def get(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
if length == 3:
|
||||
if not spl[1] in pool.keys():
|
||||
if not spl[1] in main.pool.keys():
|
||||
failure("Name does not exist: %s" % spl[1])
|
||||
return
|
||||
if not spl[1] in IRCPool.keys():
|
||||
if not spl[1] in main.IRCPool.keys():
|
||||
failure("Name has no instance: %s" % spl[1])
|
||||
return
|
||||
info(str(IRCPool[spl[1]].get(spl[2])))
|
||||
info(str(main.IRCPool[spl[1]].get(spl[2])))
|
||||
return
|
||||
else:
|
||||
incUsage("get")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
|
||||
class Help:
|
||||
def __init__(self, register):
|
||||
@@ -7,8 +7,8 @@ class Help:
|
||||
def help(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
helpMap = []
|
||||
for i in help.keys():
|
||||
helpMap.append("%s: %s" % (i, help[i]))
|
||||
for i in main.help.keys():
|
||||
helpMap.append("%s: %s" % (i, main.help[i]))
|
||||
info("\n".join(helpMap))
|
||||
return
|
||||
else:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
|
||||
class Join:
|
||||
def __init__(self, register):
|
||||
@@ -7,23 +7,23 @@ class Join:
|
||||
def join(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
if length == 3:
|
||||
if not spl[1] in pool.keys():
|
||||
if not spl[1] in main.pool.keys():
|
||||
failure("Name does not exist: %s" % spl[1])
|
||||
return
|
||||
if not spl[1] in IRCPool.keys():
|
||||
if not spl[1] in main.IRCPool.keys():
|
||||
failure("Name has no instance: %s" % spl[1])
|
||||
return
|
||||
IRCPool[spl[1]].join(spl[2])
|
||||
main.IRCPool[spl[1]].join(spl[2])
|
||||
success("Joined %s" % spl[2])
|
||||
return
|
||||
elif length == 4:
|
||||
if not spl[1] in pool.keys():
|
||||
if not spl[1] in main.pool.keys():
|
||||
failure("Name does not exist: %s" % spl[1])
|
||||
return
|
||||
if not spl[1] in IRCPool.keys():
|
||||
if not spl[1] in main.IRCPool.keys():
|
||||
failure("Name has no instance: %s" % spl[1])
|
||||
return
|
||||
IRCPool[spl[1]].join(spl[2], spl[3])
|
||||
main.IRCPool[spl[1]].join(spl[2], spl[3])
|
||||
success("Joined %s with key %s" % (spl[2], spl[3]))
|
||||
return
|
||||
else:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
import modules.keyword as keyword
|
||||
|
||||
class Key:
|
||||
@@ -39,45 +39,45 @@ class Key:
|
||||
return
|
||||
if length == 4:
|
||||
if spl[1] == "except":
|
||||
if not spl[2] in keyconf["Keywords"]:
|
||||
if not spl[2] in main.keyconf["Keywords"]:
|
||||
failure("No such keyword: %s" % spl[2])
|
||||
return
|
||||
if spl[2] in keyconf["KeywordsExcept"].keys():
|
||||
if spl[3] in keyconf["KeywordsExcept"][spl[2]]:
|
||||
if spl[2] in main.keyconf["KeywordsExcept"].keys():
|
||||
if spl[3] in main.keyconf["KeywordsExcept"][spl[2]]:
|
||||
failure("Exception exists: %s" % spl[3])
|
||||
return
|
||||
else:
|
||||
if not spl[2] in spl[3]:
|
||||
failure("Keyword %s not in exception %s. This won't work" % (spl[2], spl[3]))
|
||||
return
|
||||
keyconf["KeywordsExcept"][spl[2]] = []
|
||||
main.keyconf["KeywordsExcept"][spl[2]] = []
|
||||
|
||||
keyconf["KeywordsExcept"][spl[2]].append(spl[3])
|
||||
saveConf("keyconf")
|
||||
main.keyconf["KeywordsExcept"][spl[2]].append(spl[3])
|
||||
main.saveConf("keyconf")
|
||||
success("Successfully added exception %s for keyword %s" % (spl[3], spl[2]))
|
||||
return
|
||||
elif spl[1] == "master":
|
||||
if not spl[2] in pool.keys():
|
||||
if not spl[2] in main.pool.keys():
|
||||
failure("Name does not exist: %s" % spl[2])
|
||||
return
|
||||
if spl[2] in IRCPool.keys():
|
||||
if not spl[3] in IRCPool[spl[2]].channels:
|
||||
if spl[2] in main.IRCPool.keys():
|
||||
if not spl[3] in main.IRCPool[spl[2]].channels:
|
||||
info("Bot not on channel: %s" % spl[3])
|
||||
config["Master"] = [spl[2], spl[3]]
|
||||
saveConf("config")
|
||||
main.config["Master"] = [spl[2], spl[3]]
|
||||
main.saveConf("config")
|
||||
success("Master set to %s on %s" % (spl[3], spl[2]))
|
||||
return
|
||||
elif spl[1] == "unexcept":
|
||||
if not spl[2] in keyconf["KeywordsExcept"].keys():
|
||||
if not spl[2] in main.keyconf["KeywordsExcept"].keys():
|
||||
failure("No such exception: %s" % spl[2])
|
||||
return
|
||||
if not spl[3] in keyconf["KeywordsExcept"][spl[2]]:
|
||||
if not spl[3] in main.keyconf["KeywordsExcept"][spl[2]]:
|
||||
failure("Exception %s has no attribute %s" % (spl[2], spl[3]))
|
||||
return
|
||||
keyconf["KeywordsExcept"][spl[2]].remove(spl[3])
|
||||
if keyconf["KeywordsExcept"][spl[2]] == []:
|
||||
del keyconf["KeywordsExcept"][spl[2]]
|
||||
saveConf("keyconf")
|
||||
main.keyconf["KeywordsExcept"][spl[2]].remove(spl[3])
|
||||
if main.keyconf["KeywordsExcept"][spl[2]] == []:
|
||||
del main.keyconf["KeywordsExcept"][spl[2]]
|
||||
main.saveConf("keyconf")
|
||||
success("Successfully removed exception %s for keyword %s" % (spl[3], spl[2]))
|
||||
return
|
||||
else:
|
||||
@@ -85,32 +85,32 @@ class Key:
|
||||
return
|
||||
elif length == 3:
|
||||
if spl[1] == "unexcept":
|
||||
if not spl[2] in keyconf["KeywordsExcept"].keys():
|
||||
if not spl[2] in main.keyconf["KeywordsExcept"].keys():
|
||||
failure("No such exception: %s" % spl[2])
|
||||
return
|
||||
del keyconf["KeywordsExcept"][spl[2]]
|
||||
saveConf("keyconf")
|
||||
del main.keyconf["KeywordsExcept"][spl[2]]
|
||||
main.saveConf("keyconf")
|
||||
success("Successfully removed exception list of %s" % spl[2])
|
||||
return
|
||||
elif spl[1] == "monitor":
|
||||
if spl[2] == "on":
|
||||
if not obj.addr in MonitorPool:
|
||||
MonitorPool.append(obj.addr)
|
||||
if not obj.addr in main.MonitorPool:
|
||||
main.MonitorPool.append(obj.addr)
|
||||
success("Keyword monitoring enabled")
|
||||
if len(masterbuf) == 0:
|
||||
if len(main.masterbuf) == 0:
|
||||
return
|
||||
rtrn = []
|
||||
for i in range(len(masterbuf)):
|
||||
rtrn.append(masterbuf.pop(0))
|
||||
saveConf("masterbuf")
|
||||
for i in range(len(main.masterbuf)):
|
||||
rtrn.append(main.masterbuf.pop(0))
|
||||
main.saveConf("masterbuf")
|
||||
info("\n".join(rtrn))
|
||||
return
|
||||
else:
|
||||
failure("Keyword monitoring is already enabled")
|
||||
return
|
||||
elif spl[2] == "off":
|
||||
if obj.addr in MonitorPool:
|
||||
MonitorPool.remove(obj.addr)
|
||||
if obj.addr in main.MonitorPool:
|
||||
main.MonitorPool.remove(obj.addr)
|
||||
success("Keyword monitoring disabled")
|
||||
return
|
||||
else:
|
||||
@@ -124,22 +124,22 @@ class Key:
|
||||
return
|
||||
elif length == 2:
|
||||
if spl[1] == "show":
|
||||
info(",".join(keyconf["Keywords"]))
|
||||
info(",".join(main.keyconf["Keywords"]))
|
||||
return
|
||||
|
||||
elif spl[1] == "showexcept":
|
||||
exceptMap = []
|
||||
for i in keyconf["KeywordsExcept"].keys():
|
||||
for i in main.keyconf["KeywordsExcept"].keys():
|
||||
exceptMap.append("Key: %s" % i)
|
||||
exceptMap.append("%s: %s" % (i, ",".join(keyconf["KeywordsExcept"][i])))
|
||||
exceptMap.append("%s: %s" % (i, ",".join(main.keyconf["KeywordsExcept"][i])))
|
||||
exceptMap.append("\n")
|
||||
info("\n".join(exceptMap))
|
||||
return
|
||||
elif spl[1] == "master":
|
||||
info(" - ".join([str(i) for i in config["Master"]]))
|
||||
info(" - ".join([str(i) for i in main.config["Master"]]))
|
||||
return
|
||||
elif spl[1] == "monitor":
|
||||
if obj.addr in MonitorPool:
|
||||
if obj.addr in main.MonitorPool:
|
||||
info("Keyword monitoring is enabled on this connection")
|
||||
return
|
||||
else:
|
||||
@@ -148,7 +148,6 @@ class Key:
|
||||
else:
|
||||
incUsage("key")
|
||||
return
|
||||
|
||||
else:
|
||||
incUsage("key")
|
||||
return
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
|
||||
class List:
|
||||
def __init__(self, register):
|
||||
@@ -7,10 +7,10 @@ class List:
|
||||
def list(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
poolMap = []
|
||||
for i in pool.keys():
|
||||
for i in main.pool.keys():
|
||||
poolMap.append("Server: %s" % i)
|
||||
for x in pool[i].keys():
|
||||
poolMap.append(" %s: %s" % (x, pool[i][x]))
|
||||
for x in main.pool[i].keys():
|
||||
poolMap.append(" %s: %s" % (x, main.pool[i][x]))
|
||||
poolMap.append("\n")
|
||||
info("\n".join(poolMap))
|
||||
return
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
|
||||
class Load:
|
||||
def __init__(self, register):
|
||||
@@ -7,14 +7,14 @@ class Load:
|
||||
def load(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
if length == 2:
|
||||
if spl[1] in filemap.keys():
|
||||
loadConf(spl[1])
|
||||
success("Loaded %s from %s" % (spl[1], filemap[spl[1]][0]))
|
||||
if spl[1] in main.filemap.keys():
|
||||
main.loadConf(spl[1])
|
||||
success("Loaded %s from %s" % (spl[1], main.filemap[spl[1]][0]))
|
||||
return
|
||||
elif spl[1] == "all":
|
||||
for i in filemap.keys():
|
||||
loadConf(i)
|
||||
success("Loaded %s from %s" % (i, filemap[i][0]))
|
||||
for i in main.filemap.keys():
|
||||
main.loadConf(i)
|
||||
success("Loaded %s from %s" % (i, main.filemap[i][0]))
|
||||
return
|
||||
else:
|
||||
incUsage("load")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
from utils.loaders.single_loader import loadSingle
|
||||
|
||||
class Loadmod:
|
||||
@@ -8,7 +8,7 @@ class Loadmod:
|
||||
def loadmod(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
if length == 2:
|
||||
rtrn = loadSingle(spl[1], register)
|
||||
rtrn = loadSingle(spl[1], main.register)
|
||||
if rtrn == True:
|
||||
success("Loaded module %s" % spl[1])
|
||||
return
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
|
||||
class Logout:
|
||||
def __init__(self, register):
|
||||
@@ -7,8 +7,8 @@ class Logout:
|
||||
def logout(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
obj.authed = False
|
||||
if obj.addr in MonitorPool:
|
||||
MonitorPool.remove(obj.addr)
|
||||
if obj.addr in main.MonitorPool:
|
||||
main.MonitorPool.remove(obj.addr)
|
||||
success("Logged out")
|
||||
return
|
||||
else:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
|
||||
class Mod:
|
||||
def __init__(self, register):
|
||||
@@ -8,30 +8,30 @@ class Mod:
|
||||
if authed:
|
||||
toUnset = False
|
||||
if length == 2:
|
||||
if not spl[1] in pool.keys():
|
||||
if not spl[1] in main.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():
|
||||
optionMap.append(" %s: %s" % (i, pool[spl[1]][i]))
|
||||
for i in main.pool[spl[1]].keys():
|
||||
optionMap.append(" %s: %s" % (i, main.pool[spl[1]][i]))
|
||||
info("\n".join(optionMap))
|
||||
return
|
||||
|
||||
elif length == 3:
|
||||
if not spl[1] in pool.keys():
|
||||
if not spl[1] in main.pool.keys():
|
||||
failure("Name does not exist: %s" % spl[1])
|
||||
return
|
||||
if not spl[2] in pool[spl[1]].keys():
|
||||
if not spl[2] in main.pool[spl[1]].keys():
|
||||
failure("No such key: %s" % spl[2])
|
||||
return
|
||||
info("%s: %s" % (spl[2], pool[spl[1]][spl[2]]))
|
||||
info("%s: %s" % (spl[2], main.pool[spl[1]][spl[2]]))
|
||||
return
|
||||
|
||||
elif length == 4:
|
||||
if not spl[1] in pool.keys():
|
||||
if not spl[1] in main.pool.keys():
|
||||
failure("Name does not exist: %s" % spl[1])
|
||||
return
|
||||
if not spl[2] in pool[spl[1]].keys():
|
||||
if not spl[2] in main.pool[spl[1]].keys():
|
||||
failure("No such key: %s" % spl[2])
|
||||
return
|
||||
|
||||
@@ -39,7 +39,7 @@ class Mod:
|
||||
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]]:
|
||||
if spl[3] == main.pool[spl[1]][spl[2]]:
|
||||
failure("Value already exists: %s" % spl[3])
|
||||
return
|
||||
|
||||
@@ -72,10 +72,10 @@ class Mod:
|
||||
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")
|
||||
main.pool[spl[1]][spl[2]] = spl[3]
|
||||
if spl[1] in main.IRCPool.keys():
|
||||
main.IRCPool[spl[1]].refresh()
|
||||
main.saveConf("pool")
|
||||
if toUnset:
|
||||
success("Successfully unset key %s on %s" % (spl[2], spl[1]))
|
||||
else:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
|
||||
class Part:
|
||||
def __init__(self, register):
|
||||
@@ -7,13 +7,13 @@ class Part:
|
||||
def part(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
if length == 3:
|
||||
if not spl[1] in pool.keys():
|
||||
if not spl[1] in main.pool.keys():
|
||||
failure("Name does not exist: %s" % spl[1])
|
||||
return
|
||||
if not spl[1] in IRCPool.keys():
|
||||
if not spl[1] in main.IRCPool.keys():
|
||||
failure("Name has no instance: %s" % spl[1])
|
||||
return
|
||||
IRCPool[spl[1]].part(spl[2])
|
||||
main.IRCPool[spl[1]].part(spl[2])
|
||||
success("Left %s" % spl[2])
|
||||
return
|
||||
else:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
|
||||
class Password:
|
||||
def __init__(self, register):
|
||||
@@ -10,7 +10,7 @@ class Password:
|
||||
return
|
||||
else:
|
||||
if length == 2:
|
||||
if spl[1] == config["Password"]:
|
||||
if spl[1] == main.config["Password"]:
|
||||
success("Authenticated successfully")
|
||||
obj.authed = True
|
||||
return
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
|
||||
class Save:
|
||||
def __init__(self, register):
|
||||
@@ -7,14 +7,14 @@ class Save:
|
||||
def save(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
if length == 2:
|
||||
if spl[1] in filemap.keys():
|
||||
saveConf(spl[1])
|
||||
success("Saved %s to %s" % (spl[1], filemap[spl[1]][0]))
|
||||
if spl[1] in main.filemap.keys():
|
||||
main.saveConf(spl[1])
|
||||
success("Saved %s to %s" % (spl[1], main.filemap[spl[1]][0]))
|
||||
return
|
||||
elif spl[1] == "all":
|
||||
for i in filemap.keys():
|
||||
saveConf(i)
|
||||
success("Saved %s to %s" % (i, filemap[i][0]))
|
||||
for i in main.filemap.keys():
|
||||
main.saveConf(i)
|
||||
success("Saved %s to %s" % (i, main.filemap[i][0]))
|
||||
return
|
||||
else:
|
||||
incUsage("save")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
import modules.counters as count
|
||||
|
||||
class Stats:
|
||||
@@ -11,11 +11,11 @@ class Stats:
|
||||
stats = []
|
||||
numChannels = 0
|
||||
numWhoEntries = 0
|
||||
for i in IRCPool.keys():
|
||||
numChannels += len(IRCPool[i].channels)
|
||||
for i in wholist.keys():
|
||||
numWhoEntries += len(wholist[i].keys())
|
||||
stats.append("Servers: %s" % len(IRCPool.keys()))
|
||||
for i in main.IRCPool.keys():
|
||||
numChannels += len(main.IRCPool[i].channels)
|
||||
for i in main.wholist.keys():
|
||||
numWhoEntries += len(main.wholist[i].keys())
|
||||
stats.append("Servers: %s" % len(main.IRCPool.keys()))
|
||||
stats.append("Channels: %s" % numChannels)
|
||||
stats.append("User records: %s" % numWhoEntries)
|
||||
counterEvents = count.getEvents()
|
||||
@@ -34,13 +34,13 @@ class Stats:
|
||||
numWhoEntries = 0
|
||||
|
||||
failures = 0
|
||||
if spl[1] in IRCPool.keys():
|
||||
numChannels += len(IRCPool[spl[1]].channels)
|
||||
if spl[1] in main.IRCPool.keys():
|
||||
numChannels += len(main.IRCPool[spl[1]].channels)
|
||||
else:
|
||||
failure("Name does not exist: %s" % spl[1])
|
||||
failures += 1
|
||||
if spl[1] in wholist.keys():
|
||||
numWhoEntries += len(wholist[spl[1]].keys())
|
||||
if spl[1] in main.wholist.keys():
|
||||
numWhoEntries += len(main.wholist[spl[1]].keys())
|
||||
else:
|
||||
failure("Who entry does not exist: %s" % spl[1])
|
||||
failures += 1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
import modules.userinfo as userinfo
|
||||
|
||||
class Who:
|
||||
|
||||
Reference in New Issue
Block a user