mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-21 05:54:33 +02:00
Show final interaction count
This commit is contained in:
@@ -161,7 +161,9 @@ client.on('message', async msg => {
|
|||||||
const cleverbot = client.cleverbots.get(msg.channel.id);
|
const cleverbot = client.cleverbots.get(msg.channel.id);
|
||||||
if (cleverbot) {
|
if (cleverbot) {
|
||||||
if (!cleverbot.shouldRespond(msg)) return;
|
if (!cleverbot.shouldRespond(msg)) return;
|
||||||
|
msg.channel.startTyping().catch(() => null);
|
||||||
const response = await cleverbot.respond(msg.cleanContent);
|
const response = await cleverbot.respond(msg.cleanContent);
|
||||||
|
msg.channel.stopTyping(true);
|
||||||
await msg.channel.send(response);
|
await msg.channel.send(response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,9 @@ module.exports = class CleverbotEndCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run(msg) {
|
run(msg) {
|
||||||
if (!this.client.cleverbots.has(msg.channel.id)) {
|
const cleverbot = this.client.cleverbots.get(msg.channel.id);
|
||||||
return msg.say('There is not a Cleverbot conversation in this channel.');
|
if (!cleverbot) return msg.say('There is not a Cleverbot conversation in this channel.');
|
||||||
}
|
|
||||||
this.client.cleverbots.delete(msg.channel.id);
|
this.client.cleverbots.delete(msg.channel.id);
|
||||||
return msg.reply('Ended the current conversation.');
|
return msg.reply(`Ended the current conversation. Chatted **${cleverbot.interactions}** times.`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "131.11.0",
|
"version": "131.11.1",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ module.exports = class Cleverbot {
|
|||||||
this.channelID = channelID;
|
this.channelID = channelID;
|
||||||
this.authorID = authorID;
|
this.authorID = authorID;
|
||||||
this.cs = null;
|
this.cs = null;
|
||||||
|
this.interactions = 0;
|
||||||
this.timeout = this.setTimeout();
|
this.timeout = this.setTimeout();
|
||||||
this.key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
@@ -29,6 +30,7 @@ module.exports = class Cleverbot {
|
|||||||
clearTimeout(this.timeout);
|
clearTimeout(this.timeout);
|
||||||
this.timeout = this.setTimeout();
|
this.timeout = this.setTimeout();
|
||||||
this.cs = body.cs;
|
this.cs = body.cs;
|
||||||
|
this.interactions = Number.parseInt(body.interaction_count, 10);
|
||||||
return body.output || blankResponses[Math.floor(Math.random() * blankResponses.length)];
|
return body.output || blankResponses[Math.floor(Math.random() * blankResponses.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user