Added uwu support - #275
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an “uwu” transformation path to suppressed-message handling in SuppressorService, applying it randomly under specific conditions, and extends the unit tests to cover the new behavior.
Changes:
- Added
uwuifyTextandshouldUwuifyTexthelpers and integrated a ~5% uwuify branch intosendSuppressedMessage. - Updated suppression flow to sometimes bypass translation when uwuify triggers.
- Added/updated unit tests to verify uwuify vs translate behavior under controlled randomness.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/backend/src/shared/services/suppressor.service.ts | Introduces uwuify helper methods and a conditional uwuify/translate branch in suppressed message sending. |
| packages/backend/src/shared/services/suppressor.service.spec.ts | Adds tests for uwuify triggering/skip logic and stabilizes translation assertions. |
Suppressed comments (3)
packages/backend/src/shared/services/suppressor.service.spec.ts:139
- This test spies on
Math.random()but never restores it. Becausevi.clearAllMocks()doesn't restore spied implementations, the mock can persist across tests and cause cross-test coupling.
it('sendSuppressedMessage skips uwu when the text has fewer than 4 r or l letters', async () => {
vi.spyOn(Math, 'random').mockReturnValue(0.04);
packages/backend/src/shared/services/suppressor.service.spec.ts:158
- This test spies on
Math.random()but never restores it;vi.clearAllMocks()won't restore the original implementation, so the mocked value can leak into later tests.
it('sendSuppressedMessage uses translation for normal channels', async () => {
vi.spyOn(Math, 'random').mockReturnValue(0.5);
packages/backend/src/shared/services/suppressor.service.spec.ts:177
- This test spies on
Math.random()but doesn't restore it afterwards. Since the file-level setup usesvi.clearAllMocks()(notvi.restoreAllMocks()), the spied implementation can persist across tests.
it('sendSuppressedMessage falls back when translation fails', async () => {
vi.spyOn(Math, 'random').mockReturnValue(0.5);
(suppressorService.translationService.translate as Mock).mockRejectedValue(new Error('translate fail'));
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+256
to
+260
| const shouldUwuify = Math.random() < 0.05 && this.shouldUwuifyText(textWithFallbackReplacments); | ||
| await ( | ||
| shouldUwuify | ||
| ? Promise.resolve(this.uwuifyText(textWithFallbackReplacments)) | ||
| : this.translationService.translate(textWithFallbackReplacments) |
Comment on lines
+121
to
+135
| it('sendSuppressedMessage uwuifies text by replacing r and l with w roughly 5% of the time when there are at least 4 eligible letters', async () => { | ||
| vi.spyOn(Math, 'random').mockReturnValue(0.04); | ||
|
|
||
| await suppressorService.sendSuppressedMessage( | ||
| 'C123', | ||
| 'U1', | ||
| 'hello world', | ||
| '123', | ||
| 1, | ||
| suppressorService.muzzlePersistenceService as never, | ||
| ); | ||
|
|
||
| expect(suppressorService.translationService.translate).not.toHaveBeenCalled(); | ||
| expect(suppressorService.webService.sendMessage).toHaveBeenCalledWith('C123', '<@U1> says "hewwo wowwd"'); | ||
| }); |
Comment on lines
+206
to
+210
| public uwuifyText(text: string): string { | ||
| return text.replace(/[rRlL]/g, 'w'); | ||
| } | ||
|
|
||
| public shouldUwuifyText(text: string): boolean { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.