Skip to content

Commit

Permalink
version 0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
temaivanoff committed Sep 11, 2018
1 parent 8626940 commit 40a10a5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class Telegram extends EventEmitter {
};
}

requestSendMessage(id, msg, callback) {
requestSendMessage(id, msg, notification = true, callback) {
return request.post({
headers: { 'content-type': 'application/x-www-form-urlencoded' },
url: `https://api.telegram.org/bot${this.options.token}/sendMessage`,
proxy: this.params.proxy,
body: `chat_id=${id}&text=${msg}`,
body: `chat_id=${id}&text=${msg}&disable_notification=${!notification}`,
}, (error, response, body) => {
if (error) {
callback(true);
Expand All @@ -41,7 +41,7 @@ class Telegram extends EventEmitter {



sendText(id, msg) {
sendText(id, msg, notification) {
const SEND_ERROR = this.options.sendError;
const SEND_TIMEOUT = this.options.sendTimeout
const req = this.requestSendMessage.bind(this);
Expand All @@ -51,11 +51,11 @@ class Telegram extends EventEmitter {
if (err) {
error++;
if (error <= SEND_ERROR) {
setTimeout(() => req(id, msg, check), SEND_TIMEOUT * 1000);
setTimeout(() => req(id, msg, notification, check), SEND_TIMEOUT * 1000);
}
}
}
req(id, msg, check);
req(id, msg, notification, check);
}

checkProxy(host, callback) {
Expand Down

0 comments on commit 40a10a5

Please sign in to comment.