Destinygg chat go bindings. You can acquire a login key here.
package main
import (
"log"
"os"
"os/signal"
"syscall"
"github.com/MemeLabs/dggchat"
)
func main() {
// Create a new client
dgg, err := dggchat.New("loginkey")
if err != nil {
log.Fatalln(err)
}
// Open a connection
err = dgg.Open()
if err != nil {
log.Fatalln(err)
}
// Cleanly close the connection
defer dgg.Close()
dgg.AddMessageHandler(onMessage)
dgg.AddErrorHandler(onError)
// Wait for ctr-C to shut down
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT)
<-sc
}
func onMessage(m dggchat.Message, s *dggchat.Session) {
log.Printf("New message from %s: %s\n", m.Sender.Nick, m.Message)
if m.Message == "!test" {
s.SendPrivateMessage(m.Sender.Nick, "testing")
}
}
func onError(e string, s *dggchat.Session) {
log.Printf("error %s\n", e)
}
For a more complex example, see FerretBot