Update hello examples

This commit is contained in:
Adrian Zankich 2014-05-22 20:18:45 -07:00
parent 8eaf55552a
commit ef41a36f0f
3 changed files with 23 additions and 15 deletions

View File

@ -3,14 +3,21 @@ package main
import (
"fmt"
"github.com/hybridgroup/gobot"
"time"
)
func main() {
robot := gobot.Robot{
Work: func() {
gobot.Every("0.5s", func() { fmt.Println("Greetings human") })
},
}
gbot := gobot.NewGobot()
robot.Start()
robot := gobot.NewRobot(
"hello",
nil,
nil,
func() {
gobot.Every(0.5*time.Second, func() { fmt.Println("Greetings human") })
},
)
gbot.Robots = append(gbot.Robots, robot)
gbot.Start()
}

View File

@ -3,6 +3,7 @@ package main
import (
"fmt"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/api"
)
func Hello(params map[string]interface{}) string {
@ -12,11 +13,9 @@ func Hello(params map[string]interface{}) string {
func main() {
master := gobot.GobotMaster()
api := gobot.Api(master)
api.Port = "4000"
api.NewApi(master).Start()
hello := new(gobot.Robot)
hello.Name = "hello"
hello := gobot.NewRobot("hello", nil, nil, nil)
hello.Commands = map[string]interface{}{"Hello": Hello}
master.Robots = append(master.Robots, hello)

View File

@ -3,6 +3,7 @@ package main
import (
"fmt"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/api"
)
func Hello(params map[string]interface{}) string {
@ -12,12 +13,13 @@ func Hello(params map[string]interface{}) string {
func main() {
master := gobot.GobotMaster()
api := gobot.Api(master)
api.Username = "gort"
api.Password = "klatuu"
hello := new(gobot.Robot)
hello.Name = "hello"
server := api.NewApi(master)
server.Username = "gort"
server.Password = "klatuu"
server.Start()
hello := gobot.NewRobot("hello", nil, nil, nil)
hello.Commands = map[string]interface{}{"Hello": Hello}
master.Robots = append(master.Robots, hello)