aboutsummaryrefslogblamecommitdiff
path: root/xmpp/component.go
blob: e484e998f877303b76a64c884fea2576f9d6769d (plain) (tree)





























                                                               
package xmpp

import (
	"log"

	"dev.narayana.im/narayana/telegabber/config"

	"gosrc.io/xmpp"
)

func NewComponent(conf config.XmppConfig) *xmpp.StreamManager {
	options := xmpp.ComponentOptions{
		Address: conf.Host + ":" + conf.Port,
		Domain:  conf.Jid,
		Secret:  conf.Password,
		Name:    "telegabber",
	}

	router := xmpp.NewRouter()
	router.HandleFunc("message", HandleMessage)

	component, err := xmpp.NewComponent(options, router)
	if err != nil {
		log.Fatalf("%+v", err)
	}

	cm := xmpp.NewStreamManager(component, nil)

	return cm
}