Fix /badword add/rem truncating multi-word phrases
This commit is contained in:
parent
cf6e27539b
commit
ddd5eafe4e
1 changed files with 3 additions and 3 deletions
6
bot.go
6
bot.go
|
|
@ -213,7 +213,7 @@ func handleOwnerCommand(ctx context.Context, api *tg.Client, state *BotState, al
|
|||
return
|
||||
}
|
||||
|
||||
parts := strings.Fields(text)
|
||||
parts := strings.SplitN(text, " ", 3)
|
||||
if len(parts) < 2 {
|
||||
sendAdminReply(ctx, api, alertPeer, "Usage: /badword <list|add|rem> [word]")
|
||||
return
|
||||
|
|
@ -248,7 +248,7 @@ func handleOwnerCommand(ctx context.Context, api *tg.Client, state *BotState, al
|
|||
sendAdminReply(ctx, api, alertPeer, "Usage: /badword add <word>")
|
||||
return
|
||||
}
|
||||
word := parts[2]
|
||||
word := strings.TrimSpace(parts[2])
|
||||
for _, w := range state.cfg.BadWords {
|
||||
if strings.EqualFold(w, word) {
|
||||
sendAdminReply(ctx, api, alertPeer, fmt.Sprintf("Word %q already exists.", word))
|
||||
|
|
@ -273,7 +273,7 @@ func handleOwnerCommand(ctx context.Context, api *tg.Client, state *BotState, al
|
|||
sendAdminReply(ctx, api, alertPeer, "Usage: /badword rem <word>")
|
||||
return
|
||||
}
|
||||
word := parts[2]
|
||||
word := strings.TrimSpace(parts[2])
|
||||
newWords := make([]string, 0, len(state.cfg.BadWords))
|
||||
found := false
|
||||
for _, w := range state.cfg.BadWords {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue