diff --git a/bot.go b/bot.go index a98a62c..0d93333 100644 --- a/bot.go +++ b/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 [word]") return @@ -248,7 +248,7 @@ func handleOwnerCommand(ctx context.Context, api *tg.Client, state *BotState, al sendAdminReply(ctx, api, alertPeer, "Usage: /badword add ") 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 ") 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 {