-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.go
62 lines (51 loc) · 1.39 KB
/
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
56
57
58
59
60
61
62
package main
import (
"bufio"
"fmt"
"os"
"os/signal"
"time"
"github.com/maxsupermanhd/FactoCord-3.0/v3/discord"
"github.com/maxsupermanhd/FactoCord-3.0/v3/support"
)
var closing = false
func main() {
if support.FactoCordVersion == "" {
support.FactoCordVersion = "i'm debugging here"
}
fmt.Printf("Welcome to FactoCord %s!\n", support.FactoCordVersion)
support.Config.MustLoad()
discord.StartSession()
go console()
support.Factorio.Init(discord.ProcessFactorioLogLine)
discord.Init()
sc := make(chan os.Signal, 1)
signal.Notify(sc, os.Interrupt, os.Kill)
<-sc
closing = true
discord.Close()
for support.Factorio.IsStopping() {
time.Sleep(100 * time.Millisecond)
}
if support.Factorio.IsRunning() {
fmt.Println("Waiting for factorio server to exit...")
err := support.Factorio.Process.Wait()
if support.Factorio.Process.ProcessState.Exited() {
fmt.Println("\nFactorio server was closed, exit code", support.Factorio.Process.ProcessState.ExitCode())
} else {
fmt.Println("\nError waiting for factorio to exit")
support.Panik(err, "Error waiting for factorio to exit")
}
}
}
func console() {
Console := bufio.NewReader(os.Stdin)
for !closing {
line, _, err := Console.ReadLine()
if err != nil {
support.Panik(err, "An error occurred when attempting to read the input to pass as input to the console")
return
}
support.Factorio.Send(string(line))
}
}