diff --git a/lib/responses.js b/lib/responses.js index f44e605..2712011 100644 --- a/lib/responses.js +++ b/lib/responses.js @@ -112,8 +112,11 @@ export const RICKROLL_BLOCKS = { export function isImageRequest(text) { if (!text) return false; - return /(?:can you |could you |please |)(?:create|generate|make|draw).+(?:image|picture|drawing|illustration)/i.test( - text + return ( + text.length <= 240 && + /(?:can you |could you |please )?(?:create|generate|make|draw)\b.+\b(?:image|picture|drawing|illustration)\b/i.test( + text + ) ); } diff --git a/test/responses.test.js b/test/responses.test.js index e70ffb4..cced89b 100644 --- a/test/responses.test.js +++ b/test/responses.test.js @@ -72,6 +72,7 @@ test('isImageRequest catches several phrasings', () => { assert.ok(isImageRequest('can you create an image of a cat')); assert.ok(isImageRequest('please draw me a picture')); assert.ok(isImageRequest('generate an illustration of a sunset')); + assert.ok(!isImageRequest(`please make ${'draw '.repeat(250)}this eventually become an image`)); assert.ok(!isImageRequest('what is an image')); assert.ok(!isImageRequest('')); });