Don't return slash in Command, strip bot name if needed.

This commit is contained in:
Syfaro 2016-01-04 11:45:46 -06:00
parent 5df7aae78f
commit b7c9b50020
2 changed files with 18 additions and 2 deletions

View file

@ -129,12 +129,20 @@ func (m *Message) IsCommand() bool {
// Command checks if the message was a command and if it was, returns the
// command. If the Message was not a command, it returns an empty string.
//
// If the command contains the at bot syntax, it removes the bot name.
func (m *Message) Command() string {
if !m.IsCommand() {
return ""
}
return strings.SplitN(m.Text, " ", 2)[0]
command := strings.SplitN(m.Text, " ", 2)[0][1:]
if i := strings.Index(command, "@"); i != -1 {
command = command[:i]
}
return command
}
// CommandArguments checks if the message was a command and if it was,