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:
@@ -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
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user