Skip to content

Add a simple stop-words bot#155

Merged
umputun merged 5 commits intoradio-t:masterfrom
alek-sys:agent-one
Mar 27, 2026
Merged

Add a simple stop-words bot#155
umputun merged 5 commits intoradio-t:masterfrom
alek-sys:agent-one

Conversation

@alek-sys
Copy link
Copy Markdown
Contributor

It turned out to be quite different to integrate it with wtf bot, so it was worthwhile extracting into own thing.

It turned out to be quite different to integrate it with wtf bot, so it was worthwhile extracting into own thing.
@alek-sys alek-sys requested a review from umputun as a code owner January 20, 2026 22:27
@coveralls
Copy link
Copy Markdown

coveralls commented Jan 21, 2026

Pull Request Test Coverage Report for Build 22035658461

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 84 of 85 (98.82%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.6%) to 75.301%

Changes Missing Coverage Covered Lines Changed/Added Lines %
app/main.go 0 1 0.0%
Totals Coverage Status
Change from base Build 14460942638: 0.6%
Covered Lines: 2692
Relevant Lines: 3575

💛 - Coveralls

@umputun
Copy link
Copy Markdown
Member

umputun commented Feb 11, 2026

couple of issues:

  1. \b doesn't work with Cyrillic in Go's RE2 - saynomore.go:59 uses \b for word boundaries, but Go's regexp defines \b via \w which only matches [0-9A-Za-z_]. the bot will never match any of its default Russian stop words. tests pass because they use ASCII words ("badword", "rude"), masking the bug. fix options: use (?:^|\s) / (?:\s|$) instead of \b, or just use strings.Contains on lowercased text since QuoteMeta is already applied (no regex features needed)

  2. panic on empty responses - saynomore.go:106 calls s.rand(int64(len(matched.responses))), if a category has empty Responses slice, rand.Int63n(0) panics. a simple check in NewSayNoMore would prevent it

  3. no test for NewDefaultSayNoMore with actual Cyrillic input - a single test with a real Russian phrase would have caught issue Cover reporter package with unit tests #1

otherwise the design is clean, follows the WTF bot pattern well, and the code is readable

alek-sys and others added 3 commits February 14, 2026 17:26
- Replace \b with Unicode-aware boundaries (?:^|[^\p{L}]) / (?:[^\p{L}]|$)
  since Go RE2 \b only matches ASCII word chars
- Skip categories with empty Responses slice to prevent rand.Int63n(0) panic
- Add Cyrillic matching tests and empty responses tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@umputun umputun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, fixes look good

@umputun umputun merged commit 913f7c5 into radio-t:master Mar 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants