✏️ 修正命令行参数

This commit is contained in:
fumiama 2021-09-27 22:06:46 +08:00
parent 1d469a40d5
commit ec15178ba7
3 changed files with 13 additions and 8 deletions

2
go.mod
View File

@ -4,7 +4,7 @@ go 1.16
require (
github.com/FloatTech/AnimeAPI v1.1.9
github.com/FloatTech/ZeroBot-Plugin-Gif v0.2.0
github.com/FloatTech/ZeroBot-Plugin-Gif v0.2.1
github.com/FloatTech/ZeroBot-Plugin-Timer v1.4.3
github.com/FloatTech/bot-manager v1.0.0
github.com/gin-gonic/gin v1.7.4

4
go.sum
View File

@ -1,8 +1,8 @@
github.com/FloatTech/AnimeAPI v1.1.9 h1:H1hZmgwZPNHdx39K9JvY3awT8TTsCl9kKA1uVMyCjRg=
github.com/FloatTech/AnimeAPI v1.1.9/go.mod h1:CC+vF30UGBlcIUxwFOcXIEHoJ4r7c5x2iLQsnUCVdDI=
github.com/FloatTech/ZeroBot-Plugin v1.1.5/go.mod h1:kWuUARvU7gs4xLggi8Sy37ja2GRL6k0X6kewe5TiZRs=
github.com/FloatTech/ZeroBot-Plugin-Gif v0.2.0 h1:lovS03Nc4mxvOFPSofvUfYNe5qWAto6fotnYqRHM03s=
github.com/FloatTech/ZeroBot-Plugin-Gif v0.2.0/go.mod h1:W7ag6hml1pZTNzRXKU74OMr6rS8awQKSU+o2g7Gj4O0=
github.com/FloatTech/ZeroBot-Plugin-Gif v0.2.1 h1:f2Ja8ImigABCnqwiC0KVbYGK9lUX0rU2ZoIz/Cy/38c=
github.com/FloatTech/ZeroBot-Plugin-Gif v0.2.1/go.mod h1:W7ag6hml1pZTNzRXKU74OMr6rS8awQKSU+o2g7Gj4O0=
github.com/FloatTech/ZeroBot-Plugin-Timer v1.4.3 h1:jn/dH+OwPSRozkmeCeQQPrAGJRBudcm3OK5tXhGItRk=
github.com/FloatTech/ZeroBot-Plugin-Timer v1.4.3/go.mod h1:MVOQQ4e6AVGFm993blXXU4Sd6bAsLY2+Zb+/HMrEeEc=
github.com/FloatTech/bot-manager v1.0.0 h1:d63J5htLhVBc2ITG09WBJI+qAB0ubPjYhfXl6hljBNk=

15
main.go
View File

@ -3,7 +3,6 @@ package main
import (
"flag"
"fmt"
"os"
"strings"
// 注:以下插件均可通过前面加 // 注释,注释后停用并不加载插件
@ -12,6 +11,7 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_atri" // ATRI词库
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_chat" // 基础词库
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_qingyunke" // 青云客
"github.com/sirupsen/logrus"
// 实用类
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_github" // 搜索GitHub仓库
@ -62,13 +62,18 @@ var (
func init() {
var en bool
var debg bool
// 解析命令行参数,输入 `-g` 即可启用 gui
flag.BoolVar(&en, "g", false, "Enable the gui")
flag.BoolVar(&en, "g", false, "Enable web gui.")
// 解析命令行参数,输入 `-d` 即可开启 debug log
flag.BoolVar(&debg, "d", false, "Enable debug log.")
flag.Parse()
if en {
control.InitGui()
}
// log.SetLevel(log.DebugLevel)
if debg {
logrus.SetLevel(logrus.DebugLevel)
}
}
func main() {
@ -83,8 +88,8 @@ func main() {
// SuperUsers 某些功能需要主人权限,可通过以下两种方式修改
// []string{}:通过代码写死的方式添加主人账号
// os.Args[1:]:通过命令行参数的方式添加主人账号
SuperUsers: append([]string{"12345678", "87654321"}, os.Args[1:]...),
// flag.Args():通过命令行参数的方式添加主人账号
SuperUsers: append([]string{"12345678", "87654321"}, flag.Args()...),
Driver: []zero.Driver{
&driver.WSClient{