Update hello examples
This commit is contained in:
parent
8eaf55552a
commit
ef41a36f0f
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue