node-telegram-bot-api
Advanced tools
Comparing version 0.15.0 to 0.16.0
@@ -14,11 +14,15 @@ var TelegramBot = require('../src/telegram'); | ||
}); | ||
bot.on('text', function (msg) { | ||
// Matches /photo | ||
bot.onText(/\/photo/, function (msg) { | ||
var chatId = msg.chat.id; | ||
if (msg.text == '/photo') { | ||
// From file | ||
var photo = __dirname+'/../test/bot.gif'; | ||
bot.sendPhoto(chatId, photo, {caption: "I'm a bot!"}); | ||
} | ||
if (msg.text == '/audio') { | ||
var url = 'https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg'; | ||
// From file | ||
var photo = __dirname+'/../test/bot.gif'; | ||
bot.sendPhoto(chatId, photo, {caption: "I'm a bot!"}); | ||
}); | ||
// Matches /audio | ||
bot.onText(/\/audio/, function (msg) { | ||
var chatId = msg.chat.id; | ||
var url = 'https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg'; | ||
// From HTTP request! | ||
@@ -32,5 +36,8 @@ var audio = request(url); | ||
}); | ||
} | ||
if (msg.text == '/love') { | ||
var opts = { | ||
}); | ||
// Matches /love | ||
bot.onText(/\/love/, function (msg) { | ||
var chatId = msg.chat.id; | ||
var opts = { | ||
reply_to_message_id: msg.message_id, | ||
@@ -44,3 +51,8 @@ reply_markup: JSON.stringify({ | ||
bot.sendMessage(chatId, 'Do you love me?', opts); | ||
} | ||
}); | ||
bot.onText(/\/echo (.+)/, function (msg, match) { | ||
var chatId = msg.chat.id; | ||
var resp = match[1]; | ||
bot.sendMessage(chatId, resp); | ||
}); |
{ | ||
"name": "node-telegram-bot-api", | ||
"version": "0.15.0", | ||
"version": "0.16.0", | ||
"description": "Telegram Bot API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,4 +0,4 @@ | ||
[![Build Status](https://travis-ci.org/yagop/node-telegram-bot-api.svg?branch=master)](https://travis-ci.org/yagop/node-telegram-bot-api) [![Build status](https://ci.appveyor.com/api/projects/status/ujko6bsum3g5msjh/branch/master?svg=true)](https://ci.appveyor.com/project/yagop/node-telegram-bot-api/branch/master) [![Coverage Status](https://coveralls.io/repos/yagop/node-telegram-bot-api/badge.svg?branch=master)](https://coveralls.io/r/yagop/node-telegram-bot-api?branch=master) [![bitHound Score](https://www.bithound.io/github/yagop/node-telegram-bot-api/badges/score.svg)](https://www.bithound.io/github/yagop/node-telegram-bot-api) | ||
[![Build Status](https://travis-ci.org/yagop/node-telegram-bot-api.svg?branch=master)](https://travis-ci.org/yagop/node-telegram-bot-api) [![Build status](https://ci.appveyor.com/api/projects/status/ujko6bsum3g5msjh/branch/master?svg=true)](https://ci.appveyor.com/project/yagop/node-telegram-bot-api/branch/master) [![Coverage Status](https://coveralls.io/repos/yagop/node-telegram-bot-api/badge.svg?branch=master)](https://coveralls.io/r/yagop/node-telegram-bot-api?branch=master) [![bitHound Score](https://www.bithound.io/github/yagop/node-telegram-bot-api/badges/score.svg)](https://www.bithound.io/github/yagop/node-telegram-bot-api) [![https://telegram.me/node_telegram_bot_api](https://img.shields.io/badge/Telegram-node__telegram__bot__api-blue.svg)](https://telegram.me/node_telegram_bot_api) [![https://telegram.me/Yago_Perez](https://img.shields.io/badge/Telegram-Yago__Perez-blue.svg)](https://telegram.me/Yago_Perez) | ||
Node.js module to interact with official [Telegram Bot API](https://core.telegram.org/bots/api). A bot token is needed, to obtain one, talk to [@botfather](telegram.me/BotFather) and create a new bot. | ||
Node.js module to interact with official [Telegram Bot API](https://core.telegram.org/bots/api). A bot token is needed, to obtain one, talk to [@botfather](https://telegram.me/BotFather) and create a new bot. | ||
@@ -5,0 +5,0 @@ ```sh |
@@ -99,2 +99,9 @@ 'use strict'; | ||
options = options || {}; | ||
if (options.form) { | ||
var replyMarkup = options.form.reply_markup; | ||
if (replyMarkup && typeof replyMarkup !== 'string') { | ||
// reply_markup must be passed as JSON stringified to Telegram | ||
options.form.reply_markup = JSON.stringify(replyMarkup); | ||
} | ||
} | ||
options.url = this._buildURL(path); | ||
@@ -101,0 +108,0 @@ debug('HTTP request: %j', options); |
@@ -20,3 +20,3 @@ 'use strict'; | ||
this.timeout = options.timeout || 0; | ||
this.interval = options.interval || 2000; | ||
this.interval = options.interval || 300; | ||
this.lastUpdate = 0; | ||
@@ -23,0 +23,0 @@ this.lastRequest = null; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
563003
1127