Skip to content
Permalink
Browse files

Merge pull request #24 from nado/various-fixes

Various fixes
  • Loading branch information...
Depado committed Jan 21, 2016
2 parents 064dc2f + bb7bfe7 commit 5c5a7c8600e634c0f19eefd6ae331dacab8a3d55
@@ -49,15 +49,15 @@ func (c *Command) Get(ib *irc.Connection, from string, to string, args []string)
}
}

// Start starts the plugin and returns any occured error, nil otherwise
// Start starts the plugin and returns any occurred error, nil otherwise
func (c *Command) Start() error {
if utils.StringInSlice(command, configuration.Config.Commands) {
c.Started = true
}
return nil
}

// Stop stops the plugin and returns any occured error, nil otherwise
// Stop stops the plugin and returns any occurred error, nil otherwise
func (c *Command) Stop() error {
c.Started = false
return nil
@@ -32,15 +32,15 @@ func (m *Middleware) Get(ib *irc.Connection, from string, to string, message str
}
}

// Start starts the middleware and returns any occured error, nil otherwise
// Start starts the middleware and returns any occurred error, nil otherwise
func (m *Middleware) Start() error {
if utils.StringInSlice(middlewareName, configuration.Config.Middlewares) {
m.Started = true
}
return nil
}

// Stop returns nil when it didnt encounter any error, the error otherwise
// Stop returns nil when it didn’t encounter any error, the error otherwise
func (m *Middleware) Stop() error {
m.Started = false
return nil
@@ -41,15 +41,15 @@ func (c *Command) Get(ib *irc.Connection, from string, to string, args []string)
}
}

// Start starts the plugin and returns any occured error, nil otherwise
// Start starts the plugin and returns any occurred error, nil otherwise
func (c *Command) Start() error {
if utils.StringInSlice(command, configuration.Config.Commands) {
c.Started = true
}
return nil
}

// Stop stops the plugin and returns any occured error, nil otherwise
// Stop stops the plugin and returns any occurred error, nil otherwise
func (c *Command) Stop() error {
c.Started = false
return nil
@@ -48,15 +48,15 @@ func (c *Command) Get(ib *irc.Connection, from string, to string, args []string)
}
}

// Start starts the plugin and returns any occured error, nil otherwise
// Start starts the plugin and returns any occurred error, nil otherwise
func (c *Command) Start() error {
if utils.StringInSlice(command, configuration.Config.Commands) {
c.Started = true
}
return nil
}

// Stop stops the plugin and returns any occured error, nil otherwise
// Stop stops the plugin and returns any occurred error, nil otherwise
func (c *Command) Stop() error {
c.Started = false
return nil
@@ -69,15 +69,15 @@ func (c *Command) Get(ib *irc.Connection, from string, to string, args []string)
}
}

// Start starts the plugin and returns any occured error, nil otherwise
// Start starts the plugin and returns any occurred error, nil otherwise
func (c *Command) Start() error {
if utils.StringInSlice(command, configuration.Config.Commands) {
c.Started = true
}
return nil
}

// Stop stops the plugin and returns any occured error, nil otherwise
// Stop stops the plugin and returns any occurred error, nil otherwise
func (c *Command) Stop() error {
c.Started = false
return nil
@@ -79,15 +79,15 @@ func (c *Command) Get(ircbot *irc.Connection, from string, to string, args []str
}
}

// Start starts the plugin and returns any occured error, nil otherwise
// Start starts the plugin and returns any occurred error, nil otherwise
func (c *Command) Start() error {
if utils.StringInSlice(command, configuration.Config.Commands) {
c.Started = true
}
return nil
}

// Stop stops the plugin and returns any occured error, nil otherwise
// Stop stops the plugin and returns any occurred error, nil otherwise
func (c *Command) Stop() error {
c.Started = false
return nil
@@ -77,15 +77,15 @@ func (m *Middleware) Get(ib *irc.Connection, from string, to string, message str
}
}

// Start starts the middleware and returns any occured error, nil otherwise
// Start starts the middleware and returns any occurred error, nil otherwise
func (m *Middleware) Start() error {
if utils.StringInSlice(middlewareName, configuration.Config.Middlewares) {
m.Started = true
}
return nil
}

