Replace sanitize with gumbleutil.PlainText
This commit is contained in:
parent
9930f4c9ea
commit
a28450e5ca
|
@ -5,6 +5,7 @@ MumbleDJ Changelog
|
|||
* Updated `gumble` and `gumbleutil` dependencies.
|
||||
* Removed `sanitize` dependency.
|
||||
* Reworked `Makefile` slightly.
|
||||
* Now uses `gumbleutil.PlainText` for removing HTML tags instead of `sanitize`.
|
||||
|
||||
### February 3, 2015 -- `v2.4.1`
|
||||
* Made it possible to place MumbleDJ binary in `~/bin` instead of `/usr/local/bin` if the folder exists.
|
||||
|
|
11
commands.go
11
commands.go
|
@ -10,7 +10,6 @@ package main
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/kennygrant/sanitize"
|
||||
"github.com/layeh/gumble/gumble"
|
||||
"os"
|
||||
"regexp"
|
||||
|
@ -22,11 +21,11 @@ import (
|
|||
// it contains a command.
|
||||
func parseCommand(user *gumble.User, username, command string) {
|
||||
var com, argument string
|
||||
newlineSplit := strings.Split(command, "<br />")
|
||||
sanitizedCommand := sanitize.HTML(newlineSplit[0])
|
||||
if strings.Contains(sanitizedCommand, " ") {
|
||||
index := strings.Index(sanitizedCommand, " ")
|
||||
com, argument = sanitizedCommand[0:index], sanitizedCommand[(index+1):]
|
||||
split := strings.Split(command, "\n")
|
||||
splitString := split[0]
|
||||
if strings.Contains(splitString, " ") {
|
||||
index := strings.Index(splitString, " ")
|
||||
com, argument = splitString[0:index], splitString[(index+1):]
|
||||
} else {
|
||||
com = command
|
||||
argument = ""
|
||||
|
|
5
main.go
5
main.go
|
@ -67,8 +67,9 @@ func (dj *mumbledj) OnDisconnect(e *gumble.DisconnectEvent) {
|
|||
// OnTextMessage event. Checks for command prefix, and calls parseCommand if it exists. Ignores
|
||||
// the incoming message otherwise.
|
||||
func (dj *mumbledj) OnTextMessage(e *gumble.TextMessageEvent) {
|
||||
if e.Message[0] == dj.conf.General.CommandPrefix[0] && e.Message != dj.conf.General.CommandPrefix {
|
||||
parseCommand(e.Sender, e.Sender.Name(), e.Message[1:])
|
||||
plainMessage := gumbleutil.PlainText(&e.TextMessage)
|
||||
if plainMessage[0] == dj.conf.General.CommandPrefix[0] && plainMessage != dj.conf.General.CommandPrefix {
|
||||
parseCommand(e.Sender, e.Sender.Name(), plainMessage[1:])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue