Properly implement querying with API

This commit is contained in:
2022-08-09 07:20:30 +01:00
parent 813c9baf30
commit e69ce5090a
2 changed files with 16 additions and 5 deletions

View File

@@ -499,5 +499,12 @@ class API(object):
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)
# We are in a query
if channel == main.IRCPool[name].nickname:
if "nick" not in data:
return dumps({"success": False, "reason": "no nick specified to query"})
else:
main.IRCPool[name].sendmsg(data["nick"], msg, in_query=True)
else:
main.IRCPool[name].sendmsg(channel, msg)
return dumps({"success": True, "message": f"sent message to {channel} on {name}"})