-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (36 loc) · 878 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
package main
import (
"flag"
"fmt"
"os"
)
// main starts the bot. The only required flag is the -config flag which
// should point to the configuration file that you want to use.
func main() {
configPath := flag.String("config", "", "config file path")
version := flag.Bool("version", false, "display current version")
schemaOnly := flag.Bool("init-schema-only", false, "init db schema and exit")
flag.Parse()
if *version {
fmt.Fprintf(os.Stdout, "%s\n", VERSION)
os.Exit(0)
}
if *configPath == "" {
fmt.Fprintf(os.Stderr, "-config is required\n")
os.Exit(1)
}
var bot *bot
var err error
if bot, err = newBotFromConfig(*configPath); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
if *schemaOnly == true {
bot.initDB()
os.Exit(0)
}
if err = bot.start(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}