Move appservice/ to /

This commit is contained in:
Alex 2020-02-26 16:07:33 +01:00
parent a8e87e378e
commit 67c7f7361d
5 changed files with 10 additions and 25 deletions

View file

@ -1,4 +1,4 @@
package appservice
package main
import (
"fmt"

View file

@ -1,4 +1,4 @@
package appservice
package main
import (
"fmt"

17
main.go
View file

@ -15,7 +15,6 @@ import (
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
"git.deuxfleurs.fr/Deuxfleurs/easybridge/appservice"
"git.deuxfleurs.fr/Deuxfleurs/easybridge/connector"
"git.deuxfleurs.fr/Deuxfleurs/easybridge/connector/irc"
"git.deuxfleurs.fr/Deuxfleurs/easybridge/connector/mattermost"
@ -166,15 +165,7 @@ func main() {
reg_file := readRegistration(config.Registration)
registration = &reg_file
as_config := &appservice.Config{
HttpBindAddr: config.HttpBindAddr,
Server: config.Server,
DbType: config.DbType,
DbPath: config.DbPath,
MatrixDomain: config.MatrixDomain,
}
errch, err := appservice.Start(registration, as_config)
errch, err := StartAppService()
if err != nil {
log.Fatal(err)
}
@ -192,7 +183,7 @@ func main() {
default:
log.Fatalf("Invalid protocol %s", params.Protocol)
}
account := &appservice.Account{
account := &Account{
MatrixUser: fmt.Sprintf("@%s:%s", user, config.MatrixDomain),
AccountName: name,
Protocol: params.Protocol,
@ -200,7 +191,7 @@ func main() {
JoinedRooms: map[connector.RoomID]bool{},
}
conn.SetHandler(account)
appservice.AddAccount(account)
AddAccount(account)
go connectAndJoin(account, params)
}
}
@ -211,7 +202,7 @@ func main() {
}
}
func connectAndJoin(account *appservice.Account, params ConfigAccount) {
func connectAndJoin(account *Account, params ConfigAccount) {
log.Printf("Connecting to %s", params.Protocol)
err := account.Conn.Configure(params.Config)
if err != nil {

View file

@ -1,4 +1,4 @@
package appservice
package main
import (
"encoding/json"
@ -21,16 +21,10 @@ type Config struct {
MatrixDomain string
}
var registration *mxlib.Registration
var config *Config
var mx *mxlib.Client
func Start(r *mxlib.Registration, c *Config) (chan error, error) {
registration = r
config = c
mx = mxlib.NewClient(c.Server, r.AsToken)
func StartAppService() (chan error, error) {
mx = mxlib.NewClient(config.Server, registration.AsToken)
err := InitDb()
if err != nil {

View file

@ -1,4 +1,4 @@
package appservice
package main
import (
"fmt"