Ocean/ICCC/Registrar.go

22 lines
704 B
Go
Raw Normal View History

package ICCC
import (
"fmt"
"github.com/SommerEngineering/Ocean/Log"
LM "github.com/SommerEngineering/Ocean/Log/Meta"
)
2015-06-17 15:44:52 +00:00
// Register a command to ICCC for a specific channel.
func Registrar(channel, command string, callback func(data map[string][]string)) {
listenersLock.Lock()
defer listenersLock.Unlock()
2015-06-17 15:44:52 +00:00
// Write the command to the database:
register2Database(channel, command)
2015-06-17 15:44:52 +00:00
// Register the command at the local cache:
listeners[fmt.Sprintf(`%s::%s`, channel, command)] = callback
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameCONFIGURATION, `The registrar has registered a new ICCC command.`, `channel=`+channel, `command=`+command)
}