Skip to content

Commit

Permalink
feat: make coin name configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
EatHatsuneShallots committed Aug 7, 2024
1 parent eeef7a6 commit 48c6f3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@
## 命令行参数
> `[]`代表是可选参数
```bash
zerobot [-h] [-m] [-n nickname] [-t token] [-u url] [-g url] [-p prefix] [-d|w] [-c|s config.json] [-l latency] [-r ringlen] [-x max process time] [-mirror] [qq1 qq2 qq3 ...] [&]
zerobot [-h] [-m] [-n nickname] [-o coinname] [-t token] [-u url] [-g url] [-p prefix] [-d|w] [-c|s config.json] [-l latency] [-r ringlen] [-x max process time] [-mirror] [qq1 qq2 qq3 ...] [&]
```
- **-h**: 显示帮助
- **-m**: 不自动标记消息为已读
- **-n nickname**: 设置默认昵称,默认为`椛椛`
- **-o coinname**: 设置默认硬币名称,默认为`ATRI币`
- **-t token**: 设置`AccessToken`,默认为空
- **-u url**: 设置`Url`,默认为`ws://127.0.0.1:6700`
- ~~**-g url**~~(默认禁用): 设置`webui url`,默认为`127.0.0.1:3000`
Expand All @@ -70,6 +71,7 @@ zerobot [-h] [-m] [-n nickname] [-t token] [-u url] [-g url] [-p prefix] [-d|w]
- **&**: 驻留在后台,必须放在最后,仅`Linux`下有效

默认配置文件格式如下。当选择从配置文件加载时,将忽略相应命令行参数。
<!-- TODO 添加有关自定义硬币名称的配置 -->
```json
{
"zero": {
Expand Down
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ import (
// //
// //
// -----------------------以下为内置依赖,勿动------------------------ //
"github.com/FloatTech/AnimeAPI/wallet"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/process"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -220,6 +221,9 @@ func init() {
url := flag.String("u", "ws://127.0.0.1:6700", "Set Url of WSClient.")
// 默认昵称
adana := flag.String("n", "椛椛", "Set default nickname.")
// 默认 ATRI 币名称
// TODO 将其添加到 ZeroBot 配置文件中
atri := flag.String("o", "ATRI币", "Set default coin name.")
prefix := flag.String("p", "/", "Set command prefix.")
runcfg := flag.String("c", "", "Run from config file.")
save := flag.String("s", "", "Save default config to file and exit.")
Expand Down Expand Up @@ -251,6 +255,11 @@ func init() {
sus = append(sus, i)
}

// 更改 ATRI 币名称
// TODO 改为在 main 函数调用
// wallet.SetWalletName(config.CoinName)
wallet.SetWalletName(*atri)

// 通过代码写死的方式添加主人账号
// sus = append(sus, 12345678)
// sus = append(sus, 87654321)
Expand Down

0 comments on commit 48c6f3a

Please sign in to comment.