|
2 years ago | |
---|---|---|
Godeps | 3 years ago | |
application | 2 years ago | |
channels | 2 years ago | |
connection | 2 years ago | |
examples/echobot | 2 years ago | |
identity | 2 years ago | |
policies | 2 years ago | |
testing | 2 years ago | |
utils | 2 years ago | |
wire | 2 years ago | |
.gitignore | 4 years ago | |
.travis.yml | 2 years ago | |
CONTRIBUTING.md | 2 years ago | |
LICENSE | 3 years ago | |
README.md | 2 years ago | |
inbound_version_negotiation_test.go | 2 years ago | |
outbound_version_negotiation_test.go | 2 years ago | |
private_key | 4 years ago | |
ricochet.go | 2 years ago | |
ricochet_test.go | 3 years ago | |
testing.md | 3 years ago |
libricochet-go is an experimental implementation of the Ricochet Protocol in Go.
Below is a simple echo bot, which responds to any chat message. You can also find this code under examples/echobot
package main
import (
"git.openprivacy.ca/openprivacy/libricochet-go/application"
"git.openprivacy.ca/openprivacy/libricochet-go/utils"
"log"
"time"
)
func main() {
echobot := new(application.RicochetApplication)
pk, err := utils.LoadPrivateKeyFromFile("./private_key")
if err != nil {
log.Fatalf("error reading private key file: %v", err)
}
l, err := application.SetupOnion("127.0.0.1:9051", "tcp4", "", pk, 9878)
if err != nil {
log.Fatalf("error setting up onion service: %v", err)
}
echobot.Init(pk, new(application.AcceptAllContactManager))
echobot.OnChatMessage(func(rai *application.RicochetApplicationInstance, id uint32, timestamp time.Time, message string) {
log.Printf("message from %v - %v", rai.RemoteHostname, message)
rai.SendChatMessage(message)
})
log.Printf("echobot listening on %s", l.Addr().String())
echobot.Run(l)
}
Each automated ricochet service can extend of the StandardRicochetService
. From there
certain functions can be extended to fully build out a complete application.
This project is experimental and has not been independently reviewed. If you are looking for a quick and easy way to use ricochet please check out Ricochet IM.