Skip to content

Commit e259716

Browse files
committed
feat: update bot response label
1 parent ca479c7 commit e259716

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ deps: ## Install Go dependencies
1919
go mod download
2020
go mod tidy
2121

22-
build: ## Build the ash single-file binary
23-
CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go build -o ash ./ash.go
22+
build: ## Build the ash binary (builds package)
23+
CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go build -o ash .
2424

2525
run: build ## Build and run the ash single-file binary
2626
./ash
@@ -39,4 +39,5 @@ docker-build: ## Build using Docker for cross-compilation to Ubuntu
3939

4040
ci: docker-build
4141
rsync -avzP ash-linux-amd64 'ark:ash/ash-linux-amd64'
42+
rsync -avzP *.json 'ark:ash'
4243
ssh ark sudo systemctl restart ash.service

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ You can configure HTTP-backed bot commands in `bot.json`. Example commands inclu
1010
- `/bot quote` — uses quotable.io (returns the `content` field)
1111
- `/bot catfact` — uses catfact.ninja (returns the `fact` field)
1212

13-
Add or change commands in `bot.json` and set `BOT_CONFIG_PATH` in `config.json` if you place it elsewhere. The bot will prefix responses using the `label` field (defaults to `[BOT] `).
13+
Add or change commands in `bot.json` and set `BOT_CONFIG_PATH` in `config.json` if you place it elsewhere. The bot will prefix responses using `BOT_REPLY_LABEL` in `config.json` (defaults to `> `).
1414

1515
pairs nicely with [lava](https://polarhive.net/lava)
1616

ash.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ type Config struct {
9191
MetaDBPath string `json:"META_DB_PATH"`
9292
LinksPath string `json:"LINKS_JSON_PATH"`
9393
BotConfigPath string `json:"BOT_CONFIG_PATH"`
94+
BotReplyLabel string `json:"BOT_REPLY_LABEL,omitempty"`
9495
SyncTimeoutMS int `json:"SYNC_TIMEOUT_MS"`
9596
Debug bool `json:"DEBUG"`
9697
DeviceName string `json:"MATRIX_DEVICE_NAME"`
@@ -722,8 +723,11 @@ func run(ctx context.Context, metaDB *sql.DB, messagesDB *sql.DB, cfg *Config) e
722723
}
723724
}
724725
}
725-
label := "[BOT] "
726-
if botCfg != nil && botCfg.Label != "" {
726+
label := "> "
727+
// Precedence: config.BOT_REPLY_LABEL -> bot.json label -> default
728+
if cfg != nil && cfg.BotReplyLabel != "" {
729+
label = cfg.BotReplyLabel
730+
} else if botCfg != nil && botCfg.Label != "" {
727731
label = botCfg.Label
728732
}
729733
body = label + body

bot.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"label": "[BOT] ",
32
"commands": {
43
"joke": {
54
"method": "GET",

0 commit comments

Comments
 (0)