From 925705e216797cff7f17e1041f4ead78b92fae97 Mon Sep 17 00:00:00 2001 From: Ramin Date: Tue, 10 Sep 2024 00:52:19 +0330 Subject: [PATCH] fix reason --- src/routes/bot.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/routes/bot.ts b/src/routes/bot.ts index 9332c01..f43a0aa 100644 --- a/src/routes/bot.ts +++ b/src/routes/bot.ts @@ -10,6 +10,7 @@ const bot = async (req: Request) => { console.log("/bot received new request! Date: " + new Date() + ' hash: ' + hash + ' author: ' + author.username + ' text: ' + text + ' channel: ' + channel.name + ' mentioned_profiles: ' + mentioned_profiles); if (author.username === process.env.PRAISE_FARCASTER_HANDLE) { // The bot should not reply to itself + console.log("The bot should not reply to itself! Date: " + new Date()); return new Response('The bot should not reply to itself', { status: 200 }); } let praiseIndex = text.indexOf('@givepraise to @'); @@ -59,14 +60,7 @@ Please cast in a channel to praise`, console.log("Replied with error: no channel mentioned!"); return new Response(`Replied to the cast with error: no channel mentioned`); } - let forIndex = text.indexOf('for'); - let reason - if (forIndex !== -1) { - reason = text.substring(forIndex); - } else { - // There's no 'for' in the praise - reason = text.split(praiseReceiver.username)[1] - } + const reason = text.split(praiseReceiver.username)[1] const query = { reason, channel: channel.name,