mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-21 02:03:57 +00:00
feat: add wit.ai support
This commit is contained in:
@@ -27,20 +27,7 @@
|
||||
{
|
||||
"label": "DOWNLOAD",
|
||||
"threshold": 0.85,
|
||||
"responses": [
|
||||
{
|
||||
"p": "discord",
|
||||
"text": "you wanted peevanced"
|
||||
},
|
||||
{
|
||||
"p": "telegram",
|
||||
"text":"you wanted peevanced, on telegram"
|
||||
},
|
||||
{
|
||||
"p": "reddit",
|
||||
"text": "you wanted peevanced, on reddit"
|
||||
}
|
||||
]
|
||||
"text": "the download?"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ export default {
|
||||
once: false,
|
||||
execute(helper, _, msg) {
|
||||
if (!msg.content || msg.author.bot) return;
|
||||
if (!msg.mentions.has(msg.client.user)) return;
|
||||
helper.scanText(msg.content.toLowerCase().replace(/<.*?>/g, ''), `${msg.channelId}/${msg.id}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
|
||||
export default {
|
||||
name: 'aiResponse',
|
||||
once: false,
|
||||
async execute(client, config, aiRes) {
|
||||
if (!aiRes.response) return;
|
||||
if (!aiRes.response[0]) return;
|
||||
|
||||
try {
|
||||
const ids = aiRes.id.split('/');
|
||||
@@ -20,10 +23,19 @@ export default {
|
||||
message = channel.messages.cache.get(ids[1]);
|
||||
}
|
||||
|
||||
message.reply(aiRes.response);
|
||||
const intent = aiRes.response.reduce((a, b) => a.confidence > b.confidence ? a : b);
|
||||
const response = config.responses.find((res) => res.label === intent.name);
|
||||
if (response.threshold > intent.confidence) return;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('You have asked a Frequently Asked Question')
|
||||
.setDescription(response.text)
|
||||
.setFooter({ text: `Confidence: ${intent.confidence}` });
|
||||
|
||||
message.reply({ embeds: [embed]});
|
||||
|
||||
return;
|
||||
} catch (e) {}
|
||||
} catch (e) {console.log(e)}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,16 +2,22 @@ export default {
|
||||
name: 'aiResponse',
|
||||
once: false,
|
||||
async execute(client, config, aiRes) {
|
||||
if (!aiRes.response) return;
|
||||
if (!aiRes.response[0]) return;
|
||||
const ids = aiRes.id.split('/');
|
||||
|
||||
const intent = aiRes.response.reduce((a, b) => a.confidence > b.confidence ? a : b);
|
||||
const response = config.responses.find((res) => res.label === intent.name);
|
||||
if (response.threshold > intent.confidence) return;
|
||||
|
||||
switch (ids[0]) {
|
||||
case 'comment': {
|
||||
client.getComment(ids[1]).reply(aiRes.response);
|
||||
client.getComment(ids[1]).reply(`${response.text}\n\n*Confidence: ${intent.confidence}*`);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'post': {
|
||||
client.getSubmission(ids[1]).reply(aiRes.response);
|
||||
client.getSubmission(ids[1]).reply(`${response.text}\n\n*Confidence: ${intent.confidence}*`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,17 @@ export default {
|
||||
name: 'aiResponse',
|
||||
once: false,
|
||||
async execute(bot, config, aiRes) {
|
||||
if (!aiRes.response) return;
|
||||
if (!aiRes.response[0]) return;
|
||||
const ids = aiRes.id.split('/');
|
||||
const intent = aiRes.response.reduce((a, b) => a.confidence > b.confidence ? a : b);
|
||||
const response = config.responses.find((res) => res.label === intent.name);
|
||||
if (response.threshold > intent.confidence) return;
|
||||
|
||||
bot.sendMessage(ids[0], aiRes.response, {
|
||||
bot.sendMessage(ids[0], `${response.text}\n\n*Confidence: ${intent.confidence}*`, {
|
||||
message_thread_id: ids[1],
|
||||
reply_to_message_id: ids[2]
|
||||
reply_to_message_id: ids[2],
|
||||
parse_mode: 'HTML'
|
||||
});
|
||||
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user