2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-31 06:16:07 +00:00

Method bot.onText

This commit is contained in:
Yago
2015-10-10 17:54:11 +02:00
parent 9863172779
commit cfd32f47bf
2 changed files with 40 additions and 1 deletions

View File

@@ -463,7 +463,24 @@ describe('Telegram', function () {
});
});
it('should call `onText` callback on match', function (done) {
var bot = new Telegram(TOKEN, {webHook: true});
bot.onText(/\/echo (.+)/, function (msg, match) {
bot._WebHook._webServer.close();
match[1].should.be.exactly('ECHO ALOHA');
done();
});
var url = 'http://localhost:8443/bot'+TOKEN;
request({
url: url,
method: 'POST',
json: true,
headers: {
'content-type': 'application/json',
},
body: {update_id: 0, message: {text: '/echo ECHO ALOHA'}}
});
});
}); // End Telegram