summaryrefslogtreecommitdiffstats
path: root/bridge/config/config.go
blob: ad8a523ed7a70758de025b482de06449eb0aa942 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package config

import (
	"github.com/BurntSushi/toml"
	"log"
)

type Message struct {
	Text       string
	Channel    string
	Username   string
	Origin     string
	FullOrigin string
	Protocol   string
}

type Protocol struct {
	BindAddress            string // mattermost, slack
	IconURL                string // mattermost, slack
	IgnoreNicks            string // all protocols
	Jid                    string // xmpp
	Login                  string // mattermost
	Muc                    string // xmpp
	Name                   string // all protocols
	Nick                   string // all protocols
	NickFormatter          string // mattermost, slack
	NickServNick           string // IRC
	NickServPassword       string // IRC
	NicksPerRow            int    // mattermost, slack
	NoTLS                  bool   // mattermost
	Password               string // IRC,mattermost,XMPP
	PrefixMessagesWithNick bool   // mattemost, slack
	Protocol               string //all protocols
	RemoteNickFormat       string // all protocols
	Server                 string // IRC,mattermost,XMPP
	ShowJoinPart           bool   // all protocols
	SkipTLSVerify          bool   // IRC, mattermost
	Team                   string // mattermost
	Token                  string // gitter, slack
	URL                    string // mattermost, slack
	UseAPI                 bool   // mattermost, slack
	UseSASL                bool   // IRC
	UseTLS                 bool   // IRC
}

type Bridge struct {
	Account string
	Channel string
}

type Gateway struct {
	Name   string
	Enable bool
	In     []Bridge
	Out    []Bridge
}

type Config struct {
	IRC        map[string]Protocol
	Mattermost map[string]Protocol
	Slack      map[string]Protocol
	Gitter     map[string]Protocol
	Xmpp       map[string]Protocol
	Gateway    []Gateway
}

func NewConfig(cfgfile string) *Config {
	var cfg Config
	if _, err := toml.DecodeFile("matterbridge.toml", &cfg); err != nil {
		log.Fatal(err)
	}
	return &cfg
}