Skip to content

Commit

Permalink
add /i command
Browse files Browse the repository at this point in the history
  • Loading branch information
fegloff committed Jan 11, 2024
1 parent bb8833f commit 499ad36
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/modules/open-ai/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ 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' }
}

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
Expand Down
11 changes: 8 additions & 3 deletions src/modules/open-ai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 499ad36

Please sign in to comment.