diff options
-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.go | 17 | ||||
-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" @@ -1,4 +1,4 @@ -package appservice +package main import ( "fmt" @@ -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 = ®_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" |