-
Notifications
You must be signed in to change notification settings - Fork 2
/
outputs.go
54 lines (43 loc) · 1.04 KB
/
outputs.go
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
package core
import (
"log"
"os"
"github.com/hexbotio/hex/models"
"github.com/hexbotio/hex/outputs"
)
func Outputs(outputMsgs <-chan models.Message, plugins *map[string]models.Plugin, config models.Config) {
var command = new(outputs.Command)
var cli = new(outputs.Cli)
var slack = new(outputs.Slack)
var auditing = new(outputs.Auditing)
for {
message := <-outputMsgs
if config.Command != "" {
command.Write(message, config)
StopPlugins(*plugins, config)
for _, output := range message.Outputs {
if !output.Success {
os.Exit(1)
}
}
os.Exit(0)
}
if config.CLI {
cli.Write(message, config)
}
if config.Slack {
slack.Write(message, config)
}
if config.Auditing {
if !FileExists(config.AuditingFile) {
nf, err := os.Create(config.AuditingFile)
if err != nil {
log.Fatal("ERROR: Cannot create Auditing File at "+config.AuditingFile, err)
}
nf.Close()
config.Logger.Info("Created Auditing File " + config.AuditingFile)
}
auditing.Write(message, config)
}
}
}