Import the main module properly and fix some oddities in Twisted to prevent it from discarding some data
This commit is contained in:
parent
5b1e3c6fb1
commit
d168d69732
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
import core.helper as helper
|
import core.helper as helper
|
||||||
|
|
||||||
class Add:
|
class Add:
|
||||||
|
@ -27,32 +27,32 @@ class Add:
|
||||||
|
|
||||||
toFail = False
|
toFail = False
|
||||||
if length < 6:
|
if length < 6:
|
||||||
if config["Default"]["nickname"] == None:
|
if main.config["Default"]["nickname"] == None:
|
||||||
failure("Choose a nickname, or configure one in defaults")
|
failure("Choose a nickname, or configure one in defaults")
|
||||||
toFail = True
|
toFail = True
|
||||||
else:
|
else:
|
||||||
nickname = config["Default"]["nickname"]
|
nickname = main.config["Default"]["nickname"]
|
||||||
|
|
||||||
if length < 5:
|
if length < 5:
|
||||||
if config["Default"]["protocol"] == None:
|
if main.config["Default"]["protocol"] == None:
|
||||||
failure("Choose a protocol, or configure one in defaults")
|
failure("Choose a protocol, or configure one in defaults")
|
||||||
toFail = True
|
toFail = True
|
||||||
else:
|
else:
|
||||||
protocol = config["Default"]["protocol"]
|
protocol = main.config["Default"]["protocol"]
|
||||||
|
|
||||||
if length < 4:
|
if length < 4:
|
||||||
if config["Default"]["port"] == None:
|
if main.config["Default"]["port"] == None:
|
||||||
failure("Choose a port, or configure one in defaults")
|
failure("Choose a port, or configure one in defaults")
|
||||||
toFail = True
|
toFail = True
|
||||||
else:
|
else:
|
||||||
port = config["Default"]["port"]
|
port = main.config["Default"]["port"]
|
||||||
|
|
||||||
if length < 3:
|
if length < 3:
|
||||||
if config["Default"]["host"] == None:
|
if main.config["Default"]["host"] == None:
|
||||||
failure("Choose a host, or configure one in defaults")
|
failure("Choose a host, or configure one in defaults")
|
||||||
toFail = True
|
toFail = True
|
||||||
else:
|
else:
|
||||||
host = config["Default"]["host"]
|
host = main.config["Default"]["host"]
|
||||||
if toFail:
|
if toFail:
|
||||||
failure("Stopping due to previous error(s)")
|
failure("Stopping due to previous error(s)")
|
||||||
return
|
return
|
||||||
|
@ -61,7 +61,7 @@ class Add:
|
||||||
incUsage("add")
|
incUsage("add")
|
||||||
return
|
return
|
||||||
|
|
||||||
if name in pool.keys():
|
if name in main.pool.keys():
|
||||||
failure("Name already exists: %s" % name)
|
failure("Name already exists: %s" % name)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -77,34 +77,34 @@ class Add:
|
||||||
failure("Port must be an integer, not %s" % port)
|
failure("Port must be an integer, not %s" % port)
|
||||||
return
|
return
|
||||||
|
|
||||||
pool[name] = { "host": host,
|
main.pool[name] = { "host": host,
|
||||||
"port": port,
|
"port": port,
|
||||||
"protocol": protocol,
|
"protocol": protocol,
|
||||||
"bind": config["Default"]["bind"],
|
"bind": main.config["Default"]["bind"],
|
||||||
"timeout": config["Default"]["timeout"],
|
"timeout": main.config["Default"]["timeout"],
|
||||||
"maxdelay": config["Default"]["maxdelay"],
|
"maxdelay": main.config["Default"]["maxdelay"],
|
||||||
"initialdelay": config["Default"]["initialdelay"],
|
"initialdelay": main.config["Default"]["initialdelay"],
|
||||||
"factor": config["Default"]["factor"],
|
"factor": main.config["Default"]["factor"],
|
||||||
"jitter": config["Default"]["jitter"],
|
"jitter": main.config["Default"]["jitter"],
|
||||||
"nickname": nickname,
|
"nickname": nickname,
|
||||||
"username": config["Default"]["username"],
|
"username": main.config["Default"]["username"],
|
||||||
"realname": config["Default"]["realname"],
|
"realname": main.config["Default"]["realname"],
|
||||||
"userinfo": config["Default"]["userinfo"],
|
"userinfo": main.config["Default"]["userinfo"],
|
||||||
"finger": config["Default"]["finger"],
|
"finger": main.config["Default"]["finger"],
|
||||||
"version": config["Default"]["version"],
|
"version": main.config["Default"]["version"],
|
||||||
"source": config["Default"]["source"],
|
"source": main.config["Default"]["source"],
|
||||||
"autojoin": config["Default"]["autojoin"],
|
"autojoin": main.config["Default"]["autojoin"],
|
||||||
"authtype": config["Default"]["authtype"],
|
"authtype": main.config["Default"]["authtype"],
|
||||||
"password": config["Default"]["password"],
|
"password": main.config["Default"]["password"],
|
||||||
"authentity": config["Default"]["authentity"],
|
"authentity": main.config["Default"]["authentity"],
|
||||||
"key": config["Default"]["key"],
|
"key": main.config["Default"]["key"],
|
||||||
"certificate": config["Default"]["certificate"],
|
"certificate": main.config["Default"]["certificate"],
|
||||||
"enabled": config["ConnectOnCreate"],
|
"enabled": main.config["ConnectOnCreate"],
|
||||||
}
|
}
|
||||||
if config["ConnectOnCreate"] == True:
|
if config["ConnectOnCreate"] == True:
|
||||||
helper.addBot(name)
|
helper.addBot(name)
|
||||||
success("Successfully created bot")
|
success("Successfully created bot")
|
||||||
saveConf("pool")
|
main.saveConf("pool")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
incUsage(None)
|
incUsage(None)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
|
|
||||||
class Default:
|
class Default:
|
||||||
def __init__(self, register):
|
def __init__(self, register):
|
||||||
|
@ -9,18 +9,18 @@ class Default:
|
||||||
toUnset = False
|
toUnset = False
|
||||||
if length == 1:
|
if length == 1:
|
||||||
optionMap = ["Viewing defaults"]
|
optionMap = ["Viewing defaults"]
|
||||||
for i in config["Default"].keys():
|
for i in main.config["Default"].keys():
|
||||||
optionMap.append("%s: %s" % (i, config["Default"][i]))
|
optionMap.append("%s: %s" % (i, main.config["Default"][i]))
|
||||||
info("\n".join(optionMap))
|
info("\n".join(optionMap))
|
||||||
return
|
return
|
||||||
elif length == 2:
|
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])
|
failure("No such key: %s" % spl[1])
|
||||||
return
|
return
|
||||||
info("%s: %s" % (spl[1], config["Default"][spl[1]]))
|
info("%s: %s" % (spl[1], main.config["Default"][spl[1]]))
|
||||||
return
|
return
|
||||||
elif length == 3:
|
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])
|
failure("No such key: %s" % spl[1])
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ class Default:
|
||||||
failure("Protocol must be ssl or plain, not %s" % spl[2])
|
failure("Protocol must be ssl or plain, not %s" % spl[2])
|
||||||
return
|
return
|
||||||
|
|
||||||
if spl[2] == config["Default"][spl[1]]:
|
if spl[2] == main.config["Default"][spl[1]]:
|
||||||
failure("Value already exists: %s" % spl[2])
|
failure("Value already exists: %s" % spl[2])
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class Default:
|
||||||
failure("Authtype must be sp or ns, not %s" % spl[2])
|
failure("Authtype must be sp or ns, not %s" % spl[2])
|
||||||
return
|
return
|
||||||
if spl[1] == "enabled":
|
if spl[1] == "enabled":
|
||||||
failure("Use the ConnectOnCreate config parameter to set this")
|
failure("Use the ConnectOnCreate main.config parameter to set this")
|
||||||
return
|
return
|
||||||
if spl[1] == "autojoin":
|
if spl[1] == "autojoin":
|
||||||
if not toUnset:
|
if not toUnset:
|
||||||
|
@ -66,8 +66,8 @@ class Default:
|
||||||
else:
|
else:
|
||||||
spl[2] = []
|
spl[2] = []
|
||||||
|
|
||||||
config["Default"][spl[1]] = spl[2]
|
main.config["Default"][spl[1]] = spl[2]
|
||||||
saveConf("config")
|
main.saveConf("main.config")
|
||||||
if toUnset:
|
if toUnset:
|
||||||
success("Successfully unset key %s" % spl[1])
|
success("Successfully unset key %s" % spl[1])
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
|
|
||||||
class Delete:
|
class Delete:
|
||||||
def __init__(self, register):
|
def __init__(self, register):
|
||||||
|
@ -7,20 +7,20 @@ class Delete:
|
||||||
def delete(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
def delete(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||||
if authed:
|
if authed:
|
||||||
if length == 2:
|
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])
|
failure("Name does not exist: %s" % spl[1])
|
||||||
return
|
return
|
||||||
del pool[spl[1]]
|
del pool[spl[1]]
|
||||||
if spl[1] in ReactorPool.keys():
|
if spl[1] in main.ReactorPool.keys():
|
||||||
if spl[1] in FactoryPool.keys():
|
if spl[1] in main.FactoryPool.keys():
|
||||||
FactoryPool[spl[1]].stopTrying()
|
main.FactoryPool[spl[1]].stopTrying()
|
||||||
ReactorPool[spl[1]].disconnect()
|
main.ReactorPool[spl[1]].disconnect()
|
||||||
if spl[1] in IRCPool.keys():
|
if spl[1] in main.IRCPool.keys():
|
||||||
del IRCPool[spl[1]]
|
del main.IRCPool[spl[1]]
|
||||||
del ReactorPool[spl[1]]
|
del main.ReactorPool[spl[1]]
|
||||||
del FactoryPool[spl[1]]
|
del main.FactoryPool[spl[1]]
|
||||||
success("Successfully removed bot")
|
success("Successfully removed bot")
|
||||||
saveConf("pool")
|
main.saveConf("pool")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
incUsage("del")
|
incUsage("del")
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
|
|
||||||
class Disable:
|
class Disable:
|
||||||
def __init__(self, register):
|
def __init__(self, register):
|
||||||
|
@ -7,19 +7,19 @@ class Disable:
|
||||||
def disable(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
def disable(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||||
if authed:
|
if authed:
|
||||||
if length == 2:
|
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])
|
failure("Name does not exist: %s" % spl[1])
|
||||||
return
|
return
|
||||||
pool[spl[1]]["enabled"] = False
|
main.pool[spl[1]]["enabled"] = False
|
||||||
saveConf("pool")
|
main.saveConf("pool")
|
||||||
if spl[1] in ReactorPool.keys():
|
if spl[1] in main.ReactorPool.keys():
|
||||||
if spl[1] in FactoryPool.keys():
|
if spl[1] in main.FactoryPool.keys():
|
||||||
FactoryPool[spl[1]].stopTrying()
|
main.FactoryPool[spl[1]].stopTrying()
|
||||||
ReactorPool[spl[1]].disconnect()
|
main.ReactorPool[spl[1]].disconnect()
|
||||||
if spl[1] in IRCPool.keys():
|
if spl[1] in main.IRCPool.keys():
|
||||||
del IRCPool[spl[1]]
|
del main.IRCPool[spl[1]]
|
||||||
del ReactorPool[spl[1]]
|
del main.ReactorPool[spl[1]]
|
||||||
del FactoryPool[spl[1]]
|
del main.FactoryPool[spl[1]]
|
||||||
success("Successfully disabled bot %s" % spl[1])
|
success("Successfully disabled bot %s" % spl[1])
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
from subprocess import run, PIPE
|
from subprocess import run, PIPE
|
||||||
|
|
||||||
class Dist:
|
class Dist:
|
||||||
|
@ -7,9 +7,9 @@ class Dist:
|
||||||
|
|
||||||
def dist(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
def dist(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||||
if authed:
|
if authed:
|
||||||
if config["Dist"]["Enabled"]:
|
if main.config["Dist"]["Enabled"]:
|
||||||
rtrn = run([config["Dist"]["File"]], shell=True, stdout=PIPE)
|
rtrn = run([main.config["Dist"]["File"]], shell=True, stdout=PIPE)
|
||||||
if config["Dist"]["SendOutput"]:
|
if main.config["Dist"]["SendOutput"]:
|
||||||
info("Exit code: %s -- Stdout: %s" % (rtrn.returncode, rtrn.stdout))
|
info("Exit code: %s -- Stdout: %s" % (rtrn.returncode, rtrn.stdout))
|
||||||
else:
|
else:
|
||||||
info("Exit code: %s" % rtrn.returncode)
|
info("Exit code: %s" % rtrn.returncode)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
import core.helper as helper
|
import core.helper as helper
|
||||||
|
|
||||||
class Enable:
|
class Enable:
|
||||||
|
@ -11,9 +11,9 @@ class Enable:
|
||||||
if not spl[1] in pool.keys():
|
if not spl[1] in pool.keys():
|
||||||
failure("Name does not exist: %s" % spl[1])
|
failure("Name does not exist: %s" % spl[1])
|
||||||
return
|
return
|
||||||
pool[spl[1]]["enabled"] = True
|
main.pool[spl[1]]["enabled"] = True
|
||||||
saveConf("pool")
|
main.saveConf("pool")
|
||||||
if not spl[1] in IRCPool.keys():
|
if not spl[1] in main.IRCPool.keys():
|
||||||
helper.addBot(spl[1])
|
helper.addBot(spl[1])
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
|
|
||||||
class Get:
|
class Get:
|
||||||
def __init__(self, register):
|
def __init__(self, register):
|
||||||
|
@ -7,13 +7,13 @@ class Get:
|
||||||
def get(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
def get(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||||
if authed:
|
if authed:
|
||||||
if length == 3:
|
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])
|
failure("Name does not exist: %s" % spl[1])
|
||||||
return
|
return
|
||||||
if not spl[1] in IRCPool.keys():
|
if not spl[1] in main.IRCPool.keys():
|
||||||
failure("Name has no instance: %s" % spl[1])
|
failure("Name has no instance: %s" % spl[1])
|
||||||
return
|
return
|
||||||
info(str(IRCPool[spl[1]].get(spl[2])))
|
info(str(main.IRCPool[spl[1]].get(spl[2])))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
incUsage("get")
|
incUsage("get")
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
|
|
||||||
class Help:
|
class Help:
|
||||||
def __init__(self, register):
|
def __init__(self, register):
|
||||||
|
@ -7,8 +7,8 @@ class Help:
|
||||||
def help(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
def help(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||||
if authed:
|
if authed:
|
||||||
helpMap = []
|
helpMap = []
|
||||||
for i in help.keys():
|
for i in main.help.keys():
|
||||||
helpMap.append("%s: %s" % (i, help[i]))
|
helpMap.append("%s: %s" % (i, main.help[i]))
|
||||||
info("\n".join(helpMap))
|
info("\n".join(helpMap))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
|
|
||||||
class Join:
|
class Join:
|
||||||
def __init__(self, register):
|
def __init__(self, register):
|
||||||
|
@ -7,23 +7,23 @@ class Join:
|
||||||
def join(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
def join(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||||
if authed:
|
if authed:
|
||||||
if length == 3:
|
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])
|
failure("Name does not exist: %s" % spl[1])
|
||||||
return
|
return
|
||||||
if not spl[1] in IRCPool.keys():
|
if not spl[1] in main.IRCPool.keys():
|
||||||
failure("Name has no instance: %s" % spl[1])
|
failure("Name has no instance: %s" % spl[1])
|
||||||
return
|
return
|
||||||
IRCPool[spl[1]].join(spl[2])
|
main.IRCPool[spl[1]].join(spl[2])
|
||||||
success("Joined %s" % spl[2])
|
success("Joined %s" % spl[2])
|
||||||
return
|
return
|
||||||
elif length == 4:
|
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])
|
failure("Name does not exist: %s" % spl[1])
|
||||||
return
|
return
|
||||||
if not spl[1] in IRCPool.keys():
|
if not spl[1] in main.IRCPool.keys():
|
||||||
failure("Name has no instance: %s" % spl[1])
|
failure("Name has no instance: %s" % spl[1])
|
||||||
return
|
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]))
|
success("Joined %s with key %s" % (spl[2], spl[3]))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
import modules.keyword as keyword
|
import modules.keyword as keyword
|
||||||
|
|
||||||
class Key:
|
class Key:
|
||||||
|
@ -39,45 +39,45 @@ class Key:
|
||||||
return
|
return
|
||||||
if length == 4:
|
if length == 4:
|
||||||
if spl[1] == "except":
|
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])
|
failure("No such keyword: %s" % spl[2])
|
||||||
return
|
return
|
||||||
if spl[2] in keyconf["KeywordsExcept"].keys():
|
if spl[2] in main.keyconf["KeywordsExcept"].keys():
|
||||||
if spl[3] in keyconf["KeywordsExcept"][spl[2]]:
|
if spl[3] in main.keyconf["KeywordsExcept"][spl[2]]:
|
||||||
failure("Exception exists: %s" % spl[3])
|
failure("Exception exists: %s" % spl[3])
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
if not spl[2] in spl[3]:
|
if not spl[2] in spl[3]:
|
||||||
failure("Keyword %s not in exception %s. This won't work" % (spl[2], spl[3]))
|
failure("Keyword %s not in exception %s. This won't work" % (spl[2], spl[3]))
|
||||||
return
|
return
|
||||||
keyconf["KeywordsExcept"][spl[2]] = []
|
main.keyconf["KeywordsExcept"][spl[2]] = []
|
||||||
|
|
||||||
keyconf["KeywordsExcept"][spl[2]].append(spl[3])
|
main.keyconf["KeywordsExcept"][spl[2]].append(spl[3])
|
||||||
saveConf("keyconf")
|
main.saveConf("keyconf")
|
||||||
success("Successfully added exception %s for keyword %s" % (spl[3], spl[2]))
|
success("Successfully added exception %s for keyword %s" % (spl[3], spl[2]))
|
||||||
return
|
return
|
||||||
elif spl[1] == "master":
|
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])
|
failure("Name does not exist: %s" % spl[2])
|
||||||
return
|
return
|
||||||
if spl[2] in IRCPool.keys():
|
if spl[2] in main.IRCPool.keys():
|
||||||
if not spl[3] in IRCPool[spl[2]].channels:
|
if not spl[3] in main.IRCPool[spl[2]].channels:
|
||||||
info("Bot not on channel: %s" % spl[3])
|
info("Bot not on channel: %s" % spl[3])
|
||||||
config["Master"] = [spl[2], spl[3]]
|
main.config["Master"] = [spl[2], spl[3]]
|
||||||
saveConf("config")
|
main.saveConf("config")
|
||||||
success("Master set to %s on %s" % (spl[3], spl[2]))
|
success("Master set to %s on %s" % (spl[3], spl[2]))
|
||||||
return
|
return
|
||||||
elif spl[1] == "unexcept":
|
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])
|
failure("No such exception: %s" % spl[2])
|
||||||
return
|
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]))
|
failure("Exception %s has no attribute %s" % (spl[2], spl[3]))
|
||||||
return
|
return
|
||||||
keyconf["KeywordsExcept"][spl[2]].remove(spl[3])
|
main.keyconf["KeywordsExcept"][spl[2]].remove(spl[3])
|
||||||
if keyconf["KeywordsExcept"][spl[2]] == []:
|
if main.keyconf["KeywordsExcept"][spl[2]] == []:
|
||||||
del keyconf["KeywordsExcept"][spl[2]]
|
del main.keyconf["KeywordsExcept"][spl[2]]
|
||||||
saveConf("keyconf")
|
main.saveConf("keyconf")
|
||||||
success("Successfully removed exception %s for keyword %s" % (spl[3], spl[2]))
|
success("Successfully removed exception %s for keyword %s" % (spl[3], spl[2]))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
@ -85,32 +85,32 @@ class Key:
|
||||||
return
|
return
|
||||||
elif length == 3:
|
elif length == 3:
|
||||||
if spl[1] == "unexcept":
|
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])
|
failure("No such exception: %s" % spl[2])
|
||||||
return
|
return
|
||||||
del keyconf["KeywordsExcept"][spl[2]]
|
del main.keyconf["KeywordsExcept"][spl[2]]
|
||||||
saveConf("keyconf")
|
main.saveConf("keyconf")
|
||||||
success("Successfully removed exception list of %s" % spl[2])
|
success("Successfully removed exception list of %s" % spl[2])
|
||||||
return
|
return
|
||||||
elif spl[1] == "monitor":
|
elif spl[1] == "monitor":
|
||||||
if spl[2] == "on":
|
if spl[2] == "on":
|
||||||
if not obj.addr in MonitorPool:
|
if not obj.addr in main.MonitorPool:
|
||||||
MonitorPool.append(obj.addr)
|
main.MonitorPool.append(obj.addr)
|
||||||
success("Keyword monitoring enabled")
|
success("Keyword monitoring enabled")
|
||||||
if len(masterbuf) == 0:
|
if len(main.masterbuf) == 0:
|
||||||
return
|
return
|
||||||
rtrn = []
|
rtrn = []
|
||||||
for i in range(len(masterbuf)):
|
for i in range(len(main.masterbuf)):
|
||||||
rtrn.append(masterbuf.pop(0))
|
rtrn.append(main.masterbuf.pop(0))
|
||||||
saveConf("masterbuf")
|
main.saveConf("masterbuf")
|
||||||
info("\n".join(rtrn))
|
info("\n".join(rtrn))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
failure("Keyword monitoring is already enabled")
|
failure("Keyword monitoring is already enabled")
|
||||||
return
|
return
|
||||||
elif spl[2] == "off":
|
elif spl[2] == "off":
|
||||||
if obj.addr in MonitorPool:
|
if obj.addr in main.MonitorPool:
|
||||||
MonitorPool.remove(obj.addr)
|
main.MonitorPool.remove(obj.addr)
|
||||||
success("Keyword monitoring disabled")
|
success("Keyword monitoring disabled")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
@ -124,22 +124,22 @@ class Key:
|
||||||
return
|
return
|
||||||
elif length == 2:
|
elif length == 2:
|
||||||
if spl[1] == "show":
|
if spl[1] == "show":
|
||||||
info(",".join(keyconf["Keywords"]))
|
info(",".join(main.keyconf["Keywords"]))
|
||||||
return
|
return
|
||||||
|
|
||||||
elif spl[1] == "showexcept":
|
elif spl[1] == "showexcept":
|
||||||
exceptMap = []
|
exceptMap = []
|
||||||
for i in keyconf["KeywordsExcept"].keys():
|
for i in main.keyconf["KeywordsExcept"].keys():
|
||||||
exceptMap.append("Key: %s" % i)
|
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")
|
exceptMap.append("\n")
|
||||||
info("\n".join(exceptMap))
|
info("\n".join(exceptMap))
|
||||||
return
|
return
|
||||||
elif spl[1] == "master":
|
elif spl[1] == "master":
|
||||||
info(" - ".join([str(i) for i in config["Master"]]))
|
info(" - ".join([str(i) for i in main.config["Master"]]))
|
||||||
return
|
return
|
||||||
elif spl[1] == "monitor":
|
elif spl[1] == "monitor":
|
||||||
if obj.addr in MonitorPool:
|
if obj.addr in main.MonitorPool:
|
||||||
info("Keyword monitoring is enabled on this connection")
|
info("Keyword monitoring is enabled on this connection")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
@ -148,7 +148,6 @@ class Key:
|
||||||
else:
|
else:
|
||||||
incUsage("key")
|
incUsage("key")
|
||||||
return
|
return
|
||||||
|
|
||||||
else:
|
else:
|
||||||
incUsage("key")
|
incUsage("key")
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
|
|
||||||
class List:
|
class List:
|
||||||
def __init__(self, register):
|
def __init__(self, register):
|
||||||
|
@ -7,10 +7,10 @@ class List:
|
||||||
def list(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
def list(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||||
if authed:
|
if authed:
|
||||||
poolMap = []
|
poolMap = []
|
||||||
for i in pool.keys():
|
for i in main.pool.keys():
|
||||||
poolMap.append("Server: %s" % i)
|
poolMap.append("Server: %s" % i)
|
||||||
for x in pool[i].keys():
|
for x in main.pool[i].keys():
|
||||||
poolMap.append(" %s: %s" % (x, pool[i][x]))
|
poolMap.append(" %s: %s" % (x, main.pool[i][x]))
|
||||||
poolMap.append("\n")
|
poolMap.append("\n")
|
||||||
info("\n".join(poolMap))
|
info("\n".join(poolMap))
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
|
|
||||||
class Load:
|
class Load:
|
||||||
def __init__(self, register):
|
def __init__(self, register):
|
||||||
|
@ -7,14 +7,14 @@ class Load:
|
||||||
def load(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
def load(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||||
if authed:
|
if authed:
|
||||||
if length == 2:
|
if length == 2:
|
||||||
if spl[1] in filemap.keys():
|
if spl[1] in main.filemap.keys():
|
||||||
loadConf(spl[1])
|
main.loadConf(spl[1])
|
||||||
success("Loaded %s from %s" % (spl[1], filemap[spl[1]][0]))
|
success("Loaded %s from %s" % (spl[1], main.filemap[spl[1]][0]))
|
||||||
return
|
return
|
||||||
elif spl[1] == "all":
|
elif spl[1] == "all":
|
||||||
for i in filemap.keys():
|
for i in main.filemap.keys():
|
||||||
loadConf(i)
|
main.loadConf(i)
|
||||||
success("Loaded %s from %s" % (i, filemap[i][0]))
|
success("Loaded %s from %s" % (i, main.filemap[i][0]))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
incUsage("load")
|
incUsage("load")
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
from utils.loaders.single_loader import loadSingle
|
from utils.loaders.single_loader import loadSingle
|
||||||
|
|
||||||
class Loadmod:
|
class Loadmod:
|
||||||
|
@ -8,7 +8,7 @@ class Loadmod:
|
||||||
def loadmod(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
def loadmod(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||||
if authed:
|
if authed:
|
||||||
if length == 2:
|
if length == 2:
|
||||||
rtrn = loadSingle(spl[1], register)
|
rtrn = loadSingle(spl[1], main.register)
|
||||||
if rtrn == True:
|
if rtrn == True:
|
||||||
success("Loaded module %s" % spl[1])
|
success("Loaded module %s" % spl[1])
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
|
|
||||||
class Logout:
|
class Logout:
|
||||||
def __init__(self, register):
|
def __init__(self, register):
|
||||||
|
@ -7,8 +7,8 @@ class Logout:
|
||||||
def logout(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
def logout(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||||
if authed:
|
if authed:
|
||||||
obj.authed = False
|
obj.authed = False
|
||||||
if obj.addr in MonitorPool:
|
if obj.addr in main.MonitorPool:
|
||||||
MonitorPool.remove(obj.addr)
|
main.MonitorPool.remove(obj.addr)
|
||||||
success("Logged out")
|
success("Logged out")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
|
|
||||||
class Mod:
|
class Mod:
|
||||||
def __init__(self, register):
|
def __init__(self, register):
|
||||||
|
@ -8,30 +8,30 @@ class Mod:
|
||||||
if authed:
|
if authed:
|
||||||
toUnset = False
|
toUnset = False
|
||||||
if length == 2:
|
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])
|
failure("Name does not exist: %s" % spl[1])
|
||||||
return
|
return
|
||||||
optionMap = ["Viewing options for %s" % spl[1]]
|
optionMap = ["Viewing options for %s" % spl[1]]
|
||||||
for i in pool[spl[1]].keys():
|
for i in main.pool[spl[1]].keys():
|
||||||
optionMap.append(" %s: %s" % (i, pool[spl[1]][i]))
|
optionMap.append(" %s: %s" % (i, main.pool[spl[1]][i]))
|
||||||
info("\n".join(optionMap))
|
info("\n".join(optionMap))
|
||||||
return
|
return
|
||||||
|
|
||||||
elif length == 3:
|
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])
|
failure("Name does not exist: %s" % spl[1])
|
||||||
return
|
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])
|
failure("No such key: %s" % spl[2])
|
||||||
return
|
return
|
||||||
info("%s: %s" % (spl[2], pool[spl[1]][spl[2]]))
|
info("%s: %s" % (spl[2], main.pool[spl[1]][spl[2]]))
|
||||||
return
|
return
|
||||||
|
|
||||||
elif length == 4:
|
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])
|
failure("Name does not exist: %s" % spl[1])
|
||||||
return
|
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])
|
failure("No such key: %s" % spl[2])
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class Mod:
|
||||||
if not spl[3] in ["ssl", "plain"]:
|
if not spl[3] in ["ssl", "plain"]:
|
||||||
failure("Protocol must be ssl or plain, not %s" % spl[3])
|
failure("Protocol must be ssl or plain, not %s" % spl[3])
|
||||||
return
|
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])
|
failure("Value already exists: %s" % spl[3])
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -72,10 +72,10 @@ class Mod:
|
||||||
if spl[2] == "autojoin":
|
if spl[2] == "autojoin":
|
||||||
spl[3] = spl[3].split(",")
|
spl[3] = spl[3].split(",")
|
||||||
|
|
||||||
pool[spl[1]][spl[2]] = spl[3]
|
main.pool[spl[1]][spl[2]] = spl[3]
|
||||||
if spl[1] in IRCPool.keys():
|
if spl[1] in main.IRCPool.keys():
|
||||||
IRCPool[spl[1]].refresh()
|
main.IRCPool[spl[1]].refresh()
|
||||||
saveConf("pool")
|
main.saveConf("pool")
|
||||||
if toUnset:
|
if toUnset:
|
||||||
success("Successfully unset key %s on %s" % (spl[2], spl[1]))
|
success("Successfully unset key %s on %s" % (spl[2], spl[1]))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
|
|
||||||
class Part:
|
class Part:
|
||||||
def __init__(self, register):
|
def __init__(self, register):
|
||||||
|
@ -7,13 +7,13 @@ class Part:
|
||||||
def part(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
def part(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||||
if authed:
|
if authed:
|
||||||
if length == 3:
|
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])
|
failure("Name does not exist: %s" % spl[1])
|
||||||
return
|
return
|
||||||
if not spl[1] in IRCPool.keys():
|
if not spl[1] in main.IRCPool.keys():
|
||||||
failure("Name has no instance: %s" % spl[1])
|
failure("Name has no instance: %s" % spl[1])
|
||||||
return
|
return
|
||||||
IRCPool[spl[1]].part(spl[2])
|
main.IRCPool[spl[1]].part(spl[2])
|
||||||
success("Left %s" % spl[2])
|
success("Left %s" % spl[2])
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
|
|
||||||
class Password:
|
class Password:
|
||||||
def __init__(self, register):
|
def __init__(self, register):
|
||||||
|
@ -10,7 +10,7 @@ class Password:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
if length == 2:
|
if length == 2:
|
||||||
if spl[1] == config["Password"]:
|
if spl[1] == main.config["Password"]:
|
||||||
success("Authenticated successfully")
|
success("Authenticated successfully")
|
||||||
obj.authed = True
|
obj.authed = True
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
|
|
||||||
class Save:
|
class Save:
|
||||||
def __init__(self, register):
|
def __init__(self, register):
|
||||||
|
@ -7,14 +7,14 @@ class Save:
|
||||||
def save(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
def save(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||||
if authed:
|
if authed:
|
||||||
if length == 2:
|
if length == 2:
|
||||||
if spl[1] in filemap.keys():
|
if spl[1] in main.filemap.keys():
|
||||||
saveConf(spl[1])
|
main.saveConf(spl[1])
|
||||||
success("Saved %s to %s" % (spl[1], filemap[spl[1]][0]))
|
success("Saved %s to %s" % (spl[1], main.filemap[spl[1]][0]))
|
||||||
return
|
return
|
||||||
elif spl[1] == "all":
|
elif spl[1] == "all":
|
||||||
for i in filemap.keys():
|
for i in main.filemap.keys():
|
||||||
saveConf(i)
|
main.saveConf(i)
|
||||||
success("Saved %s to %s" % (i, filemap[i][0]))
|
success("Saved %s to %s" % (i, main.filemap[i][0]))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
incUsage("save")
|
incUsage("save")
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
import modules.counters as count
|
import modules.counters as count
|
||||||
|
|
||||||
class Stats:
|
class Stats:
|
||||||
|
@ -11,11 +11,11 @@ class Stats:
|
||||||
stats = []
|
stats = []
|
||||||
numChannels = 0
|
numChannels = 0
|
||||||
numWhoEntries = 0
|
numWhoEntries = 0
|
||||||
for i in IRCPool.keys():
|
for i in main.IRCPool.keys():
|
||||||
numChannels += len(IRCPool[i].channels)
|
numChannels += len(main.IRCPool[i].channels)
|
||||||
for i in wholist.keys():
|
for i in main.wholist.keys():
|
||||||
numWhoEntries += len(wholist[i].keys())
|
numWhoEntries += len(main.wholist[i].keys())
|
||||||
stats.append("Servers: %s" % len(IRCPool.keys()))
|
stats.append("Servers: %s" % len(main.IRCPool.keys()))
|
||||||
stats.append("Channels: %s" % numChannels)
|
stats.append("Channels: %s" % numChannels)
|
||||||
stats.append("User records: %s" % numWhoEntries)
|
stats.append("User records: %s" % numWhoEntries)
|
||||||
counterEvents = count.getEvents()
|
counterEvents = count.getEvents()
|
||||||
|
@ -34,13 +34,13 @@ class Stats:
|
||||||
numWhoEntries = 0
|
numWhoEntries = 0
|
||||||
|
|
||||||
failures = 0
|
failures = 0
|
||||||
if spl[1] in IRCPool.keys():
|
if spl[1] in main.IRCPool.keys():
|
||||||
numChannels += len(IRCPool[spl[1]].channels)
|
numChannels += len(main.IRCPool[spl[1]].channels)
|
||||||
else:
|
else:
|
||||||
failure("Name does not exist: %s" % spl[1])
|
failure("Name does not exist: %s" % spl[1])
|
||||||
failures += 1
|
failures += 1
|
||||||
if spl[1] in wholist.keys():
|
if spl[1] in main.wholist.keys():
|
||||||
numWhoEntries += len(wholist[spl[1]].keys())
|
numWhoEntries += len(main.wholist[spl[1]].keys())
|
||||||
else:
|
else:
|
||||||
failure("Who entry does not exist: %s" % spl[1])
|
failure("Who entry does not exist: %s" % spl[1])
|
||||||
failures += 1
|
failures += 1
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.main import *
|
import main
|
||||||
import modules.userinfo as userinfo
|
import modules.userinfo as userinfo
|
||||||
|
|
||||||
class Who:
|
class Who:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"Keywords": [
|
"Keywords": [
|
||||||
"example"
|
"example",
|
||||||
|
"s"
|
||||||
],
|
],
|
||||||
"KeywordsExcept": {}
|
"KeywordsExcept": {}
|
||||||
}
|
}
|
111
core/bot.py
111
core/bot.py
|
@ -6,7 +6,7 @@ import modules.keyword as keyword
|
||||||
import modules.userinfo as userinfo
|
import modules.userinfo as userinfo
|
||||||
import modules.counters as count
|
import modules.counters as count
|
||||||
|
|
||||||
from core.main import *
|
import main
|
||||||
from utils.logging.log import *
|
from utils.logging.log import *
|
||||||
from utils.logging.send import *
|
from utils.logging.send import *
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@ class IRCBot(IRCClient):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.connected = False
|
self.connected = False
|
||||||
self.channels = []
|
self.channels = []
|
||||||
|
self.buffer = ""
|
||||||
self.name = name
|
self.name = name
|
||||||
instance = pool[name]
|
instance = main.pool[name]
|
||||||
|
|
||||||
self.nickname = instance["nickname"]
|
self.nickname = instance["nickname"]
|
||||||
self.realname = instance["realname"]
|
self.realname = instance["realname"]
|
||||||
|
@ -40,7 +40,7 @@ class IRCBot(IRCClient):
|
||||||
self.password = instance["password"]
|
self.password = instance["password"]
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
instance = pool[self.name]
|
instance = main.pool[self.name]
|
||||||
if not instance["nickname"] == self.nickname:
|
if not instance["nickname"] == self.nickname:
|
||||||
self.nickname = instance["nickname"]
|
self.nickname = instance["nickname"]
|
||||||
self.setNick(self.nickname)
|
self.setNick(self.nickname)
|
||||||
|
@ -69,21 +69,21 @@ class IRCBot(IRCClient):
|
||||||
userinfo.setWhoSingle(self.name, nick, ident, host)
|
userinfo.setWhoSingle(self.name, nick, ident, host)
|
||||||
count.event(self.name, "privmsg")
|
count.event(self.name, "privmsg")
|
||||||
|
|
||||||
keyword.actKeyword(user, channel, msg, self.nickname, "PRV", self.name)
|
keyword.actKeyword(user, channel, msg, self.nickname, "MSG", self.name)
|
||||||
|
|
||||||
def noticed(self, user, channel, msg):
|
def noticed(self, user, channel, msg):
|
||||||
nick, ident, host = self.parsen(user)
|
nick, ident, host = self.parsen(user)
|
||||||
userinfo.setWhoSingle(self.name, nick, ident, host)
|
userinfo.setWhoSingle(self.name, nick, ident, host)
|
||||||
count.event(self.name, "notice")
|
count.event(self.name, "notice")
|
||||||
|
|
||||||
keyword.actKeyword(user, channel, msg, self.nickname, "NOT", self.name)
|
keyword.actKeyword(user, channel, msg, self.nickname, "NOTICE", self.name)
|
||||||
|
|
||||||
def action(self, user, channel, msg):
|
def action(self, user, channel, msg):
|
||||||
nick, ident, host = self.parsen(user)
|
nick, ident, host = self.parsen(user)
|
||||||
userinfo.setWhoSingle(self.name, nick, ident, host)
|
userinfo.setWhoSingle(self.name, nick, ident, host)
|
||||||
count.event(self.name, "action")
|
count.event(self.name, "action")
|
||||||
|
|
||||||
keyword.actKeyword(user, channel, msg, self.nickname, "ACT", self.name)
|
keyword.actKeyword(user, channel, msg, self.nickname, "ACTION", self.name)
|
||||||
|
|
||||||
def get(self, var):
|
def get(self, var):
|
||||||
try:
|
try:
|
||||||
|
@ -148,10 +148,79 @@ class IRCBot(IRCClient):
|
||||||
def got_who(self, whoinfo):
|
def got_who(self, whoinfo):
|
||||||
userinfo.setWho(self.name, whoinfo[1])
|
userinfo.setWho(self.name, whoinfo[1])
|
||||||
|
|
||||||
|
|
||||||
|
#twisted sucks so i have to do this to actually get the user info
|
||||||
|
def irc_JOIN(self, prefix, params):
|
||||||
|
"""
|
||||||
|
Called when a user joins a channel.
|
||||||
|
"""
|
||||||
|
nick = prefix.split('!')[0]
|
||||||
|
channel = params[-1]
|
||||||
|
if nick == self.nickname:
|
||||||
|
self.joined(channel)
|
||||||
|
else:
|
||||||
|
self.userJoined(prefix, channel)
|
||||||
|
|
||||||
|
def irc_PART(self, prefix, params):
|
||||||
|
"""
|
||||||
|
Called when a user leaves a channel.
|
||||||
|
"""
|
||||||
|
nick = prefix.split('!')[0]
|
||||||
|
channel = params[0]
|
||||||
|
if len(params) >= 2:
|
||||||
|
message = params[1]
|
||||||
|
else:
|
||||||
|
message = None
|
||||||
|
if nick == self.nickname:
|
||||||
|
self.left(channel, message)
|
||||||
|
else:
|
||||||
|
self.userLeft(prefix, channel, message)
|
||||||
|
|
||||||
|
def irc_QUIT(self, prefix, params):
|
||||||
|
"""
|
||||||
|
Called when a user has quit.
|
||||||
|
"""
|
||||||
|
#nick = prefix.split('!')[0]
|
||||||
|
self.userQuit(prefix, params[0])
|
||||||
|
|
||||||
|
def irc_NICK(self, prefix, params):
|
||||||
|
"""
|
||||||
|
Called when a user changes their nickname.
|
||||||
|
"""
|
||||||
|
nick = prefix.split('!', 1)[0]
|
||||||
|
if nick == self.nickname:
|
||||||
|
self.nickChanged(params[0])
|
||||||
|
else:
|
||||||
|
self.userRenamed(prefix, params[0])
|
||||||
|
|
||||||
|
def irc_KICK(self, prefix, params):
|
||||||
|
"""
|
||||||
|
Called when a user is kicked from a channel.
|
||||||
|
"""
|
||||||
|
#kicker = prefix.split('!')[0]
|
||||||
|
channel = params[0]
|
||||||
|
kicked = params[1]
|
||||||
|
message = params[-1]
|
||||||
|
if kicked.lower() == self.nickname.lower():
|
||||||
|
# Yikes!
|
||||||
|
self.kickedFrom(channel, prefix, message)
|
||||||
|
else:
|
||||||
|
self.userKicked(kicked, channel, prefix, message)
|
||||||
|
|
||||||
|
def irc_TOPIC(self, prefix, params):
|
||||||
|
"""
|
||||||
|
Someone in the channel set the topic.
|
||||||
|
"""
|
||||||
|
#user = prefix.split('!')[0]
|
||||||
|
channel = params[0]
|
||||||
|
newtopic = params[1]
|
||||||
|
self.topicUpdated(prefix, channel, newtopic)
|
||||||
|
#END hacks
|
||||||
|
|
||||||
def signedOn(self):
|
def signedOn(self):
|
||||||
self.connected = True
|
self.connected = True
|
||||||
log("signed on: %s" % self.name)
|
log("signed on: %s" % self.name)
|
||||||
if config["ConnectionNotifications"]:
|
if main.config["ConnectionNotifications"]:
|
||||||
keyword.sendMaster("SIGNON: %s" % self.name)
|
keyword.sendMaster("SIGNON: %s" % self.name)
|
||||||
if self.authtype == "ns":
|
if self.authtype == "ns":
|
||||||
self.msg(self.authentity, "IDENTIFY %s" % self.nspass)
|
self.msg(self.authentity, "IDENTIFY %s" % self.nspass)
|
||||||
|
@ -164,14 +233,15 @@ class IRCBot(IRCClient):
|
||||||
self.channels.append(channel)
|
self.channels.append(channel)
|
||||||
self.who(channel).addCallback(self.got_who)
|
self.who(channel).addCallback(self.got_who)
|
||||||
count.event(self.name, "selfjoin")
|
count.event(self.name, "selfjoin")
|
||||||
if self.name == config["Master"][0] and channel == config["Master"][1]:
|
if self.name == main.config["Master"][0] and channel == main.config["Master"][1]:
|
||||||
for i in range(len(masterbuf)):
|
for i in range(len(main.masterbuf)):
|
||||||
self.msg(channel, masterbuf.pop(0))
|
self.msg(channel, main.masterbuf.pop(0))
|
||||||
saveConf("masterbuf")
|
main.saveConf("masterbuf")
|
||||||
|
|
||||||
def left(self, channel):
|
def left(self, channel, message):
|
||||||
if channel in self.channels:
|
if channel in self.channels:
|
||||||
self.channels.remove(channel)
|
self.channels.remove(channel)
|
||||||
|
keyword.actKeyword(user, channel, message, self.nickname, "SELFPART", self.name)
|
||||||
count.event(self.name, "selfpart")
|
count.event(self.name, "selfpart")
|
||||||
|
|
||||||
def kickedFrom(self, channel, kicker, message):
|
def kickedFrom(self, channel, kicker, message):
|
||||||
|
@ -185,9 +255,10 @@ class IRCBot(IRCClient):
|
||||||
userinfo.setWhoSingle(self.name, nick, ident, host)
|
userinfo.setWhoSingle(self.name, nick, ident, host)
|
||||||
count.event(self.name, "join")
|
count.event(self.name, "join")
|
||||||
|
|
||||||
def userLeft(self, user, channel):
|
def userLeft(self, user, channel, message):
|
||||||
nick, ident, host = self.parsen(user)
|
nick, ident, host = self.parsen(user)
|
||||||
userinfo.setWhoSingle(self.name, nick, ident, host)
|
userinfo.setWhoSingle(self.name, nick, ident, host)
|
||||||
|
keyword.actKeyword(user, channel, message, self.nickname, "PART", self.name)
|
||||||
count.event(self.name, "part")
|
count.event(self.name, "part")
|
||||||
|
|
||||||
def userQuit(self, user, quitMessage):
|
def userQuit(self, user, quitMessage):
|
||||||
|
@ -195,14 +266,14 @@ class IRCBot(IRCClient):
|
||||||
userinfo.setWhoSingle(self.name, nick, ident, host)
|
userinfo.setWhoSingle(self.name, nick, ident, host)
|
||||||
count.event(self.name, "quit")
|
count.event(self.name, "quit")
|
||||||
|
|
||||||
keyword.actKeyword(user, None, quitMessage, self.nickname, "QUT", self.name)
|
keyword.actKeyword(user, None, quitMessage, self.nickname, "QUIT", self.name)
|
||||||
|
|
||||||
def userKicked(self, kickee, channel, kicker, message):
|
def userKicked(self, kickee, channel, kicker, message):
|
||||||
nick, ident, host = self.parsen(kicker)
|
nick, ident, host = self.parsen(kicker)
|
||||||
userinfo.setWhoSingle(self.name, nick, ident, host)
|
userinfo.setWhoSingle(self.name, nick, ident, host)
|
||||||
count.event(self.name, "kick")
|
count.event(self.name, "kick")
|
||||||
|
|
||||||
keyword.actKeyword(kicker, channel, message, self.nickname, "KCK", self.name)
|
keyword.actKeyword(kicker, channel, message, self.nickname, "KICK", self.name)
|
||||||
|
|
||||||
def userRenamed(self, oldname, newname):
|
def userRenamed(self, oldname, newname):
|
||||||
nick, ident, host = self.parsen(oldname)
|
nick, ident, host = self.parsen(oldname)
|
||||||
|
@ -215,7 +286,7 @@ class IRCBot(IRCClient):
|
||||||
userinfo.setWhoSingle(self.name, nick, ident, host)
|
userinfo.setWhoSingle(self.name, nick, ident, host)
|
||||||
count.event(self.name, "topic")
|
count.event(self.name, "topic")
|
||||||
|
|
||||||
keyword.actKeyword(user, channel, newTopic, self.nickname, "TOP", self.name)
|
keyword.actKeyword(user, channel, newTopic, self.nickname, "TOPIC", self.name)
|
||||||
|
|
||||||
def modeChanged(self, user, channel, toset, modes, args):
|
def modeChanged(self, user, channel, toset, modes, args):
|
||||||
nick, ident, host = self.parsen(user)
|
nick, ident, host = self.parsen(user)
|
||||||
|
@ -224,7 +295,7 @@ class IRCBot(IRCClient):
|
||||||
|
|
||||||
class IRCBotFactory(ReconnectingClientFactory):
|
class IRCBotFactory(ReconnectingClientFactory):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.instance = pool[name]
|
self.instance = main.pool[name]
|
||||||
self.name = name
|
self.name = name
|
||||||
self.client = None
|
self.client = None
|
||||||
self.maxDelay = self.instance["maxdelay"]
|
self.maxDelay = self.instance["maxdelay"]
|
||||||
|
@ -234,7 +305,7 @@ class IRCBotFactory(ReconnectingClientFactory):
|
||||||
|
|
||||||
def buildProtocol(self, addr):
|
def buildProtocol(self, addr):
|
||||||
entry = IRCBot(self.name)
|
entry = IRCBot(self.name)
|
||||||
IRCPool[self.name] = entry
|
main.IRCPool[self.name] = entry
|
||||||
self.client = entry
|
self.client = entry
|
||||||
return entry
|
return entry
|
||||||
|
|
||||||
|
@ -245,7 +316,7 @@ class IRCBotFactory(ReconnectingClientFactory):
|
||||||
error = reason.getErrorMessage()
|
error = reason.getErrorMessage()
|
||||||
log("%s: connection lost: %s" % (self.name, error))
|
log("%s: connection lost: %s" % (self.name, error))
|
||||||
sendAll("%s: connection lost: %s" % (self.name, error))
|
sendAll("%s: connection lost: %s" % (self.name, error))
|
||||||
if config["ConnectionNotifications"]:
|
if main.config["ConnectionNotifications"]:
|
||||||
keyword.sendMaster("CONNLOST %s: %s" % (self.name, error))
|
keyword.sendMaster("CONNLOST %s: %s" % (self.name, error))
|
||||||
self.retry(connector)
|
self.retry(connector)
|
||||||
#ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
|
#ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
|
||||||
|
|
|
@ -2,43 +2,43 @@ from twisted.internet import reactor
|
||||||
from twisted.internet.ssl import DefaultOpenSSLContextFactory
|
from twisted.internet.ssl import DefaultOpenSSLContextFactory
|
||||||
|
|
||||||
from core.bot import IRCBot, IRCBotFactory
|
from core.bot import IRCBot, IRCBotFactory
|
||||||
from core.main import *
|
import main
|
||||||
from utils.logging.log import *
|
from utils.logging.log import *
|
||||||
|
|
||||||
def addBot(name):
|
def addBot(name):
|
||||||
instance = pool[name]
|
instance = main.pool[name]
|
||||||
log("Started bot %s to %s:%s protocol %s nickname %s" % (name, instance["host"], instance["port"], instance["protocol"], instance["nickname"]))
|
log("Started bot %s to %s:%s protocol %s nickname %s" % (name, instance["host"], instance["port"], instance["protocol"], instance["nickname"]))
|
||||||
if instance["protocol"] == "plain":
|
if instance["protocol"] == "plain":
|
||||||
if instance["bind"] == None:
|
if instance["bind"] == None:
|
||||||
bot = IRCBotFactory(name)
|
bot = IRCBotFactory(name)
|
||||||
rct = reactor.connectTCP(instance["host"], instance["port"], bot, timeout=int(instance["timeout"]))
|
rct = reactor.connectTCP(instance["host"], instance["port"], bot, timeout=int(instance["timeout"]))
|
||||||
|
|
||||||
ReactorPool[name] = rct
|
main.ReactorPool[name] = rct
|
||||||
FactoryPool[name] = bot
|
main.FactoryPool[name] = bot
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
bot = IRCBotFactory(name)
|
bot = IRCBotFactory(name)
|
||||||
rct = reactor.connectTCP(instance["host"], instance["port"], bot, timeout=int(instance["timeout"]), bindAddress=instance["bind"])
|
rct = reactor.connectTCP(instance["host"], instance["port"], bot, timeout=int(instance["timeout"]), bindAddress=instance["bind"])
|
||||||
|
|
||||||
ReactorPool[name] = rct
|
main.ReactorPool[name] = rct
|
||||||
FactoryPool[name] = bot
|
main.FactoryPool[name] = bot
|
||||||
return
|
return
|
||||||
elif instance["protocol"] == "ssl":
|
elif instance["protocol"] == "ssl":
|
||||||
keyFN = certPath+instance["key"]
|
keyFN = main.certPath+instance["key"]
|
||||||
certFN = certPath+instance["certificate"]
|
certFN = main.certPath+instance["certificate"]
|
||||||
contextFactory = DefaultOpenSSLContextFactory(keyFN.encode("utf-8", "replace"), certFN.encode("utf-8", "replace"))
|
contextFactory = DefaultOpenSSLContextFactory(keyFN.encode("utf-8", "replace"), certFN.encode("utf-8", "replace"))
|
||||||
if instance["bind"] == None:
|
if instance["bind"] == None:
|
||||||
bot = IRCBotFactory(name)
|
bot = IRCBotFactory(name)
|
||||||
rct = reactor.connectSSL(instance["host"], int(instance["port"]), bot, contextFactory)
|
rct = reactor.connectSSL(instance["host"], int(instance["port"]), bot, contextFactory)
|
||||||
|
|
||||||
ReactorPool[name] = rct
|
main.ReactorPool[name] = rct
|
||||||
FactoryPool[name] = bot
|
main.FactoryPool[name] = bot
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|
||||||
bot = IRCBotFactory(name)
|
bot = IRCBotFactory(name)
|
||||||
rct = reactor.connectSSL(instance["host"], int(instance["port"]), bot, contextFactory, bindAddress=instance["bind"])
|
rct = reactor.connectSSL(instance["host"], int(instance["port"]), bot, contextFactory, bindAddress=instance["bind"])
|
||||||
|
|
||||||
ReactorPool[name] = rct
|
main.ReactorPool[name] = rct
|
||||||
FactoryPool[name] = bot
|
main.FactoryPool[name] = bot
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
from core.main import *
|
import main
|
||||||
from utils.logging.log import *
|
from utils.logging.log import *
|
||||||
from utils.logging.send import *
|
from utils.logging.send import *
|
||||||
|
|
||||||
def parseCommand(addr, authed, data):
|
def parseCommand(addr, authed, data):
|
||||||
#call command modules with: (addr, authed, data, spl, success, failure, info, incUsage, length)
|
#call command modules with: (addr, authed, data, spl, success, failure, info, incUsage, length)
|
||||||
spl = data.split()
|
spl = data.split()
|
||||||
if addr in connections.keys():
|
if addr in main.connections.keys():
|
||||||
obj = connections[addr]
|
obj = main.connections[addr]
|
||||||
else:
|
else:
|
||||||
warn("Got connection object with no instance in the address pool")
|
warn("Got connection object with no instance in the address pool")
|
||||||
return
|
return
|
||||||
|
@ -22,9 +22,9 @@ def parseCommand(addr, authed, data):
|
||||||
else:
|
else:
|
||||||
failure("No text was sent")
|
failure("No text was sent")
|
||||||
return
|
return
|
||||||
for i in CommandMap.keys():
|
for i in main.CommandMap.keys():
|
||||||
if spl[0] == i:
|
if spl[0] == i:
|
||||||
CommandMap[i](addr, authed, data, obj, spl, success, failure, info, incUsage, length)
|
main.CommandMap[i](addr, authed, data, obj, spl, success, failure, info, incUsage, length)
|
||||||
return
|
return
|
||||||
incUsage(None)
|
incUsage(None)
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from twisted.internet.protocol import Protocol, Factory, ClientFactory
|
from twisted.internet.protocol import Protocol, Factory, ClientFactory
|
||||||
from core.main import *
|
import main
|
||||||
from utils.logging.log import *
|
from utils.logging.log import *
|
||||||
|
|
||||||
from core.parser import parseCommand
|
from core.parser import parseCommand
|
||||||
|
@ -8,7 +8,7 @@ class Server(Protocol):
|
||||||
def __init__(self, addr):
|
def __init__(self, addr):
|
||||||
self.addr = addr
|
self.addr = addr
|
||||||
self.authed = False
|
self.authed = False
|
||||||
if config["UsePassword"] == False:
|
if main.config["UsePassword"] == False:
|
||||||
self.authed = True
|
self.authed = True
|
||||||
|
|
||||||
def send(self, data):
|
def send(self, data):
|
||||||
|
@ -34,22 +34,22 @@ class Server(Protocol):
|
||||||
def connectionLost(self, reason):
|
def connectionLost(self, reason):
|
||||||
self.authed = False
|
self.authed = False
|
||||||
log("Connection lost from %s:%s -- %s" % (self.addr.host, self.addr.port, reason.getErrorMessage()))
|
log("Connection lost from %s:%s -- %s" % (self.addr.host, self.addr.port, reason.getErrorMessage()))
|
||||||
if self.addr in connections.keys():
|
if self.addr in main.connections.keys():
|
||||||
del connections[self.addr]
|
del main.connections[self.addr]
|
||||||
else:
|
else:
|
||||||
warn("Tried to remove a non-existant connection.")
|
warn("Tried to remove a non-existant connection.")
|
||||||
if self.addr in MonitorPool:
|
if self.addr in main.MonitorPool:
|
||||||
MonitorPool.remove(self.addr)
|
main.MonitorPool.remove(self.addr)
|
||||||
|
|
||||||
class ServerFactory(Factory):
|
class ServerFactory(Factory):
|
||||||
def buildProtocol(self, addr):
|
def buildProtocol(self, addr):
|
||||||
entry = Server(addr)
|
entry = Server(addr)
|
||||||
connections[addr] = entry
|
main.connections[addr] = entry
|
||||||
return entry
|
return entry
|
||||||
|
|
||||||
def send(self, addr, data):
|
def send(self, addr, data):
|
||||||
if addr in connections.keys():
|
if addr in main.connections.keys():
|
||||||
connection = connections[addr]
|
connection = main.connections[addr]
|
||||||
connection.send(data)
|
connection.send(data)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
from core.main import *
|
import main
|
||||||
|
|
||||||
def event(name, eventType):
|
def event(name, eventType):
|
||||||
if not "local" in counters.keys():
|
if not "local" in main.counters.keys():
|
||||||
counters["local"] = {}
|
main.counters["local"] = {}
|
||||||
if not "global" in counters.keys():
|
if not "global" in main.counters.keys():
|
||||||
counters["global"] = {}
|
main.counters["global"] = {}
|
||||||
if not name in counters["local"].keys():
|
if not name in main.counters["local"].keys():
|
||||||
counters["local"][name] = {}
|
main.counters["local"][name] = {}
|
||||||
if eventType not in counters["local"][name].keys():
|
if eventType not in main.counters["local"][name].keys():
|
||||||
counters["local"][name][eventType] = 0
|
main.counters["local"][name][eventType] = 0
|
||||||
|
|
||||||
if eventType not in counters["global"]:
|
if eventType not in main.counters["global"]:
|
||||||
counters["global"][eventType] = 0
|
main.counters["global"][eventType] = 0
|
||||||
|
|
||||||
counters["local"][name][eventType] += 1
|
main.counters["local"][name][eventType] += 1
|
||||||
counters["global"][eventType] += 1
|
main.counters["global"][eventType] += 1
|
||||||
|
|
||||||
def getEvents(name=None):
|
def getEvents(name=None):
|
||||||
if name == None:
|
if name == None:
|
||||||
if "global" in counters.keys():
|
if "global" in main.counters.keys():
|
||||||
return counters["global"]
|
return main.counters["global"]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
if name in counters["local"].keys():
|
if name in main.counters["local"].keys():
|
||||||
return counters["local"][name]
|
return main.counters["local"][name]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -1,38 +1,38 @@
|
||||||
from core.main import *
|
import main
|
||||||
from utils.logging.log import *
|
from utils.logging.log import *
|
||||||
import modules.counters as count
|
import modules.counters as count
|
||||||
|
|
||||||
def sendMaster(data):
|
def sendMaster(data):
|
||||||
if not len(MonitorPool) == 0:
|
if not len(main.MonitorPool) == 0:
|
||||||
hasMonitors = True
|
hasMonitors = True
|
||||||
else:
|
else:
|
||||||
hasMonitors = False
|
hasMonitors = False
|
||||||
|
|
||||||
if config["Master"] == [None, None]:
|
if main.config["Master"] == [None, None]:
|
||||||
if hasMonitors:
|
if hasMonitors:
|
||||||
for i in MonitorPool:
|
for i in main.MonitorPool:
|
||||||
connections[i].send(data)
|
main.connections[i].send(data)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
masterbuf.append(data)
|
main.masterbuf.append(data)
|
||||||
saveConf("masterbuf")
|
main.saveConf("masterbuf")
|
||||||
return
|
return
|
||||||
|
|
||||||
if config["Master"][0] in IRCPool.keys():
|
if main.config["Master"][0] in main.IRCPool.keys():
|
||||||
if config["Master"][1] in IRCPool[config["Master"][0]].channels:
|
if main.config["Master"][1] in main.IRCPool[main.config["Master"][0]].channels:
|
||||||
IRCPool[config["Master"][0]].msg(config["Master"][1], data)
|
main.IRCPool[main.config["Master"][0]].msg(main.config["Master"][1], data)
|
||||||
else:
|
else:
|
||||||
if not hasMonitors:
|
if not hasMonitors:
|
||||||
masterbuf.append(data)
|
main.masterbuf.append(data)
|
||||||
saveConf("masterbuf")
|
main.saveConf("masterbuf")
|
||||||
else:
|
else:
|
||||||
if not hasMonitors:
|
if not hasMonitors:
|
||||||
masterbuf.append(data)
|
main.masterbuf.append(data)
|
||||||
saveConf("masterbuf")
|
main.saveConf("masterbuf")
|
||||||
warn("Master with no IRC instance defined")
|
warn("Master with no IRC instance defined")
|
||||||
|
|
||||||
for i in MonitorPool:
|
for i in main.MonitorPool:
|
||||||
connections[i].send(data)
|
main.connections[i].send(data)
|
||||||
|
|
||||||
def isKeyword(msg):
|
def isKeyword(msg):
|
||||||
message = msg.lower()
|
message = msg.lower()
|
||||||
|
@ -40,10 +40,10 @@ def isKeyword(msg):
|
||||||
toUndo = False
|
toUndo = False
|
||||||
uniqueNum = 0
|
uniqueNum = 0
|
||||||
totalNum = 0
|
totalNum = 0
|
||||||
for i in keyconf["Keywords"]:
|
for i in main.keyconf["Keywords"]:
|
||||||
if i in message:
|
if i in message:
|
||||||
if i in keyconf["KeywordsExcept"].keys():
|
if i in main.keyconf["KeywordsExcept"].keys():
|
||||||
for x in keyconf["KeywordsExcept"][i]:
|
for x in main.keyconf["KeywordsExcept"][i]:
|
||||||
if x in message:
|
if x in message:
|
||||||
toUndo = True
|
toUndo = True
|
||||||
messageDuplicate = messageDuplicate.replace(x, "\0\r\n\n\0")
|
messageDuplicate = messageDuplicate.replace(x, "\0\r\n\n\0")
|
||||||
|
@ -68,10 +68,10 @@ def isKeyword(msg):
|
||||||
|
|
||||||
def actKeyword(user, channel, message, nickname, actType, name):
|
def actKeyword(user, channel, message, nickname, actType, name):
|
||||||
toSend = isKeyword(message)
|
toSend = isKeyword(message)
|
||||||
if name == config["Master"][0] and channel == config["Master"][1]:
|
if name == main.config["Master"][0] and channel == main.config["Master"][1]:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if config["HighlightNotifications"]:
|
if main.config["HighlightNotifications"]:
|
||||||
msgLower = message.lower()
|
msgLower = message.lower()
|
||||||
nickLower = nickname.lower()
|
nickLower = nickname.lower()
|
||||||
if nickLower in msgLower:
|
if nickLower in msgLower:
|
||||||
|
@ -83,19 +83,19 @@ def actKeyword(user, channel, message, nickname, actType, name):
|
||||||
count.event(name, "keymatch")
|
count.event(name, "keymatch")
|
||||||
|
|
||||||
def addKeyword(keyword):
|
def addKeyword(keyword):
|
||||||
if keyword in keyconf["Keywords"]:
|
if keyword in main.keyconf["Keywords"]:
|
||||||
return "EXISTS"
|
return "EXISTS"
|
||||||
else:
|
else:
|
||||||
for i in keyconf["Keywords"]:
|
for i in main.keyconf["Keywords"]:
|
||||||
if i in keyword or keyword in i:
|
if i in keyword or keyword in i:
|
||||||
return "ISIN"
|
return "ISIN"
|
||||||
keyconf["Keywords"].append(keyword)
|
main.keyconf["Keywords"].append(keyword)
|
||||||
saveConf("keyconf")
|
main.saveConf("keyconf")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def delKeyword(keyword):
|
def delKeyword(keyword):
|
||||||
if not keyword in keyconf["Keywords"]:
|
if not keyword in main.keyconf["Keywords"]:
|
||||||
return "NOKEY"
|
return "NOKEY"
|
||||||
keyconf["Keywords"].remove(keyword)
|
main.keyconf["Keywords"].remove(keyword)
|
||||||
saveConf("keyconf")
|
main.saveConf("keyconf")
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -1,32 +1,34 @@
|
||||||
from core.main import *
|
import main
|
||||||
from string import digits
|
from string import digits
|
||||||
#from utils.logging.log import *
|
#from utils.logging.log import *
|
||||||
|
|
||||||
def setWho(network, newObjects):
|
def setWho(network, newObjects):
|
||||||
network = "".join([x for x in network if not x in digits])
|
network = "".join([x for x in network if not x in digits])
|
||||||
if not network in wholist.keys():
|
if not network in main.wholist.keys():
|
||||||
wholist[network] = {}
|
main.wholist[network] = {}
|
||||||
for i in newObjects.keys():
|
for i in newObjects.keys():
|
||||||
wholist[network][i] = newObjects[i]
|
main.wholist[network][i] = newObjects[i]
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def setWhoSingle(network, nick, ident, host):
|
def setWhoSingle(network, nick, ident, host):
|
||||||
network = "".join([x for x in network if not x in digits])
|
network = "".join([x for x in network if not x in digits])
|
||||||
|
|
||||||
if network in wholist.keys():
|
if network in main.wholist.keys():
|
||||||
if nick in wholist[network].keys():
|
if nick in main.wholist[network].keys():
|
||||||
wholist[network][nick][1] = ident
|
main.wholist[network][nick][1] = ident
|
||||||
wholist[network][nick][2] = host
|
main.wholist[network][nick][2] = host
|
||||||
else:
|
else:
|
||||||
wholist[network][nick] = [nick, ident, host, None, None, None]
|
main.wholist[network][nick] = [nick, ident, host, None, None, None]
|
||||||
|
else:
|
||||||
|
main.wholist[network] = {nick: [nick, ident, host, None, None, None]}
|
||||||
|
|
||||||
def getWho(nick):
|
def getWho(nick):
|
||||||
result = {}
|
result = {}
|
||||||
for i in wholist.keys():
|
for i in main.wholist.keys():
|
||||||
for x in wholist[i].keys():
|
for x in main.wholist[i].keys():
|
||||||
if nick.lower() == x.lower():
|
if nick.lower() == x.lower():
|
||||||
if not i in result.keys():
|
if not i in result.keys():
|
||||||
result[i] = []
|
result[i] = []
|
||||||
result[i].append(wholist[i][x])
|
result[i].append(main.wholist[i][x])
|
||||||
return result
|
return result
|
||||||
|
|
38
threshold
38
threshold
|
@ -6,29 +6,9 @@ from twisted.internet.ssl import DefaultOpenSSLContextFactory
|
||||||
#from sys import stdout
|
#from sys import stdout
|
||||||
#log.startLogging(stdout)
|
#log.startLogging(stdout)
|
||||||
|
|
||||||
from core.main import (
|
import main
|
||||||
configPath,
|
|
||||||
certPath,
|
|
||||||
connections,
|
|
||||||
IRCPool,
|
|
||||||
ReactorPool,
|
|
||||||
FactoryPool,
|
|
||||||
MonitorPool,
|
|
||||||
saveConf,
|
|
||||||
loadConf,
|
|
||||||
initMain,
|
|
||||||
)
|
|
||||||
|
|
||||||
initMain()
|
main.initMain()
|
||||||
|
|
||||||
from core.main import (
|
|
||||||
config,
|
|
||||||
keyconf,
|
|
||||||
pool,
|
|
||||||
help,
|
|
||||||
wholist,
|
|
||||||
counters,
|
|
||||||
)
|
|
||||||
|
|
||||||
from utils.logging.log import *
|
from utils.logging.log import *
|
||||||
import modules.userinfo as userinfo
|
import modules.userinfo as userinfo
|
||||||
|
@ -37,14 +17,14 @@ from core.server import Server, ServerFactory
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
listener = ServerFactory()
|
listener = ServerFactory()
|
||||||
if config["Listener"]["UseSSL"] == True:
|
if main.config["Listener"]["UseSSL"] == True:
|
||||||
reactor.listenSSL(config["Listener"]["Port"], listener, DefaultOpenSSLContextFactory(certPath+config["Listener"]["Key"], certPath+config["Listener"]["Certificate"]), interface=config["Listener"]["Address"])
|
reactor.listenSSL(main.config["Listener"]["Port"], listener, DefaultOpenSSLContextFactory(main.certPath+main.config["Listener"]["Key"], main.certPath+main.config["Listener"]["Certificate"]), interface=main.config["Listener"]["Address"])
|
||||||
log("Threshold running with SSL on %s:%s" % (config["Listener"]["Address"], config["Listener"]["Port"]))
|
log("Threshold running with SSL on %s:%s" % (main.config["Listener"]["Address"], main.config["Listener"]["Port"]))
|
||||||
else:
|
else:
|
||||||
reactor.listenTCP(config["Listener"]["Port"], listener, interface=config["Listener"]["Address"])
|
reactor.listenTCP(main.config["Listener"]["Port"], listener, interface=main.config["Listener"]["Address"])
|
||||||
log("Threshold running on %s:%s" % (config["Listener"]["Address"], config["Listener"]["Port"]))
|
log("Threshold running on %s:%s" % (main.config["Listener"]["Address"], main.config["Listener"]["Port"]))
|
||||||
for i in pool.keys():
|
for i in main.pool.keys():
|
||||||
if pool[i]["enabled"] == True:
|
if main.pool[i]["enabled"] == True:
|
||||||
helper.addBot(i)
|
helper.addBot(i)
|
||||||
|
|
||||||
reactor.run()
|
reactor.run()
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from os import listdir
|
from os import listdir
|
||||||
from core.main import *
|
|
||||||
from utils.logging.log import *
|
from utils.logging.log import *
|
||||||
import commands
|
import commands
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
from os import listdir
|
from os import listdir
|
||||||
from core.main import *
|
import main
|
||||||
from utils.logging.log import *
|
from utils.logging.log import *
|
||||||
import commands
|
import commands
|
||||||
|
|
||||||
def loadSingle(command, func):
|
def loadSingle(command, func):
|
||||||
if command+".py" in listdir("commands"):
|
if command+".py" in listdir("commands"):
|
||||||
try:
|
try:
|
||||||
if command in CommandMap.keys():
|
if command in main.CommandMap.keys():
|
||||||
return "Cannot reload modules"
|
return "Cannot reload modules"
|
||||||
else:
|
else:
|
||||||
className = command.capitalize()
|
className = command.capitalize()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from core.main import connections, help
|
import main
|
||||||
|
|
||||||
def sendData(addr, data):
|
def sendData(addr, data):
|
||||||
connections[addr].send(data)
|
main.connections[addr].send(data)
|
||||||
|
|
||||||
def sendSuccess(addr, data):
|
def sendSuccess(addr, data):
|
||||||
sendData(addr, "[y] " + data)
|
sendData(addr, "[y] " + data)
|
||||||
|
@ -13,14 +13,14 @@ def sendInfo(addr, data):
|
||||||
sendData(addr, "[i] " + data)
|
sendData(addr, "[i] " + data)
|
||||||
|
|
||||||
def sendAll(data):
|
def sendAll(data):
|
||||||
for i in connections:
|
for i in main.connections:
|
||||||
connections[i].send(data)
|
main.connections[i].send(data)
|
||||||
return
|
return
|
||||||
|
|
||||||
def incorrectUsage(addr, mode):
|
def incorrectUsage(addr, mode):
|
||||||
if mode == None:
|
if mode == None:
|
||||||
sendFailure(addr, "Incorrect usage")
|
sendFailure(addr, "Incorrect usage")
|
||||||
return
|
return
|
||||||
if mode in help.keys():
|
if mode in main.help.keys():
|
||||||
sendFailure(addr, "Usage: " + help[mode])
|
sendFailure(addr, "Usage: " + main.help[mode])
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue