Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
Fix a bug in usercommand that let spam text with unregistered commands
Browse files Browse the repository at this point in the history
  • Loading branch information
nado committed Jan 20, 2016
1 parent 12e0a07 commit 8e7f15a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugins/usercommand/middleware.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package usercommand

import (
"log"
"strings"

"github.com/depado/go-b0tsec/configuration"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8e7f15a

Please sign in to comment.