From b12a7d76f8c15b3aa5ace48fe22d602dc46b1690 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Mon, 6 Jul 2020 17:02:41 -0700 Subject: [PATCH] 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 --- lib/plugin/base.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/plugin/base.ex b/lib/plugin/base.ex index 3b6e9c7..5fd3ecd 100644 --- a/lib/plugin/base.ex +++ b/lib/plugin/base.ex @@ -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