mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 00:07:36 +02:00
Fix
This commit is contained in:
@@ -157,7 +157,7 @@ client.on('message', async msg => {
|
|||||||
|
|
||||||
// Cleverbot handler
|
// Cleverbot handler
|
||||||
const cleverbot = client.cleverbots.get(msg.channel.id);
|
const cleverbot = client.cleverbots.get(msg.channel.id);
|
||||||
if (cleverbot) {
|
if (cleverbot && cleverbot.active) {
|
||||||
if (!hasText) return;
|
if (!hasText) return;
|
||||||
if (!cleverbot.shouldRespond(msg)) return;
|
if (!cleverbot.shouldRespond(msg)) return;
|
||||||
const response = await cleverbot.respond(msg.cleanContent);
|
const response = await cleverbot.respond(msg.cleanContent);
|
||||||
|
|||||||
@@ -21,16 +21,18 @@ module.exports = class CleverbotCommand extends Command {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
run(msg) {
|
async run(msg) {
|
||||||
if (this.client.cleverbots.has(msg.channel.id)) {
|
if (this.client.cleverbots.has(msg.channel.id)) {
|
||||||
return msg.say('There is already a Cleverbot conversation in this channel.');
|
return msg.say('There is already a Cleverbot conversation in this channel.');
|
||||||
}
|
}
|
||||||
const cleverbot = new Cleverbot(this.client, msg.channel.id, msg.author.id);
|
const cleverbot = new Cleverbot(this.client, msg.channel.id, msg.author.id);
|
||||||
this.client.cleverbots.set(msg.channel.id, cleverbot);
|
this.client.cleverbots.set(msg.channel.id, cleverbot);
|
||||||
const usage = this.client.registry.commands.get('cleverbot-end').usage();
|
const usage = this.client.registry.commands.get('cleverbot-end').usage();
|
||||||
return msg.reply(stripIndents`
|
await msg.reply(stripIndents`
|
||||||
Cleverbot is now active in this channel, replying to ${msg.author}.
|
Cleverbot is now active in this channel, replying to ${msg.author}.
|
||||||
To end the conversation, use ${usage}.
|
To end the conversation, use ${usage}.
|
||||||
`);
|
`);
|
||||||
|
cleverbot.active = true;
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ module.exports = class Cleverbot {
|
|||||||
this.cs = null;
|
this.cs = null;
|
||||||
this.timeout = this.setTimeout();
|
this.timeout = this.setTimeout();
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
this.active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async respond(input) {
|
async respond(input) {
|
||||||
|
|||||||
Reference in New Issue
Block a user