-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.go
55 lines (47 loc) · 1.21 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
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
var tok string
var admUsers []string
var authEnabled = utils.AuthTypeEnabled
/* shared vars */
var online = []utils.OnlinePlayer{}
var cliOutput = make(chan string)
var needResult = false
var db *gorm.DB
var b *tb.Bot
var execCmd *exec.Cmd
var stdin io.WriteCloser
var stdout io.ReadCloser
var targetChat tb.Recipient
var wg sync.WaitGroup
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,
AuthType: &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)
}