feat(stop): ability to stop bot from listening on updates

resolve #12
This commit is contained in:
Mahdi Dibaiee
2015-11-08 06:52:06 +03:30
parent 82961d7fa5
commit cdb5adc71f
8 changed files with 47 additions and 16 deletions

View File

@ -5,6 +5,7 @@ export default function poll(bot) {
}
bot.emit('update', response.result);
if (bot._stop) return null;
return poll(bot);
});
}

View File

@ -12,7 +12,7 @@ export default function webhook(options = {}, bot) {
return bot.api.setWebhook(options.url).then(() => {
https.createServer(options.server, (req, res) => {
bot._webhookServer = https.createServer(options.server, (req, res) => {
return getBody(req).then(data => {
bot.emit('update', qs.parse(data).result);