增加-u参数

This commit is contained in:
fumiama 2021-10-11 13:32:23 +08:00
parent 2fb445746e
commit 4677d789f2
2 changed files with 13 additions and 5 deletions

View File

@ -20,9 +20,11 @@
## 命令行参数
```bash
zerobot -h [-d|w] [-g] qq1 qq2 qq3 ...
zerobot -h -t token -u url [-d|w] [-g] qq1 qq2 qq3 ...
```
- **-h**: 显示帮助
- **-h**: 显示帮助
- **-t token**: 设置`AccessToken`
- **-u url**: 设置`Url`
- **-d|w**: 开启 debug | warning 级别及以上日志输出
- **-g**: 开启 [webgui](https://github.com/FloatTech/bot-manager)
- **qqs**: superusers 的 qq 号

12
main.go
View File

@ -61,13 +61,19 @@ var (
"* Project: https://github.com/FloatTech/ZeroBot-Plugin",
}
banner = strings.Join(contents, "\n")
token *string
url *string
)
func init() {
// 解析命令行参数,输入 `-d` 即可开启 debug log
// 解析命令行参数
d := flag.Bool("d", false, "Enable debug level log and higher.")
w := flag.Bool("w", false, "Enable warning level log and higher.")
h := flag.Bool("h", false, "Display this help.")
// 直接写死 AccessToken 时,请更改下面第二个参数
token = flag.String("t", "", "Set AccessToken of WSClient.")
// 直接写死 URL 时,请更改下面第二个参数
url = flag.String("u", "ws://127.0.0.1:6700", "Set Url of WSClient.")
flag.Parse()
if *h {
printBanner()
@ -106,8 +112,8 @@ func main() {
Driver: []zero.Driver{
&driver.WSClient{
// OneBot 正向WS 默认使用 6700 端口
Url: "ws://127.0.0.1:6700",
AccessToken: "",
Url: *url,
AccessToken: *token,
},
},
})