From 4cdcc388b6d2e599bbd45094c3d77385f6facbcc Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Mon, 16 Nov 2020 18:20:23 -0800 Subject: [PATCH] Fix bug where message params were not being trimmed properly If you send a message that says: "!command foo bar " (note the ending space) - the parameters given back to the plugin would be: ["foo", "bar "] which is kind of strange in this instance. Therefore, ending whitespace is trimmed for parameters and trailing parameters. Signed-off-by: Alek Ratzloff --- lib/irc/msg.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/irc/msg.ex b/lib/irc/msg.ex index c4f7f6c..d1762ac 100644 --- a/lib/irc/msg.ex +++ b/lib/irc/msg.ex @@ -49,12 +49,13 @@ defmodule Omnibot.Irc.Msg do params = String.slice(params, 1..-1) - |> String.split(" ") + |> String.split() |> Enum.filter(fn s -> String.length(s) > 0 end) trailing = trailing |> String.slice(2..-1) + |> String.trim() |> Util.string_or_nil() params = if trailing, do: params ++ [trailing], else: params