diff --git a/.env.test b/.env.test index d099dce..947b5c8 100644 --- a/.env.test +++ b/.env.test @@ -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 diff --git a/src/events/just-ask.test.ts b/src/events/just-ask.test.ts new file mode 100644 index 0000000..5a17ffd --- /dev/null +++ b/src/events/just-ask.test.ts @@ -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); + }); + }); +}); diff --git a/src/events/just-ask.ts b/src/events/just-ask.ts index f3506f1..5b9ded6 100644 --- a/src/events/just-ask.ts +++ b/src/events/just-ask.ts @@ -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)`; @@ -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),