aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-02-26 16:07:33 +0100
committerAlex Auvolat <alex@adnab.me>2020-02-26 16:07:33 +0100
commit67c7f7361d63a282788f159494a6f43172c8806a (patch)
treefe80e56bf8cba13ff4ffbd126dc0d6fec146d657
parenta8e87e378ea0a232cb06ef65d77fd39009270676 (diff)
downloadeasybridge-67c7f7361d63a282788f159494a6f43172c8806a.tar.gz
easybridge-67c7f7361d63a282788f159494a6f43172c8806a.zip
Move appservice/ to /
-rw-r--r--account.go (renamed from appservice/account.go)2
-rw-r--r--db.go (renamed from appservice/db.go)2
-rw-r--r--main.go17
-rw-r--r--server.go (renamed from appservice/server.go)12
-rw-r--r--util.go (renamed from appservice/util.go)2
5 files changed, 10 insertions, 25 deletions
diff --git a/appservice/account.go b/account.go
index 4bb2dfe..8da6d44 100644
--- a/appservice/account.go
+++ b/account.go
@@ -1,4 +1,4 @@
-package appservice
+package main
import (
"fmt"
diff --git a/appservice/db.go b/db.go
index 34fc046..fe3d1e3 100644
--- a/appservice/db.go
+++ b/db.go
@@ -1,4 +1,4 @@
-package appservice
+package main
import (
"fmt"
diff --git a/main.go b/main.go
index 0864b66..d74e3d8 100644
--- a/main.go
+++ b/main.go
@@ -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 {
diff --git a/appservice/server.go b/server.go
index 669559d..10721be 100644
--- a/appservice/server.go
+++ b/server.go
@@ -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 {
diff --git a/appservice/util.go b/util.go
index 160f492..c811a1e 100644
--- a/appservice/util.go
+++ b/util.go
@@ -1,4 +1,4 @@
-package appservice
+package main
import (
"fmt"