From 78037580dc92883f5ca21157e45268850cb5db90 Mon Sep 17 00:00:00 2001 From: GramingFoxTeam Date: Wed, 16 Nov 2022 18:09:42 +0300 Subject: [PATCH] fix(discord-bot): only send lowercased text --- bots/discord/commands/trainMessage.js | 2 +- bots/discord/events/helper/aiResponse.js | 2 ++ bots/telegram/commands/train.js | 1 - bots/telegram/events/helper/aiResponse.js | 2 ++ bots/telegram/events/telegram/callbackQuery.js | 4 +--- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bots/discord/commands/trainMessage.js b/bots/discord/commands/trainMessage.js index 4674ead..5b9d843 100644 --- a/bots/discord/commands/trainMessage.js +++ b/bots/discord/commands/trainMessage.js @@ -45,7 +45,7 @@ export default { collector.on('collect', (i) => { i.client.helper.sendTrainData( - interaction.targetMessage.content, + interaction.targetMessage.content.toLowerCase(), i.values[0].toUpperCase() ); diff --git a/bots/discord/events/helper/aiResponse.js b/bots/discord/events/helper/aiResponse.js index fecf23a..b3ee448 100644 --- a/bots/discord/events/helper/aiResponse.js +++ b/bots/discord/events/helper/aiResponse.js @@ -8,6 +8,8 @@ export default { if (!response) return; if (Number(aiRes.predictions[0].score) >= response.threshold) { + if (!response.text) return; + const ids = aiRes.id.split('/'); let channel = global.client.channels.cache.get(ids[0]); diff --git a/bots/telegram/commands/train.js b/bots/telegram/commands/train.js index aeca3aa..722ae8e 100644 --- a/bots/telegram/commands/train.js +++ b/bots/telegram/commands/train.js @@ -1,7 +1,6 @@ export default { command: /\/train/, async execute(msg) { - console.log(msg); if (msg.reply_to_message.message_id === msg.message_thread_id) return global.bot.sendMessage(msg.chat.id, 'Please reply to a message!', { message_thread_id: msg.message_thread_id, diff --git a/bots/telegram/events/helper/aiResponse.js b/bots/telegram/events/helper/aiResponse.js index 0d2f29d..ae5e69d 100644 --- a/bots/telegram/events/helper/aiResponse.js +++ b/bots/telegram/events/helper/aiResponse.js @@ -10,6 +10,8 @@ export default { if (Number(aiRes.predictions[0].score) >= response.threshold) { const ids = aiRes.id.split('/'); + if (!response.text) return; + global.bot.sendMessage(ids[0], response.text, { message_thread_id: ids[1], reply_to_message_id: ids[2] diff --git a/bots/telegram/events/telegram/callbackQuery.js b/bots/telegram/events/telegram/callbackQuery.js index 0564ff1..835f564 100644 --- a/bots/telegram/events/telegram/callbackQuery.js +++ b/bots/telegram/events/telegram/callbackQuery.js @@ -3,9 +3,7 @@ export default { once: false, async execute(cb) { const admins = await global.bot.getChatAdministrators(cb.message.chat.id); - const isAdmin = admins.find( - (admin) => admin.user.id === cb.from.id - ); + const isAdmin = admins.find((admin) => admin.user.id === cb.from.id); if (!isAdmin) return global.bot.sendMessage(