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
7 changes: 5 additions & 2 deletions lib/responses.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
);
}

Expand Down
1 change: 1 addition & 0 deletions test/responses.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(''));
});
Expand Down
Loading