diff --git a/src/modules/open-ai/api/openAi.ts b/src/modules/open-ai/api/openAi.ts index ab45f950..6e25b2b4 100644 --- a/src/modules/open-ai/api/openAi.ts +++ b/src/modules/open-ai/api/openAi.ts @@ -162,6 +162,7 @@ export const streamChatCompletion = async ( }; let completion = ""; let msgId = 0; + let showStatus = false; return new Promise(async (resolve, reject) => { const res = await openai.createChatCompletion( payload as CreateChatCompletionRequest, @@ -176,6 +177,7 @@ export const streamChatCompletion = async ( for (const line of lines) { const message = line.replace(/^data: /, ""); if (message === "[DONE]") { + showStatus = false; if (!completion.endsWith(".")) { if (msgId === 0) { msgId = (await ctx.reply(completion)).message_id; @@ -202,6 +204,13 @@ export const streamChatCompletion = async ( .editMessageText(ctx.chat?.id!, msgId, completion) .catch((e: any) => console.log(e)); } + if (!showStatus) { + await ctx.replyWithChatAction("typing"); + showStatus = true; + setTimeout(async () => { + showStatus = false; + }, 10000); + } } } catch (error) { logger.error("Could not JSON parse stream message", message, error); diff --git a/src/modules/qrcode/QRCodeBot.ts b/src/modules/qrcode/QRCodeBot.ts index b508087c..e2e6454a 100644 --- a/src/modules/qrcode/QRCodeBot.ts +++ b/src/modules/qrcode/QRCodeBot.ts @@ -162,7 +162,7 @@ Please add return } - ctx.reply(`Generating...`); + // ctx.reply(`Generating...`); const messageText = message; diff --git a/src/modules/sd-images/index.ts b/src/modules/sd-images/index.ts index e1569487..46e62888 100644 --- a/src/modules/sd-images/index.ts +++ b/src/modules/sd-images/index.ts @@ -109,7 +109,7 @@ export class SDImagesBot { let idx = this.queue.findIndex(v => v === uuid); if (idx !== 0) { - ctx.reply(`${author} you are the ${idx + 1}/${this.queue.length}. Please wait about ${idx * 30} sec`); + ctx.reply(`You are ${idx + 1} of ${this.queue.length}. Please wait ~${idx * 30}seconds`); } // waiting queue @@ -119,7 +119,7 @@ export class SDImagesBot { idx = this.queue.findIndex(v => v === uuid); } - // ctx.reply(`${author} starting to generate your image`); + // ctx.reply(`Generating...`); ctx.api.sendChatAction(ctx.chat?.id!,'upload_photo') const imageBuffer = await this.sdNodeApi.generateImage(prompt); @@ -161,7 +161,7 @@ export class SDImagesBot { let idx = this.queue.findIndex(v => v === uuid); if (idx !== 0) { - ctx.reply(`${author} you are the ${idx + 1}/${this.queue.length}. Please wait about ${idx * 30} sec`); + ctx.reply(`You are ${idx + 1} of ${this.queue.length}. Please wait ~${idx * 30}seconds`); } // waiting queue