2016-01-02 02:08:28 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/s-rah/go-ricochet"
|
|
|
|
)
|
|
|
|
|
2016-02-29 00:18:25 +00:00
|
|
|
type EchoBotService struct {
|
|
|
|
goricochet.StandardRicochetService
|
|
|
|
}
|
2016-01-02 02:08:28 +00:00
|
|
|
|
2016-02-29 00:18:25 +00:00
|
|
|
func (ebs * EchoBotService) OnAuthenticationResult(channelID int32, serverHostname string, result bool) {
|
|
|
|
if true {
|
|
|
|
ebs.Ricochet().OpenChatChannel(5)
|
|
|
|
ebs.Ricochet().SendMessage(5, "Hi I'm an echo bot, I echo what you say!")
|
|
|
|
}
|
|
|
|
}
|
2016-01-02 02:08:28 +00:00
|
|
|
|
2016-02-29 00:18:25 +00:00
|
|
|
func (ebs * EchoBotService) OnChatMessage(channelID int32, serverHostname string, messageId int32, message string) {
|
|
|
|
ebs.Ricochet().AckChatMessage(channelID, messageId)
|
|
|
|
ebs.Ricochet().SendMessage(5, message)
|
|
|
|
}
|
2016-01-02 02:08:28 +00:00
|
|
|
|
2016-02-29 00:18:25 +00:00
|
|
|
func main() {
|
|
|
|
ricochetService := new(EchoBotService)
|
|
|
|
ricochetService.Init("./private_key", "kwke2hntvyfqm7dr")
|
|
|
|
err := ricochetService.Ricochet().Connect("kwke2hntvyfqm7dr", "127.0.0.1:55555|jlq67qzo6s4yp3sp")
|
|
|
|
if err == nil {
|
|
|
|
ricochetService.OnConnect("jlq67qzo6s4yp3sp")
|
|
|
|
ricochetService.Ricochet().ListenAndWait("jlq67qzo6s4yp3sp", ricochetService)
|
2016-01-02 02:08:28 +00:00
|
|
|
}
|
|
|
|
}
|