Skip to content
Permalink
Browse files

Fix a bug in usercommand that let spam text with unregistered commands

  • Loading branch information
nado committed Jan 20, 2016
1 parent 12e0a07 commit 8e7f15a003365257ee074384b35d2ead68e9e1ab
Showing with 7 additions and 1 deletion.
  1. +7 −1 plugins/usercommand/middleware.go
@@ -1,6 +1,7 @@
package usercommand

import (
"log"
"strings"

"github.com/depado/go-b0tsec/configuration"
@@ -33,9 +34,14 @@ func (m *Middleware) Get(ib *irc.Connection, from string, to string, message str
if !strings.HasPrefix(message, cnf.UserCommandCharacter) || len(message) == 1 {
return
}

splittedMsg := strings.Fields(message[1:])
uc := UserCommand{splittedMsg[0], ""}
database.BotStorage.Get(bucketName, uc.Name, &uc)

if err := database.BotStorage.Get(bucketName, uc.Name, &uc); err != nil {
log.Println(err)
return
}

if strings.HasPrefix(uc.Value, cnf.CommandCharacter) {
if len(uc.Value) > 1 {

0 comments on commit 8e7f15a

Please sign in to comment.
You can’t perform that action at this time.