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 <alekratz@gmail.com>
This commit is contained in:
@@ -49,12 +49,13 @@ defmodule Omnibot.Irc.Msg do
|
|||||||
|
|
||||||
params =
|
params =
|
||||||
String.slice(params, 1..-1)
|
String.slice(params, 1..-1)
|
||||||
|> String.split(" ")
|
|> String.split()
|
||||||
|> Enum.filter(fn s -> String.length(s) > 0 end)
|
|> Enum.filter(fn s -> String.length(s) > 0 end)
|
||||||
|
|
||||||
trailing =
|
trailing =
|
||||||
trailing
|
trailing
|
||||||
|> String.slice(2..-1)
|
|> String.slice(2..-1)
|
||||||
|
|> String.trim()
|
||||||
|> Util.string_or_nil()
|
|> Util.string_or_nil()
|
||||||
|
|
||||||
params = if trailing, do: params ++ [trailing], else: params
|
params = if trailing, do: params ++ [trailing], else: params
|
||||||
|
|||||||
Reference in New Issue
Block a user