From ba9709b06442a6033d7162afe14bd71d136f5676 Mon Sep 17 00:00:00 2001 From: Theo Fandrich Date: Tue, 22 Aug 2023 11:36:45 -0700 Subject: [PATCH 1/4] removed extra log --- src/bot.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/bot.ts b/src/bot.ts index aba2dff4..beae7bc6 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -59,7 +59,6 @@ bot.use( onLimitExceeded: async (ctx) => { // await ctx.reply("Please refrain from sending too many requests") logger.error(`@${ctx.from?.username} has exceeded the message limit`); - logger.error(`onLimitExceeded: ${ctx.message?.text}`) // await ctx.reply(""); }, From 7cab719b815a8a53f45e4d55f09a45f2196672be Mon Sep 17 00:00:00 2001 From: ahiipsa Date: Tue, 22 Aug 2023 22:37:04 +0400 Subject: [PATCH 2/4] Removed await for /ask command --- src/modules/open-ai/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/open-ai/index.ts b/src/modules/open-ai/index.ts index 966f98aa..ae4b9d59 100644 --- a/src/modules/open-ai/index.ts +++ b/src/modules/open-ai/index.ts @@ -230,19 +230,19 @@ export class OpenAIBot { // } if (ctx.message!.text === "/ask harmony.one/dear") { - await ctx.reply(askTemplates.dear); + ctx.reply(askTemplates.dear); return; } if (ctx.hasCommand(SupportedCommands.ask.name)) { ctx.session.openAi.chatGpt.model = ChatGPTModelsEnum.GPT_4; - await this.onChat(ctx); + this.onChat(ctx); return; } if (ctx.hasCommand(SupportedCommands.ask35.name)) { ctx.session.openAi.chatGpt.model = ChatGPTModelsEnum.GPT_35_TURBO; - await this.onChat(ctx); + this.onChat(ctx); return; } From 54393f3ffc73b71c4380363f35b2bf3fa8c42019 Mon Sep 17 00:00:00 2001 From: Theo Fandrich Date: Tue, 22 Aug 2023 12:53:07 -0700 Subject: [PATCH 3/4] changed limit to 3 seconds per 3 --- src/bot.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bot.ts b/src/bot.ts index beae7bc6..6b9cc532 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -51,9 +51,9 @@ bot.api.config.use(autoRetry()); bot.use( limit({ - // Allow only 20 message to be handled every 1 minute. - timeFrame: 60000, - limit: 20, + // Allow only 3 message to be handled every 3 seconds. + timeFrame: 3000, + limit: 3, // This is called when the limit is exceeded. onLimitExceeded: async (ctx) => { From aff9d2d72062170b8aa9a978bdc3ba1a32f73874 Mon Sep 17 00:00:00 2001 From: fegloff Date: Tue, 22 Aug 2023 16:02:32 -0500 Subject: [PATCH 4/4] hotfix: drop_pending_updates: true --- src/bot.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bot.ts b/src/bot.ts index 6b9cc532..b9c428cc 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -394,7 +394,9 @@ app.use(express.static("./public")); // Public directory, used in voice-memo bot app.listen(config.port, () => { logger.info(`Bot listening on port ${config.port}`); - bot.start(); + bot.start({ + drop_pending_updates: true + }); AppDataSource.initialize(); // bot.start({