// Stop stops the middleware and returns any occured error, nil otherwise
// Stop stops the middleware and returns any occurred error, nil otherwise
func (m *Middleware) Stop() error {
m.Started = false
return nil
@@ -23,7 +23,7 @@ type Middleware interface {
IsStarted() bool
}

// Plugins is the map structure of all configured plugins
// Commands is the map structure of all configured plugins
var Commands = map[string]Command{}

// Middlewares is the slice of all configured middlewares Get() func
@@ -21,7 +21,7 @@ const (
mainKey = "main"
)

// Data is the struct that contains the data about the karma intented to be stored somewhere.
// Data is the struct that contains the data about the karma intended to be stored somewhere.
type Data struct {
Karma map[string]int
}
@@ -166,7 +166,7 @@ func (c *Command) Get(ib *irc.Connection, from string, to string, args []string)
}
}

// Start starts the plugin and returns any occured error, nil otherwise
// Start starts the plugin and returns any occurred error, nil otherwise
func (c *Command) Start() error {
if utils.StringInSlice(command, configuration.Config.Commands) {
if err := database.BotStorage.CreateBucket(bucketName); err != nil {
@@ -180,7 +180,7 @@ func (c *Command) Start() error {
return nil
}

// Stop stops the plugin and returns any occured error, nil otherwise
// Stop stops the plugin and returns any occurred error, nil otherwise
func (c *Command) Stop() error {
c.Started = false
return nil
@@ -56,7 +56,7 @@ func (m *Middleware) Get(ib *irc.Connection, from string, to string, message str
}
}

// Start starts the middleware and returns any occured error, nil otherwise
// Start starts the middleware and returns any occurred error, nil otherwise
func (m *Middleware) Start() error {
if utils.StringInSlice(middlewareName, configuration.Config.Middlewares) {
if err := InitLoggers(); err != nil {
@@ -67,19 +67,19 @@ func (m *Middleware) Start() error {
return nil
}

// Stop returns nil when it didnt encounter any error, the error otherwise
// Stop returns nil when it didn’t encounter any error, the error otherwise
func (m *Middleware) Stop() error {
if !m.Started {
return nil
}
var closeErr error
if err := HistoryFile.Close(); err != nil {
log.Printf("Error closing history file : %s\n", err)
closeErr = fmt.Errorf("error occured while closing loggers’ files")
closeErr = fmt.Errorf("error occurred while closing loggers’ files")
}
if err := LinkFile.Close(); err != nil {
log.Printf("closing links file : %s\n", err)
closeErr = fmt.Errorf("error occured while closing loggers’ files")
closeErr = fmt.Errorf("error occurred while closing loggers’ files")
}

if closeErr != nil {
@@ -44,15 +44,15 @@ func (c *Command) Get(ib *irc.Connection, from string, to string, args []string)
ib.Privmsg(to, MainChain.Generate())
}

// Start starts the plugin and returns any occured error, nil otherwise
// Start starts the plugin and returns any occurred error, nil otherwise
func (c *Command) Start() error {
if utils.StringInSlice(command, configuration.Config.Commands) {
c.Started = true
}
return nil
}

// Stop stops the plugin and returns any occured error, nil otherwise
// Stop stops the plugin and returns any occurred error, nil otherwise
func (c *Command) Stop() error {
c.Started = false
return nil
@@ -53,7 +53,7 @@ func (m *Middleware) Get(ib *irc.Connection, from string, to string, message str
}
}

// Start starts the middleware and returns any occured error, nil otherwise
// Start starts the middleware and returns any occurred error, nil otherwise
func (m *Middleware) Start() error {
if utils.StringInSlice(middlewareName, configuration.Config.Middlewares) {
MainChain = NewChain("main")
@@ -67,7 +67,7 @@ func (m *Middleware) Start() error {
return nil
}

// Stop stops the middleware and returns any occured error, nil otherwise
// Stop stops the middleware and returns any occurred error, nil otherwise
func (m *Middleware) Stop() error {
MainChain = nil
m.Started = false
@@ -57,15 +57,15 @@ func (c *Command) Get(ib *irc.Connection, from string, to string, args []string)
}
}

// Start starts the plugin and returns any occured error, nil otherwise
// Start starts the plugin and returns any occurred error, nil otherwise
func (c *Command) Start() error {
if utils.StringInSlice(command, configuration.Config.Commands) {
c.Started = true
}
return nil
}

// Stop stops the plugin and returns any occured error, nil otherwise
// Stop stops the plugin and returns any occurred error, nil otherwise
func (c *Command) Stop() error {
c.Started = false
return nil
@@ -30,15 +30,15 @@ func (m *Middleware) Get(ib *irc.Connection, from string, to string, message str
Map[from] = time.Now()
}

// Start starts the middleware and returns any occured error, nil otherwise
// Start starts the middleware and returns any occurred error, nil otherwise
func (m *Middleware) Start() error {
if utils.StringInSlice(middlewareName, configuration.Config.Middlewares) {
m.Started = true
}
return nil
}

// Stop stops the middleware and returns any occured error, nil otherwise
// Stop stops the middleware and returns any occurred error, nil otherwise
func (m *Middleware) Stop() error {
m.Started = false
return nil
@@ -147,15 +147,15 @@ func (m *Middleware) Get(ib *irc.Connection, from string, to string, message str
}
}

// Start starts the middleware and returns any occured error, nil otherwise
// Start starts the middleware and returns any occurred error, nil otherwise
func (m *Middleware) Start() error {
if utils.StringInSlice(middlewareName, configuration.Config.Middlewares) {
m.Started = true
}
return nil
}

// Stop stops the middleware and returns any occured error, nil otherwise
// Stop stops the middleware and returns any occurred error, nil otherwise
func (m *Middleware) Stop() error {
m.Started = false
return nil
@@ -70,15 +70,15 @@ func (c *Command) Get(ib *irc.Connection, from string, to string, args []string)
}
}

// Start starts the plugin and returns any occured error, nil otherwise
// Start starts the plugin and returns any occurred error, nil otherwise
func (c *Command) Start() error {
if utils.StringInSlice(command, configuration.Config.Commands) {
c.Started = true
}
return nil
}

// Stop stops the plugin and returns any occured error, nil otherwise
// Stop stops the plugin and returns any occurred error, nil otherwise
func (c *Command) Stop() error {
c.Started = false
return nil
@@ -127,15 +127,15 @@ func (c *Command) fetch(query string) error {
return nil
}

// Start starts the plugin and returns any occured error, nil otherwise
// Start starts the plugin and returns any occurred error, nil otherwise
func (c *Command) Start() error {
if utils.StringInSlice(command, configuration.Config.Commands) {
c.Started = true
}
return nil
}

// Stop stops the plugin and returns any occured error, nil otherwise
// Stop stops the plugin and returns any occurred error, nil otherwise
func (c *Command) Stop() error {
c.Started = false
return nil
@@ -80,7 +80,7 @@ func (c *Command) Get(ib *irc.Connection, from string, to string, args []string)
ib.Privmsgf(to, "Registered commands : %s", strings.Join(l, " "))
}

// Start starts the plugin and returns any occured error, nil otherwise
// Start starts the plugin and returns any occurred error, nil otherwise
func (c *Command) Start() error {
if utils.StringInSlice(command, configuration.Config.Commands) {
CreateBucket()
@@ -89,7 +89,7 @@ func (c *Command) Start() error {
return nil
}

// Stop stops the plugin and returns any occured error, nil otherwise
// Stop stops the plugin and returns any occurred error, nil otherwise
func (c *Command) Stop() error {
c.Started = false
return nil
@@ -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 {
@@ -56,7 +62,7 @@ func (m *Middleware) Get(ib *irc.Connection, from string, to string, message str
ib.Privmsg(to, msg)
}

// Start starts the middleware and returns any occured error, nil otherwise
// Start starts the middleware and returns any occurred error, nil otherwise
func (m *Middleware) Start() error {
if utils.StringInSlice(middlewareName, configuration.Config.Middlewares) {
CreateBucket()
@@ -65,7 +71,7 @@ func (m *Middleware) Start() error {
return nil
}

// Stop stops the middleware and returns any occured error, nil otherwise
// Stop stops the middleware and returns any occurred error, nil otherwise
func (m *Middleware) Stop() error {
m.Started = false
return nil
@@ -75,15 +75,15 @@ func (c *Command) Get(ib *irc.Connection, from string, to string, args []string)
}
}

// Start starts the plugin and returns any occured error, nil otherwise
// Start starts the plugin and returns any occurred error, nil otherwise
func (c *Command) Start() error {
if utils.StringInSlice(pluginCommand, configuration.Config.Commands) {
c.Started = true
}
return nil
}

// Stop stops the plugin and returns any occured error, nil otherwise
// Stop stops the plugin and returns any occurred error, nil otherwise
func (c *Command) Stop() error {
c.Started = false
return nil

0 comments on commit 5c5a7c8

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