Skip to content

Commit

Permalink
Merge pull request #159 from harmony-one/dev
Browse files Browse the repository at this point in the history
Dev to Master Merge
  • Loading branch information
fegloff authored Aug 22, 2023
2 parents b29e5d5 + aff9d2d commit b919a64
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,14 @@ 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) => {
// 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("");
},

Expand Down Expand Up @@ -395,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({
Expand Down
6 changes: 3 additions & 3 deletions src/modules/open-ai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit b919a64

Please sign in to comment.