From ec1dd42ca1e7eacdbd46dcfe56c75fdc8623409a Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Sat, 18 Jul 2020 14:09:17 -0700 Subject: [PATCH] Fix routing bug in IRC and base plugin Previously, messages were only routed from IRC if they were *not* for the current user. This should only be happening for privmsg messages, since a plugin is generally aware of what it's sending out. Signed-off-by: Alek Ratzloff --- lib/irc/irc.ex | 5 ++--- lib/plugin/base.ex | 17 +++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/irc/irc.ex b/lib/irc/irc.ex index 504fd99..cb29833 100644 --- a/lib/irc/irc.ex +++ b/lib/irc/irc.ex @@ -77,9 +77,8 @@ defmodule Omnibot.Irc do msg = Msg.parse(line) # Send the message to the router - if (!msg.prefix) || (msg.prefix.nick != State.cfg().nick) do - route_msg(self(), msg) - end + route_msg(self(), msg) + {:noreply, socket} end end diff --git a/lib/plugin/base.ex b/lib/plugin/base.ex index 1e4f290..e9ed453 100644 --- a/lib/plugin/base.ex +++ b/lib/plugin/base.ex @@ -44,16 +44,17 @@ defmodule Omnibot.Plugin.Base do nick = msg.prefix.nick case String.upcase(msg.command) do "PRIVMSG" -> - [channel | params] = msg.params - line = Enum.join(params, " ") + if (!msg.prefix) || (msg.prefix.nick != Omnibot.State.cfg().nick) do + [channel | params] = msg.params + line = Enum.join(params, " ") - case String.split(line, " ") do - [cmd | params] -> if Enum.member?(commands(), cmd), - do: on_channel_msg(irc, channel, nick, cmd, params), - else: on_channel_msg(irc, channel, nick, line) - _ -> on_channel_msg(irc, channel, nick, line) + case String.split(line, " ") do + [cmd | params] -> if Enum.member?(commands(), cmd), + do: on_channel_msg(irc, channel, nick, cmd, params), + else: on_channel_msg(irc, channel, nick, line) + _ -> on_channel_msg(irc, channel, nick, line) + end end - "JOIN" -> [channel | _] = msg.params on_join(irc, channel, nick)