mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-25 04:01:02 +00:00
feat: add wit.ai support
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user