Socket
Socket
Sign inDemoInstall

tgb

Package Overview
Dependencies
0
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.1 to 0.4.2

20

examples/polling.js
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);
}
});

2

package.json
{
"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) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc