Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ REPEL_LOG_CHANNEL_ID=your-repel-log-channel-id
# Role IDs (from your dev server)
REPEL_ROLE_ID=your-repel-role-id
MODERATORS_ROLE_IDS=your-moderator-role-id
REGULAR_ROLE_ID=your-regular-role-id

# Other
GUIDES_TRACKER_PATH=guides-tracker.json
Expand Down
22 changes: 22 additions & 0 deletions src/events/just-ask.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import assert from 'node:assert';
import { describe, it } from 'node:test';
import { isAskingToAsk } from './just-ask.js';

describe('justAsk Regex', () => {
const testCases = [
{ input: 'Anyone knows js?', expected: true },
{ input: 'Somebody can help with Python?', expected: true },
{ input: 'No one has experience with js?', expected: true },
{ input: 'Everybody tried React?', expected: true },
{ input: 'People familiar with Kubernetes?', expected: true },

{ input: 'I know js well.', expected: false },
{ input: 'This is a question without the pattern.', expected: false },
];
testCases.forEach(({ input, expected }) => {
it(`should return ${expected} for input: "${input}"`, () => {
const result = isAskingToAsk(input);
assert.strictEqual(result, expected);
});
});
});
4 changes: 2 additions & 2 deletions src/events/just-ask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { loadMarkdownOptions } from '../util/markdown.js';
import { rateLimit } from '../util/rate-limit.js';

// Subject patterns (who)
const reSubject = `(?:(?:any|some|no|every)(?:one|body)|people|folks|peeps|who)`;
const reSubject = `(?:(?:any|some|no|every)(?: ?(?:one|body))|people|folks|peeps|who)`;

// Verb patterns (has/knows/can help/etc)
const reVerb = `(?:ha[sv]e?|got|knows?|can(?: help)?|tried|used|worked(?: with)?|familiar(?: with)?|experience[ds]?(?: with)?|heard(?: of)?|seen)`;
Expand All @@ -25,7 +25,7 @@ const askToAskPattern = new RegExp(
'i'
);

const isAskingToAsk = (text: string) => askToAskPattern.test(text);
export const isAskingToAsk = (text: string) => askToAskPattern.test(text);

const [response] = await loadMarkdownOptions<{ name: string }>(
new URL('../commands/tips/subjects/', import.meta.url),
Expand Down