You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
725 B
Go

package bridge
import (
"time"
"github.com/hugot/go-deltachat/deltabot"
"github.com/hugot/whapp-deltachat/botcommands"
"github.com/hugot/whapp-deltachat/whappdc"
core "github.com/hugot/whapp-deltachat/whappdc-core"
)
type Bridge struct {
Ctx *core.BridgeContext
}
func (b *Bridge) Init(config *core.Config) error {
messageWorker := whappdc.NewMessageWorker()
ctx := core.NewBridgeContext(config, 15*time.Minute)
err := ctx.Init(
whappdc.NewWhappHandler(ctx, messageWorker),
[]deltabot.Command{
&botcommands.Echo{},
botcommands.NewWhappBridge(ctx),
},
)
if err != nil {
return err
}
messageWorker.Start()
b.Ctx = ctx
return nil
}
func (b *Bridge) Close() error {
return b.Ctx.Close()
}