Comparing version 0.4.1 to 0.4.2
const tgb = require("../index"); | ||
/* | ||
const bot = tgb(process.env.TELEGRAM_BOT_TOKEN); | ||
@@ -21,2 +22,21 @@ const {polling, entities} = tgb; | ||
} | ||
}); | ||
*/ | ||
const token = process.env.TELEGRAM_BOT_TOKEN; | ||
const {polling, entities} = tgb; | ||
//----------------------------------------------------- | ||
polling(token, {"proxy": "127.0.0.1:8080"}, function({message}, bot) { | ||
bot.sendMessage([message.from.id, entities(message) || "empty"]); | ||
}).catch(function(error) { | ||
if(error.code === tgb.ERR_INVALID_TOKEN) { | ||
this.stop(); | ||
console.log("There's a problem with the token..."); | ||
} | ||
else { | ||
delete error.response; | ||
console.log(error); | ||
} | ||
}); |
{ | ||
"name": "tgb", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "The best choice for your Telegram Bots", | ||
@@ -5,0 +5,0 @@ "homepage": "https://666.io", |
@@ -63,3 +63,3 @@ [![Codacy][cod_b]][cod_l] | ||
// tgb.polling(token, onMsg(data, bot)).stop().start(); | ||
// tgb.polling(token, options{limit, timeout, interval}, onMsg(data, bot)); | ||
// tgb.polling(token, options{proxy, limit, timeout, interval}, onMsg(data, bot)); | ||
// tgb.polling(bot, onMsg(data)); | ||
@@ -66,0 +66,0 @@ |
@@ -18,6 +18,2 @@ //----------------------------------------------------- | ||
function polling(bot, options, onMessage) { | ||
if(typeof(bot) === "string") { | ||
bot = client(bot); | ||
} | ||
if(typeof(options) === "function") { | ||
@@ -36,2 +32,7 @@ onMessage = options; | ||
if(typeof(bot) === "string") { | ||
bot = client(bot); | ||
bot.proxy = options.proxy; | ||
} | ||
//----------------]> | ||
@@ -112,3 +113,3 @@ | ||
try { | ||
onMessage.call(instance, d); | ||
onMessage.call(instance, d, bot); | ||
options.offset = id + 1; | ||
@@ -115,0 +116,0 @@ } catch(e) { |
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
88446
2244