hybridgroup.gobot/examples/hello_api_auth.go

29 lines
542 B
Go
Raw Normal View History

2014-04-19 06:45:42 +08:00
package main
import (
"fmt"
"github.com/hybridgroup/gobot"
2014-05-23 11:18:45 +08:00
"github.com/hybridgroup/gobot/api"
2014-04-19 06:45:42 +08:00
)
func Hello(params map[string]interface{}) string {
name := params["name"].(string)
return fmt.Sprintf("hi %v", name)
}
func main() {
master := gobot.GobotMaster()
2014-05-23 11:18:45 +08:00
server := api.NewApi(master)
server.Username = "gort"
server.Password = "klatuu"
server.Start()
hello := gobot.NewRobot("hello", nil, nil, nil)
2014-04-19 06:45:42 +08:00
hello.Commands = map[string]interface{}{"Hello": Hello}
master.Robots = append(master.Robots, hello)
master.Start()
}