-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
55 lines (41 loc) · 947 Bytes
/
main.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
55
/*
Command Tetra is an extended services package for TS6 IRC daemons with Lua and
Moonscript support.
*/
package main
import (
"flag"
"fmt"
"log"
"os"
"os/exec"
"github.com/Xe/Tetra/bot"
)
var (
config = flag.String("config", "etc/config.yaml", "configuration file for Tetra to use (or TETRA_CONFIG_PATH)")
)
func main() {
flag.Parse()
confloc := *config
if envvar := os.Getenv("TETRA_CONFIG_PATH"); envvar != "" {
confloc = envvar
}
if _, err := os.Open(confloc); err != nil {
fmt.Fprintln(os.Stderr, "Please add your config at "+*config)
os.Exit(1)
}
fmt.Printf("Using config file %s\n", confloc)
cmd := exec.Command("moonc", ".")
cmd.Dir = "./lib"
err := cmd.Run()
if err != nil {
log.Fatal(err)
}
tetra.NewTetra(confloc)
tetra.Connect(tetra.ActiveConfig.Uplink.Host, tetra.ActiveConfig.Uplink.Port)
defer tetra.Conn.Conn.Close()
tetra.Auth()
tetra.StickConfig()
go tetra.WebApp()
tetra.Main()
}