From 499ad36a56a5ef12f4c20a8a6d0eb9895ece8a30 Mon Sep 17 00:00:00 2001 From: fegloff Date: Wed, 10 Jan 2024 23:31:43 -0400 Subject: [PATCH] add /i command --- src/modules/open-ai/helpers.ts | 6 ++++-- src/modules/open-ai/index.ts | 11 ++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/modules/open-ai/helpers.ts b/src/modules/open-ai/helpers.ts index dc329752..a873124f 100644 --- a/src/modules/open-ai/helpers.ts +++ b/src/modules/open-ai/helpers.ts @@ -16,8 +16,10 @@ export const SupportedCommands = { ask32: { name: 'ask32' }, gpt: { name: 'gpt' }, last: { name: 'last' }, - dalle: { name: 'image' }, + dalle: { name: 'dalle' }, + dalleImg: { name: 'image' }, dalleShort: { name: 'img' }, + dalleShorter: { name: 'i' }, genImgEn: { name: 'genImgEn' }, on: { name: 'on' }, off: { name: 'off' } @@ -25,7 +27,7 @@ export const SupportedCommands = { export const MAX_TRIES = 3 -const DALLE_PREFIX_LIST = ['i.', ', ', 'image ', 'd.', 'img '] +const DALLE_PREFIX_LIST = ['i. ', ',', 'image ', 'd.', 'img ', 'i '] export const isMentioned = ( ctx: OnMessageContext | OnCallBackQueryData diff --git a/src/modules/open-ai/index.ts b/src/modules/open-ai/index.ts index 3642eac4..809006aa 100644 --- a/src/modules/open-ai/index.ts +++ b/src/modules/open-ai/index.ts @@ -101,8 +101,10 @@ export class OpenAIBot implements PayableBot { return 0 } if ( - ctx.hasCommand(SupportedCommands.dalle.name) || - ctx.hasCommand(SupportedCommands.dalleShort.name) + ctx.hasCommand([SupportedCommands.dalle.name, + SupportedCommands.dalleImg.name, + SupportedCommands.dalleShort.name, + SupportedCommands.dalleShorter.name]) ) { const imageNumber = ctx.session.openAi.imageGen.numImages const imageSize = ctx.session.openAi.imageGen.imgSize @@ -227,7 +229,10 @@ export class OpenAIBot implements PayableBot { } if ( - ctx.hasCommand([SupportedCommands.dalle.name, SupportedCommands.dalleShort.name]) || + ctx.hasCommand([SupportedCommands.dalle.name, + SupportedCommands.dalleImg.name, + SupportedCommands.dalleShort.name, + SupportedCommands.dalleShorter.name]) || (ctx.message?.text?.startsWith('image ') && ctx.chat?.type === 'private') ) { let prompt = (ctx.match ? ctx.match : ctx.message?.text) as string