From 6ba9f94e716de98951ca59f58f23a93334c1e4c2 Mon Sep 17 00:00:00 2001 From: Matthieu Grieger Date: Mon, 2 Feb 2015 11:50:31 -0800 Subject: [PATCH] Fix https://github.com/matthieugrieger/mumbledj/issues/32: Newlines messing up \!add commands --- CHANGELOG.md | 1 + commands.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f443d1..d46f3fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ MumbleDJ Changelog * Added panic on audio play fail for debugging purposes. * Fixed '!' being recognized as '!skipplaylist'. * Fixed !reset crash when there is no audio playing. +* Fixed newlines after YouTube URL messing up !add commands. ### January 30, 2015 -- `v2.3.3` * Fixed private messages crashing the bot when the target user switches channels or disconnects. diff --git a/commands.go b/commands.go index ec4402a..e80b06c 100644 --- a/commands.go +++ b/commands.go @@ -22,7 +22,8 @@ import ( // it contains a command. func parseCommand(user *gumble.User, username, command string) { var com, argument string - sanitizedCommand := sanitize.HTML(command) + newlineSplit := strings.Split(command, "
") + sanitizedCommand := sanitize.HTML(newlineSplit[0]) if strings.Contains(sanitizedCommand, " ") { index := strings.Index(sanitizedCommand, " ") com, argument = sanitizedCommand[0:index], sanitizedCommand[(index+1):]