hybridgroup.gobot/examples/hello_api.go

24 lines
539 B
Go
Raw Normal View History

2013-11-28 12:05:45 +08:00
package main
import (
"fmt"
"github.com/hybridgroup/gobot"
2014-05-23 11:18:45 +08:00
"github.com/hybridgroup/gobot/api"
2013-11-28 12:05:45 +08:00
)
func main() {
2014-06-13 11:58:54 +08:00
gbot := gobot.NewGobot()
api.NewAPI(gbot).Start()
2013-11-28 12:05:45 +08:00
2014-06-13 11:58:54 +08:00
gbot.AddCommand("CustomGobotCommand", func(params map[string]interface{}) interface{} {
return "This command is attached to the master!"
})
2014-06-12 07:44:23 +08:00
2014-06-13 12:33:25 +08:00
hello := gbot.AddRobot(gobot.NewRobot("hello"))
2014-06-12 07:44:23 +08:00
hello.AddCommand("HiThere", func(params map[string]interface{}) interface{} {
2014-06-13 11:58:54 +08:00
return fmt.Sprintf("This command is attached to the robot %v", hello.Name)
2014-06-12 07:44:23 +08:00
})
2013-11-28 12:05:45 +08:00
2014-06-13 11:58:54 +08:00
gbot.Start()
2013-11-28 12:05:45 +08:00
}