Capabilities command and documentation update.
This commit is contained in:
44
commands/capabilities/exported.go
Normal file
44
commands/capabilities/exported.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package capabilities
|
||||
|
||||
import (
|
||||
// stdlib
|
||||
"log"
|
||||
|
||||
// local
|
||||
"develop.pztrn.name/gonews/gonews/eventer"
|
||||
"develop.pztrn.name/gonews/gonews/networker"
|
||||
)
|
||||
|
||||
var capabilities = []string{
|
||||
"VERSION 2",
|
||||
}
|
||||
|
||||
func Initialize() {
|
||||
log.Println("Initializing capabilities command...")
|
||||
|
||||
eventer.AddEventHandler(&eventer.EventHandler{
|
||||
Command: "internal/capability_add",
|
||||
Handler: addCapability,
|
||||
})
|
||||
|
||||
eventer.AddEventHandler(&eventer.EventHandler{
|
||||
Command: "commands/capabilities",
|
||||
Handler: handler,
|
||||
})
|
||||
}
|
||||
|
||||
func addCapability(data interface{}) interface{} {
|
||||
capabilities = append(capabilities, data.(string))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func handler(data interface{}) interface{} {
|
||||
dataToReturn := "Capability list:\r\n"
|
||||
|
||||
for _, cap := range capabilities {
|
||||
dataToReturn += cap + "\r\n"
|
||||
}
|
||||
dataToReturn += ".\r\n"
|
||||
return &networker.Reply{Code: "101", Data: dataToReturn}
|
||||
}
|
Reference in New Issue
Block a user