prevent command timeout from picking up on non client-directed messages

This commit is contained in:
hgw 2023-10-02 02:11:27 +00:00
parent bc6f27f72d
commit 129d77efd6

44
bot.js
View File

@ -123,31 +123,33 @@ async function twitter(chan, provfeed, n) {
} }
bot.addListener('message', function(nick, to, text, from) { bot.addListener('message', function(nick, to, text, from) {
if (msgTimeout.has(to)) { if (text.startsWith(config.irc.prefix)) {
if (msgTimeoutMsg.has("yes")) { if (msgTimeout.has(to)) {
return; if (msgTimeoutMsg.has("yes")) {
return;
} else {
bot.say(to, errorMsg+" You are sending commands too quickly")
msgTimeoutMsg.add("yes");
setTimeout(() => {
msgTimeoutMsg.delete("yes");
}, config.floodprotect.command_listen_timeout)
}
} else { } else {
bot.say(to, errorMsg+" You are sending commands too quickly") var args = text.split(' ');
msgTimeoutMsg.add("yes"); if (args[0] === config.irc.prefix+'help') {
help(to, args[1]);
} else if (args[0] === config.irc.prefix+'feed') {
feed(to, nick, args[1], args[2]);
} else if (args[0] === config.irc.prefix+'twitter') {
twitter(to, args[1], args[2])
} else if (args[0] === config.irc.prefix+'opt') {
opt(to, nick, args[1], args[2], args[3], args[4])
}
msgTimeout.add(to);
setTimeout(() => { setTimeout(() => {
msgTimeoutMsg.delete("yes"); msgTimeout.delete(to);
}, config.floodprotect.command_listen_timeout) }, config.floodprotect.command_listen_timeout)
} }
} else {
var args = text.split(' ');
if (args[0] === config.irc.prefix+'help') {
help(to, args[1]);
} else if (args[0] === config.irc.prefix+'feed') {
feed(to, nick, args[1], args[2]);
} else if (args[0] === config.irc.prefix+'twitter') {
twitter(to, args[1], args[2])
} else if (args[0] === config.irc.prefix+'opt') {
opt(to, nick, args[1], args[2], args[3], args[4])
}
msgTimeout.add(to);
setTimeout(() => {
msgTimeout.delete(to);
}, config.floodprotect.command_listen_timeout)
} }
}); });