Fix query handling and don't send a fake message

This commit is contained in:
2022-08-15 17:59:31 +01:00
parent e4c1d80250
commit 0b69893e17
2 changed files with 13 additions and 5 deletions

View File

@@ -608,13 +608,21 @@ class API(object):
if name not in main.IRCPool.keys():
return dumps({"success": False, "reason": f"relay {num} not on {net}"})
# We are in a query
in_query = False
if "nick" in data:
nick = data["nick"]
if nick == channel:
in_query = True
else:
nick = None
if channel == main.IRCPool[name].nickname:
if "nick" not in data:
in_query = True
if nick:
return dumps({"success": False, "reason": "no nick specified to query"})
else:
main.IRCPool[name].sendmsg(data["nick"], msg, in_query=True)
main.IRCPool[name].sendmsg(nick, msg, in_query=in_query)
else:
main.IRCPool[name].sendmsg(channel, msg)
main.IRCPool[name].sendmsg(channel, msg, in_query=in_query)
return dumps({"success": True, "message": f"sent message to {channel} on {name}"})
@app.route("/irc/nick/<net>/<num>/", methods=["GET"])