forked from uditkarode/Minegram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
63 lines (54 loc) · 1.27 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
63
package main
import (
"io"
"os/exec"
"reflect"
"runtime"
"sync"
"minegram/modules"
"minegram/utils"
"github.com/fatih/color"
tb "gopkg.in/tucnak/telebot.v2"
"gorm.io/gorm"
)
/* configuration options */
var (
cmd string
tok string
admUsers []string
authEnabled = true
)
/* shared vars */
var (
online = []utils.OnlinePlayer{}
cliOutput = make(chan string)
needResult = false
db *gorm.DB
b *tb.Bot
execCmd *exec.Cmd
stdin io.WriteCloser
stdout io.ReadCloser
targetChat tb.Recipient
wg sync.WaitGroup
)
/* shared error */
var err error
func plugModule(module utils.ModuleFunction) {
color.Blue("LOADING MODULE: " + runtime.FuncForPC(reflect.ValueOf(module).Pointer()).Name())
module(utils.ModuleData{
CmdToRun: &cmd, TgBotToken: &tok, AdminUsers: &admUsers,
IsAuthEnabled: &authEnabled, OnlinePlayers: &online,
ConsoleOut: &cliOutput, NeedResult: &needResult,
GormDb: &db, TeleBot: &b, ExecCmd: &execCmd, Stdin: &stdin,
Stdout: &stdout, TargetChat: &targetChat, Waitgroup: &wg,
})
}
func main() {
plugModule(modules.Core)
plugModule(modules.Parser)
plugModule(modules.TgUtilCommands)
plugModule(modules.TgToMc)
plugModule(modules.Auth)
plugModule(modules.Logger)
plugModule(modules.Init)
}