oklahomer / go-sarah-xmpp

go-sarah adapter for xmpp integration

Home Page:https://godoc.org/github.com/oklahomer/go-sarah-xmpp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This is a sarah Adapter implementation for XMPP / Jabber

At present this is work in progress, and API may change without notice.

Getting Started

Below is a minimal sample that describes how to setup and start XMPP Adapter.

package main

import (
        "github.com/oklahomer/go-sarah"
        "github.com/oklahomer/go-sarah-xmpp"
        "golang.org/x/net/context"
        "gopkg.in/yaml.v2"
        "io/ioutil"
)

func main() {
        // Setup configuration
        configBuf, _ := ioutil.ReadFile("/path/to/adapter/config.yaml")
        xmppConfig := xmpp.NewConfig()
        yaml.Unmarshal(configBuf, xmppConfig)

        // Setup bot
        xmppAdapter, _ := xmpp.NewAdapter(xmppConfig)
        storage := sarah.NewUserContextStorage(sarah.NewCacheConfig())
        xmppBot, _ := sarah.NewBot(xmppAdapter, sarah.BotWithStorage(storage))
	
        // Start
        rootCtx := context.Background()
        runnerCtx, _ := context.WithCancel(rootCtx)
        runner, _ := sarah.NewRunner(sarah.NewConfig(), sarah.WithBot(xmppBot))
        runner.Run(runnerCtx)
}

Acknowledgements and thanks

This library uses the excellent xmpp library - https://github.com/mattn/go-xmpp

About

go-sarah adapter for xmpp integration

https://godoc.org/github.com/oklahomer/go-sarah-xmpp


Languages

Language:Go 100.0%