Implement indexing into Apache Druid #1

Closed
m wants to merge 263 commits from druid into master
2 changed files with 28 additions and 0 deletions
Showing only changes of commit 220ce976f2 - Show all commits

View File

@ -478,3 +478,27 @@ class API(object):
return dumps({"success": False, "reason": f"could not get first relay for {net}"}) return dumps({"success": False, "reason": f"could not get first relay for {net}"})
first_relay.list() first_relay.list()
return dumps({"success": True, "message": f"requested list with instance {first_relay.num} of {net}"}) return dumps({"success": True, "message": f"requested list with instance {first_relay.num} of {net}"})
@app.route("/irc/msg/<net>/<num>/<channel>/", methods=["PUT"])
@login_required
def irc_send_message(self, request, net, num, channel):
print("IRC SEND", net, num, channel)
try:
data = loads(request.content.read())
except JSONDecodeError:
return "Invalid JSON"
if "msg" not in data:
return dumps({"success": False, "reason": "no msg."})
msg = data["msg"]
if net not in main.network.keys():
return dumps({"success": False, "reason": "no such net."})
if not num.isdigit():
return dumps({"success": False, "reason": "invalid num: not a number."})
num = int(num)
if num not in main.network[net].relays.keys():
return dumps({"success": False, "reason": f"no relay {num} on {net}"})
name = f"{net}{num}"
if name not in main.IRCPool.keys():
return dumps({"success": False, "reason": f"relay {num} not on {net}"})
main.IRCPool[name].sendmsg(channel, msg)
return dumps({"success": True, "message": f"sent message to {channel} on {name}"})

View File

@ -252,6 +252,10 @@ class IRCBot(IRCClient):
def action(self, user, channel, msg): def action(self, user, channel, msg):
self.event(type="action", muser=user, channel=channel, msg=msg) self.event(type="action", muser=user, channel=channel, msg=msg)
def sendmsg(self, channel, msg):
self.event(type="self", mtype="msg", channel=channel, nick=self.nickname, msg=msg)
self.msg(channel, msg)
def get(self, var): def get(self, var):
try: try:
result = getattr(self, var) result = getattr(self, var)