Fix small bug where plugins that don't override on_msg/2 would report errors

Since route_msg expects msg.prefix to be present, every plugin that
calls route_msg when no prefix is specified in the message (e.g. with
PING messages) would cause a crash of the process.

Now, it just calls a no-op function, since all behavior covered by
route_message requires information in the prefix at some point.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-07-06 17:02:41 -07:00
parent e4062d06ef
commit b12a7d76f8

View File

@@ -42,6 +42,8 @@ defmodule Omnibot.Plugin.Base do
route_msg(irc, msg)
end
defp route_msg(irc, %Irc.Msg {prefix: nil}), do: nil
defp route_msg(irc, msg) do
nick = msg.prefix.nick
case String.upcase(msg.command) do