node-telegram-bot
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -13,3 +13,3 @@ /** | ||
var bot = new Bot({ | ||
token: 'TOKEN HERE' | ||
token: 'TOKEN_HERE' | ||
}) | ||
@@ -53,6 +53,9 @@ .on('message', function (message) { | ||
}) | ||
.on('message', function (message) { | ||
console.log(message); | ||
}) | ||
//Command without argument | ||
.on('test', function(msg){ | ||
.on('test', function (message){ | ||
bot.sendMessage({ | ||
chat_id: msg.chat.id, | ||
chat_id: message.chat.id, | ||
text: 'You\'ve send command: ' + command | ||
@@ -62,5 +65,5 @@ }); | ||
//Command with argument: | ||
.on('arg', function(args, msg){ | ||
.on('arg', function (args, message){ | ||
bot.sendMessage({ | ||
chat_id: msg.chat.id, | ||
chat_id: message.chat.id, | ||
text: 'You\'ve send command with arguments: ' + args | ||
@@ -67,0 +70,0 @@ }); |
@@ -201,8 +201,15 @@ 'use strict' | ||
if (self.polling) { | ||
debug("Poll"); | ||
request.get({ | ||
url: url, | ||
timeout: 6000, | ||
json: true | ||
}, function (err, res, body) { | ||
self._poll(); | ||
if (err) { | ||
self.emit('error', err); | ||
if (err.code !== 'ETIMEDOUT') { | ||
self.emit('error', err); | ||
} | ||
} else if (res.statusCode === 200) { | ||
@@ -240,11 +247,11 @@ if (body.ok) { | ||
self.emit('error', new Error('Duplicate token.')); | ||
} else if(res && res.hasOwnProperty('statusCode') && res.statusCode === 502) { | ||
self.emit('error', new Error('Gateway error.')); | ||
} else { | ||
self.emit('error', new Error(util.format('Unknown error. Status code: %d', res.statusCode))); | ||
} | ||
self._poll(); | ||
}); | ||
} else { | ||
debug('Stopped polling'); | ||
setTimeout(function() { | ||
setTimeout(function () { | ||
self._poll(); | ||
@@ -251,0 +258,0 @@ }, self.interval); |
{ | ||
"name": "node-telegram-bot", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Telegram Bot API Wrapper for nodejs", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,2 +7,3 @@ node-telegram-bot | ||
- 0.1.6 Fixes #53 | ||
- 0.1.5 Add analytics botan.io | ||
@@ -9,0 +10,0 @@ - 0.1.4 Fixes #48 |
86607
1103
106