add a 1 minute delay on pti globe reaction

This commit is contained in:
mose 2019-09-14 09:53:08 +08:00
parent 8e80c17238
commit b50958c9cf

View file

@ -1,5 +1,7 @@
const bot = require('bbot'); const bot = require('bbot');
const globe_delay = 60000; // 1 minute
var globe_said = {};
bot.global.text({ bot.global.text({
contains: ['facebook', 'google', 'amazon', 'apple', 'microsoft'] contains: ['facebook', 'google', 'amazon', 'apple', 'microsoft']
@ -9,6 +11,13 @@ bot.global.text({
id: 'gafam-react' id: 'gafam-react'
}); });
bot.global.text(/pe?tit? globe/i, (b) => b.respond('![pti globe](https://crapaud-fou.org/images/chat-ptiglobe.png)'), { bot.global.text(
/pe?tit? globe/i
, (b) => {
if (!globe_said[b.message.user.room] || new Date().getTime() > globe_said[b.message.user.room] + globe_delay) {
b.respond('![pti globe](https://crapaud-fou.org/images/chat-ptiglobe.png)');
globe_said[b.message.user.room] = new Date().getTime();
}
}, {
id: 'ptiglobe-direct' id: 'ptiglobe-direct'
}) })