2016-01-02 02:08:28 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/s-rah/go-ricochet"
|
2016-02-28 00:20:40 +00:00
|
|
|
"time"
|
2016-01-02 02:08:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
ricochet := new(goricochet.Ricochet)
|
|
|
|
|
|
|
|
// You will want to replace these values with your own test credentials
|
|
|
|
ricochet.Init("./private_key", true)
|
|
|
|
ricochet.Connect("kwke2hntvyfqm7dr", "127.0.0.1:55555|jlq67qzo6s4yp3sp")
|
|
|
|
|
2016-01-02 08:47:32 +00:00
|
|
|
// Not needed past the initial run
|
2016-01-02 02:08:28 +00:00
|
|
|
// TODO need to wait for contact response before sending OpenChannel
|
|
|
|
// ricochet.SendContactRequest("EchoBot", "I'm an EchoBot")
|
|
|
|
|
|
|
|
go ricochet.ListenAndWait()
|
2016-02-28 00:20:40 +00:00
|
|
|
ricochet.OpenChatChannel(5)
|
|
|
|
time.Sleep(time.Second * 1)
|
2016-02-28 02:52:20 +00:00
|
|
|
ricochet.SendMessage(5, "Hi I'm an echo bot, I echo what you say!")
|
2016-01-02 02:08:28 +00:00
|
|
|
|
|
|
|
for true {
|
|
|
|
message,channel,_ := ricochet.Listen()
|
2016-02-28 02:52:20 +00:00
|
|
|
fmt.Print(channel, message)
|
2016-01-02 02:08:28 +00:00
|
|
|
if message != "" {
|
2016-02-28 02:52:20 +00:00
|
|
|
ricochet.SendMessage(5, message)
|
2016-01-02 02:08:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|