From 0b69893e172844caaccee41fea1f1df2c948fadb Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Mon, 15 Aug 2022 17:59:31 +0100 Subject: [PATCH] Fix query handling and don't send a fake message --- api/views.py | 14 +++++++++++--- core/bot.py | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/api/views.py b/api/views.py index 12269ba..588120d 100644 --- a/api/views.py +++ b/api/views.py @@ -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///", methods=["GET"]) diff --git a/core/bot.py b/core/bot.py index 45d7191..45dd84f 100644 --- a/core/bot.py +++ b/core/bot.py @@ -272,7 +272,7 @@ class IRCBot(IRCClient): hostmask = us[0] else: # Close enough... - hostmask = f"{self.nickname}!*@{self.servername}" + hostmask = f"{self.nickname}!{self.nickname}@{self.servername}" warn(f"Could not get a hostname, using {hostmask}") nick, ident, host = parsen(hostmask) # We sent someone a query reply @@ -280,7 +280,7 @@ class IRCBot(IRCClient): self.event(type="self", mtype="msg", channel=self.nickname, nick=channel, ident=ident, host=host, msg=msg) else: self.event(type="self", mtype="msg", channel=channel, nick=self.nickname, ident=ident, host=host, msg=msg) - self.event(type="msg", channel=channel, nick=self.nickname, ident=ident, host=host, msg=msg) + # self.event(type="msg", channel=channel, nick=self.nickname, ident=ident, host=host, msg=msg) self.msg(channel, msg) def get(self, var):