Implement indexing into Apache Druid #1
|
@ -0,0 +1,33 @@
|
|||
import main
|
||||
|
||||
from utils.get import getRelay
|
||||
|
||||
class GetstrCommand:
|
||||
def __init__(self, *args):
|
||||
self.getstr(*args)
|
||||
|
||||
def getstr(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
if length == 3:
|
||||
net = spl[1]
|
||||
num = spl[2]
|
||||
if not net in main.network.keys():
|
||||
failure("Network does not exist: %s" % net)
|
||||
return
|
||||
if not num.isdigit():
|
||||
failure("Must be a number, not %s" % num)
|
||||
return
|
||||
num = int(num)
|
||||
alias = main.alias[num]["nick"].lower()
|
||||
host, port = getRelay(num)
|
||||
password = main.config["Relay"]["Password"]
|
||||
connstr = f"/connect -ssl {host} {port}"
|
||||
authstr = f"/quote PASS {alias}/{net}:{password}"
|
||||
obj.send(connstr)
|
||||
obj.send(authstr)
|
||||
|
||||
else:
|
||||
incUsage("getstr")
|
||||
return
|
||||
else:
|
||||
incUsage(None)
|
|
@ -33,5 +33,6 @@
|
|||
"authcheck": "authcheck [<network>]",
|
||||
"recheckauth": "recheckauth [<network>]",
|
||||
"blacklist": "blacklist <network> <channel>",
|
||||
"email": "email <add|del|list> [(domain)|<num>] [<email>]"
|
||||
"email": "email <add|del|list> [(domain)|<num>] [<email>]",
|
||||
"getstr": "getstr <net> <num>"
|
||||
}
|
||||
|
|
11
core/bot.py
11
core/bot.py
|
@ -480,6 +480,8 @@ class IRCBot(IRCClient):
|
|||
chankeep.initialList(self.net, self.num, listinfo)
|
||||
|
||||
def recheckList(self):
|
||||
if not main.config["ChanKeep"]["Enabled"]:
|
||||
return
|
||||
allRelays = chankeep.allRelaysActive(self.net)
|
||||
debug(f"recheckList() all relays for {self.net} {allRelays}")
|
||||
if allRelays:
|
||||
|
@ -526,9 +528,10 @@ class IRCBot(IRCClient):
|
|||
if net_inst_chanlimit:
|
||||
if self.chanlimit > net_inst_chanlimit:
|
||||
self.chanlimit = net_inst_chanlimit
|
||||
warn(f"Chanlimit on {self.net} too high, setting to {self.chanlimit}")
|
||||
# warn(f"Chanlimit on {self.net} too high, setting to {self.chanlimit}")
|
||||
|
||||
if not regproc.needToRegister(self.net): # if we need to register, only recheck on auth confirmation
|
||||
if main.config["ChanKeep"]["Enabled"]:
|
||||
self.recheckList()
|
||||
|
||||
def seed_prefix(self, prefix):
|
||||
|
@ -618,6 +621,8 @@ class IRCBot(IRCClient):
|
|||
def regPing(self, negativepass=None):
|
||||
if self.authenticated:
|
||||
return
|
||||
if not regproc.needToRegister(self.net):
|
||||
self.authenticated = True
|
||||
sinst = regproc.substitute(self.net, self.num)
|
||||
if not sinst:
|
||||
error(f"regPing() {self.net}: registration ping failed for {self.num}")
|
||||
|
@ -630,7 +635,7 @@ class IRCBot(IRCClient):
|
|||
if negativepass is True:
|
||||
if self._negativePass is None:
|
||||
self._negativePass = True
|
||||
debug(f"regPing() {self.net}: positive registration check - {self.num}")
|
||||
debug(f"regPing() {self.net}: negpass:True positive registration check - {self.num}")
|
||||
if sinst["ping"]:
|
||||
debug("Sending ping - %s - %i" % (self.net, self.num))
|
||||
self.msg(sinst["entity"], sinst["pingmsg"])
|
||||
|
@ -644,11 +649,13 @@ class IRCBot(IRCClient):
|
|||
if sinst["negative"]:
|
||||
self._negativePass = None
|
||||
self.msg(sinst["entity"], sinst["negativemsg"])
|
||||
debug(f"regPing() {self.net}: sent negativemsg '{sinst['negativemsg']}' to {sinst['entity']} - {self.num}")
|
||||
return
|
||||
else:
|
||||
self._negativePass = True
|
||||
if sinst["ping"]:
|
||||
self.msg(sinst["entity"], sinst["pingmsg"])
|
||||
debug(f"regPing() {self.net}: sent ping '{sinst['pingmsg']}' to {sinst['entity']} - {self.num}")
|
||||
return
|
||||
else:
|
||||
self.authenticated = True
|
||||
|
|
|
@ -16,7 +16,7 @@ def getEnabledRelays(net):
|
|||
:return: list of enabled relay numbers
|
||||
"""
|
||||
enabledRelays = [x for x in main.network[net].relays.keys() if main.network[net].relays[x]["enabled"]]
|
||||
debug(f"getEnabledRelays() {net}: {enabledRelays}")
|
||||
# debug(f"getEnabledRelays() {net}: {enabledRelays}")
|
||||
return enabledRelays
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@ def getConnectedRelays(net):
|
|||
if name in main.IRCPool.keys():
|
||||
if main.IRCPool[name].isconnected:
|
||||
connectedRelays.append(i)
|
||||
debug(f"getConnectedRelays() {net}: {connectedRelays}")
|
||||
# debug(f"getConnectedRelays() {net}: {connectedRelays}")
|
||||
return connectedRelays
|
||||
|
||||
|
||||
|
@ -50,15 +50,15 @@ def getActiveRelays(net):
|
|||
for i in enabledRelays:
|
||||
name = net + str(i)
|
||||
if name in main.IRCPool.keys():
|
||||
debug(
|
||||
(
|
||||
f"getActiveRelays() {net}: {i} auth:{main.IRCPool[name].authenticated} "
|
||||
f"conn:{main.IRCPool[name].isconnected}"
|
||||
)
|
||||
)
|
||||
# debug(
|
||||
# (
|
||||
# f"getActiveRelays() {net}: {i} auth:{main.IRCPool[name].authenticated} "
|
||||
# f"conn:{main.IRCPool[name].isconnected}"
|
||||
# )
|
||||
# )
|
||||
if main.IRCPool[name].authenticated and main.IRCPool[name].isconnected:
|
||||
activeRelays.append(i)
|
||||
debug(f"getActiveRelays() {net}: {activeRelays}")
|
||||
# debug(f"getActiveRelays() {net}: {activeRelays}")
|
||||
return activeRelays
|
||||
|
||||
|
||||
|
@ -84,7 +84,7 @@ def allRelaysActive(net):
|
|||
activeRelays = getActiveRelays(net)
|
||||
enabledRelays = getEnabledRelays(net)
|
||||
relaysActive = len(activeRelays) == len(enabledRelays)
|
||||
debug(f"allRelaysActive() {net}: {relaysActive} ({activeRelays}/{enabledRelays})")
|
||||
# debug(f"allRelaysActive() {net}: {relaysActive} ({activeRelays}/{enabledRelays})")
|
||||
return relaysActive
|
||||
|
||||
|
||||
|
|
|
@ -12,16 +12,16 @@ def get_first_relay(net):
|
|||
"""
|
||||
cur_relay = 0
|
||||
max_relay = len(main.network[net].relays.keys()) + 1
|
||||
debug(f"get_first_relay() {net}: max_relay:{max_relay}")
|
||||
# debug(f"get_first_relay() {net}: max_relay:{max_relay}")
|
||||
activeRelays = chankeep.getActiveRelays(net)
|
||||
debug(f"get_first_relay() {net}: activeRelays:{activeRelays}")
|
||||
# debug(f"get_first_relay() {net}: activeRelays:{activeRelays}")
|
||||
while cur_relay != max_relay:
|
||||
cur_relay += 1
|
||||
if cur_relay not in activeRelays:
|
||||
continue
|
||||
name = net + str(cur_relay)
|
||||
if name in main.IRCPool.keys():
|
||||
debug(f"get_first_relay() {net}: found relay {name}")
|
||||
# debug(f"get_first_relay() {net}: found relay {name}")
|
||||
return main.IRCPool[name]
|
||||
return None
|
||||
|
||||
|
|
|
@ -146,6 +146,8 @@ def get_unregistered_relays(net=None):
|
|||
def registerTest(c):
|
||||
sinst = substitute(c["net"], c["num"])
|
||||
name = c["net"] + str(c["num"])
|
||||
net = c["net"]
|
||||
num = c["num"]
|
||||
if sinst["check"] is False:
|
||||
return
|
||||
if "msg" in c.keys() and not c["msg"] is None:
|
||||
|
@ -157,24 +159,28 @@ def registerTest(c):
|
|||
confirmRegistration(
|
||||
c["net"], c["num"], negativepass=False
|
||||
) # Not passed negative check, report back
|
||||
debug(f"registerTest() {net} - {num} not passed negative:checknegativemsg check, {sinst['checknegativemsg']} present in message")
|
||||
return
|
||||
if sinst["checkendnegative"] in c["msg"]:
|
||||
confirmRegistration(
|
||||
c["net"], c["num"], negativepass=True
|
||||
) # Passed the negative check, report back
|
||||
debug(f"registerTest() {net} - {num} passed negative:checkendnegative check, {sinst['checkendnegative']} present in message")
|
||||
return
|
||||
if sinst["ping"]:
|
||||
if sinst["checkmsg2"] in c["msg"] and c["nick"] == sinst["entity"]:
|
||||
confirmRegistration(c["net"], c["num"])
|
||||
debug(f"registerTest() {net} - {num} passed ping:checkmsg2 check, {sinst['checkmsg2']} present in message")
|
||||
return
|
||||
if sinst["checktype"] == "msg":
|
||||
if "msg" in c.keys():
|
||||
if sinst["checkmsg"] in c["msg"]:
|
||||
confirmRegistration(c["net"], c["num"])
|
||||
debug(f"registerTest() {net} - {num} passed checktype:msg:checkmsg check, {sinst['checkmsg']} present in message")
|
||||
return
|
||||
elif sinst["checktype"] == "mode":
|
||||
if c["type"] == "self":
|
||||
if c["mtype"] == "mode":
|
||||
if sinst["checkmode"] in c["mode"] and c["status"] is True:
|
||||
confirmRegistration(c["net"], c["num"])
|
||||
debug(f"registerTest() {net} - {num} passed checktype:mode:checkmost check, {sinst['checkmode']} present in mode")
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue