Skip to content

Commit

Permalink
✨ 添加 -n -p 参数
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Jan 10, 2022
1 parent c221401 commit 8ea64e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@
> 如果您不知道什么是 [OneBot](https://github.com/howmanybots/onebot) 或不希望运行多个程序,还可以直接前往 [gocqzbp](https://github.com/FloatTech/gocqzbp)[Release](https://github.com/FloatTech/gocqzbp/releases) 页面下载单一可执行文件或前往 [Packages](https://github.com/FloatTech/gocqzbp/pkgs/container/gocqzbp) 页面使用`docker`,运行后按提示登录即可。
## 命令行参数
> `[]`代表是可选参数
```bash
zerobot -h -t token -u url [-d|w] [-g 监听地址:端口] qq1 qq2 qq3 ...
zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地址:端口] [qq1 qq2 qq3 ...] [&]
```
- **-h**: 显示帮助
- **-t token**: 设置`AccessToken`,默认为空
- **-u url**: 设置`Url`,默认为`ws://127.0.0.1:6700`
- **-n nickname**: 设置默认昵称,默认为`椛椛`
- **-p prefix**: 设置命令前缀,默认为`/`
- **-d|w**: 开启 debug | warning 级别及以上日志输出
- **-g 监听地址:端口**: 在 http://监听地址:端口 上开启 [webgui](https://github.com/FloatTech/bot-manager)
- **qqs**: superusers 的 qq 号
- **&**: 驻留在后台,必须放在最后,仅`Linux`下有效

## 功能
> 在编译时,以下功能除插件控制外,均可通过注释`main.go`中的相应`import`而物理禁用,减小插件体积。
Expand Down
15 changes: 10 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,12 @@ var (
"* Copyright © 2020 - 2021 FloatTech. All Rights Reserved.",
"* Project: https://github.com/FloatTech/ZeroBot-Plugin",
}
nicks = []string{"ATRI", "atri", "亚托莉", "アトリ"}
banner = strings.Join(contents, "\n")
token *string
url *string
adana *string
prefix *string
reg = registry.NewRegReader("reilia.fumiama.top:32664", "fumiama")
)

Expand All @@ -100,6 +103,9 @@ func init() {
token = flag.String("t", "", "Set AccessToken of WSClient.")
// 直接写死 URL 时,请更改下面第二个参数
url = flag.String("u", "ws://127.0.0.1:6700", "Set Url of WSClient.")
// 默认昵称
adana = flag.String("n", "椛椛", "Set default nickname.")
prefix = flag.String("p", "/", "Set command prefix.")

flag.Parse()
if *h {
Expand Down Expand Up @@ -155,12 +161,11 @@ func main() {
})
zero.RunAndBlock(
zero.Config{
NickName: []string{"椛椛", "ATRI", "atri", "亚托莉", "アトリ"},
CommandPrefix: "/",
NickName: append([]string{*adana}, nicks...),
CommandPrefix: *prefix,
// SuperUsers 某些功能需要主人权限,可通过以下两种方式修改
// "12345678", "87654321":通过代码写死的方式添加主人账号
// flag.Args():通过命令行参数的方式添加主人账号,无需修改下方任何代码
SuperUsers: append([]string{"12345678", "87654321"}, flag.Args()...),
// SuperUsers: []string{"12345678", "87654321"}, // 通过代码写死的方式添加主人账号
SuperUsers: flag.Args(), // 通过命令行参数的方式添加主人账号
Driver: []zero.Driver{driver.NewWebSocketClient(*url, *token)},
},
)
Expand Down

0 comments on commit 8ea64e7

Please sign in to comment.