Add endpoint to get the bot's nickname
This commit is contained in:
parent
a2b6ebd912
commit
7e51178a10
15
api/views.py
15
api/views.py
|
@ -508,3 +508,18 @@ class API(object):
|
||||||
else:
|
else:
|
||||||
main.IRCPool[name].sendmsg(channel, msg)
|
main.IRCPool[name].sendmsg(channel, msg)
|
||||||
return dumps({"success": True, "message": f"sent message to {channel} on {name}"})
|
return dumps({"success": True, "message": f"sent message to {channel} on {name}"})
|
||||||
|
|
||||||
|
@app.route("/irc/nick/<net>/<num>/", methods=["GET"])
|
||||||
|
@login_required
|
||||||
|
def irc_get_nick(self, request, net, num):
|
||||||
|
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}"})
|
||||||
|
return dumps({"nickname": main.IRCPool[name].nickname})
|
Loading…
Reference in New Issue