Comparing version 1.0.0 to 1.1.0
27
api.md
@@ -18,2 +18,3 @@ # API reference | ||
- [`.forwardMessage(chatId, fromChatId, messageId, extra)`](#forwardmessage) | ||
- [`.sendCopy(chatId, message, extra)`](#sendcopy) | ||
- [`.getChat(chatId)`](#getchat) | ||
@@ -165,9 +166,23 @@ - [`.getChatAdministrators(chatId)`](#getchatadministrators) | ||
| --- | --- | --- | | ||
| chatId | `number`\|`string` | Source Chat id | | ||
| fromChatId | `number`\|`string` | Target Chat id | | ||
| chatId | `number`\|`string` | Target Chat id | | ||
| fromChatId | `number`\|`string` | Source Chat id | | ||
| messageId | `number` | Message id | | ||
| [extra] | `object` | [Extra parameters](https://core.telegram.org/bots/api#forwardmessage)| | ||
* * * | ||
<a name="sendcopy"></a> | ||
#### `telegraf.sendCopy(chatId, message, extra) => Promise` | ||
Sends message copy. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| chatId | `number`\|`string` | Target Chat id | | ||
| message | `object` | Message | | ||
| [extra] | `object` | [Extra parameters](https://core.telegram.org/bots/api#sendmessage)| | ||
* * * | ||
<a name="getchat"></a> | ||
@@ -636,4 +651,3 @@ #### `telegraf.getChat(chatId) => Promise` | ||
telegraf.sendVideo('chatId', { | ||
source: fs.createReadStream('/path/to/video.mp4'), | ||
filename: 'kitten.mp4' | ||
source: fs.createReadStream('/path/to/video.mp4') | ||
}) | ||
@@ -647,4 +661,5 @@ | ||
// send url | ||
telegraf.sendAudio('chatId', { | ||
url: 'http://lorempixel.com/image_output/cats-q-c-640-480-7.jpg' | ||
telegraf.sendPhoto('chatId', { | ||
url: 'http://lorempixel.com/400/200/cats/', | ||
filename: 'kitten.jpg' | ||
}) | ||
@@ -651,0 +666,0 @@ ``` |
var debug = require('debug')('telegraf:core') | ||
var Promise = require('bluebird') | ||
var ware = require('co-ware') | ||
var Promise = require('bluebird') | ||
var util = require('util') | ||
var Telegram = require('./telegram-api') | ||
var memorySession = require('./memory-session') | ||
var constants = require('./constants') | ||
var platform = require('./platform') | ||
@@ -297,3 +297,3 @@ /** | ||
var result = {} | ||
constants.updateTypes.forEach((key) => { | ||
platform.updateTypes.forEach((key) => { | ||
if (update[key]) { | ||
@@ -305,3 +305,3 @@ result.payload = update[key] | ||
if (update.message) { | ||
constants.messageSubTypes.forEach((messageType) => { | ||
platform.messageSubTypes.forEach((messageType) => { | ||
if (update.message[messageType]) { | ||
@@ -366,3 +366,3 @@ result.subType = messageType | ||
if (chatId) { | ||
constants.chatShortcuts.forEach((command) => { | ||
platform.chatShortcuts.forEach((command) => { | ||
context[command.name] = this[command.target].bind(proxy, chatId) | ||
@@ -369,0 +369,0 @@ }) |
@@ -8,3 +8,3 @@ var debug = require('debug')('telegraf:api') | ||
var Multipart = require('multipart-stream') | ||
var constants = require('./constants') | ||
var platform = require('./platform') | ||
var Promise = require('bluebird') | ||
@@ -130,2 +130,25 @@ | ||
/** | ||
* Send message copy . | ||
* | ||
* @param {(string|number)} chatId | ||
* @param {Object} message | ||
* @param {Object} extra | ||
* @return {Promise} | ||
* @api public | ||
*/ | ||
telegram.sendCopy = function (chatId, message, extra) { | ||
var params = {} | ||
var methodName | ||
Object.keys(platform.copyMethods).forEach((type) => { | ||
if (message[type]) { | ||
params[type] = platform.messageExtractors[type](message) | ||
methodName = platform.copyMethods[type] | ||
} | ||
}) | ||
var opts = Object.assign({chat_id: chatId}, params, extra) | ||
debug(methodName, opts) | ||
return this.sendRequest(methodName, opts) | ||
} | ||
/** | ||
* Sends chat action. | ||
@@ -545,3 +568,3 @@ * | ||
if (res && !res.finished && !isMultipart && constants.webHookAnswerBlacklist.indexOf(method) === -1) { | ||
if (res && !res.finished && !isMultipart && platform.webHookAnswerBlacklist.indexOf(method) === -1) { | ||
debug('▷ webhook', method) | ||
@@ -621,3 +644,3 @@ options.method = method | ||
var fileName = value.filename || `${key}.${constants.defaultExtensions[key] || 'dat'}` | ||
var fileName = value.filename || `${key}.${platform.defaultExtensions[key] || 'dat'}` | ||
@@ -624,0 +647,0 @@ if (value.url) { |
{ | ||
"name": "telegraf", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "📢 Modern Telegram bot framework", | ||
@@ -34,3 +34,3 @@ "main": "lib/telegraf.js", | ||
"lib/telegram-api.js", | ||
"lib/constants.js", | ||
"lib/platform.js", | ||
"lib/memory-session.js" | ||
@@ -37,0 +37,0 @@ ], |
@@ -14,3 +14,3 @@ [![npm](https://img.shields.io/npm/l/telegraf.svg?style=flat-square)](https://www.npmjs.com/package/telegraf) | ||
- [Inline mode](https://core.telegram.org/bots/api#inline-mode) | ||
- [Middlewares](https://www.npmjs.com/search?q=telegraf-) | ||
- [Middlewares, middlewares everywhere](https://www.npmjs.com/search?q=telegraf-) | ||
- http/https/Connect/express.js webhooks | ||
@@ -188,3 +188,2 @@ - Reply via webhook | ||
### Telegram WebHook | ||
@@ -198,7 +197,8 @@ | ||
var tlsOptions = { | ||
key: fs.readFileSync('server-key.pem'), | ||
key: fs.readFileSync('server-key.pem'), | ||
cert: fs.readFileSync('server-cert.pem'), | ||
// This is necessary only if the client | ||
// uses the self-signed certificate. | ||
ca: [ fs.readFileSync('client-cert.pem') ] | ||
ca: [ | ||
// This is necessary only if the client uses the self-signed certificate. | ||
fs.readFileSync('client-cert.pem') | ||
] | ||
} | ||
@@ -205,0 +205,0 @@ |
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
61021
1113