Add database models and improve config/main
This commit is contained in:
33
matrix.go
33
matrix.go
@ -1,4 +1,4 @@
|
||||
// mautrix-whatsapp - A Matrix-Whatsapp puppeting bridge.
|
||||
// mautrix-whatsapp - A Matrix-WhatsApp puppeting bridge.
|
||||
// Copyright (C) 2018 Tulir Asokan
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
@ -16,6 +16,35 @@
|
||||
|
||||
package main
|
||||
|
||||
func InitMatrix() {
|
||||
import (
|
||||
log "maunium.net/go/maulogger"
|
||||
)
|
||||
|
||||
type MatrixListener struct {
|
||||
bridge *Bridge
|
||||
log *log.Sublogger
|
||||
stop chan struct{}
|
||||
}
|
||||
|
||||
func NewMatrixListener(bridge *Bridge) *MatrixListener {
|
||||
return &MatrixListener{
|
||||
bridge: bridge,
|
||||
stop: make(chan struct{}, 1),
|
||||
log: bridge.Log.CreateSublogger("Matrix", log.LevelDebug),
|
||||
}
|
||||
}
|
||||
|
||||
func (ml *MatrixListener) Start() {
|
||||
for {
|
||||
select {
|
||||
case evt := <-ml.bridge.AppService.Events:
|
||||
log.Debugln("Received Matrix event:", evt)
|
||||
case <-ml.stop:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (ml *MatrixListener) Stop() {
|
||||
ml.stop <- struct{}{}
|
||||
}
|
||||
|
Reference in New Issue
Block a user