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.0.7 to 0.1.0

2

package.json
{
"name": "tgb",
"version": "0.0.7",
"version": "0.1.0",
"description": "The best choice for your Telegram Bots",

@@ -5,0 +5,0 @@ "homepage": "https://666.io",

[![Codacy][cod_b]][cod_l]
[![Bot API](https://img.shields.io/badge/Bot%20API-v.3.5-blue.svg)](https://core.telegram.org/bots/api)
```

@@ -19,4 +21,2 @@ npm -g install tgb

[Full Bot API 3.5][3]
* [WebHook](#refWebHook): +

@@ -47,9 +47,2 @@ * [Download](#refDownload): +

#### Goals:
1. High stability;
2. Low memory usage;
3. Maximum performance;
4. Flexibility.
```js

@@ -106,4 +99,3 @@ const tgb = require("tgb");

}
})).catch(function(error) { // srv|cl errors
});
})).catch(function(error) {}); // srv|cl errors

@@ -120,3 +112,3 @@ const url = await wh.bind(bot, "db.gg", function({message}, bot) {

// url = await wh.bind(otherBot, "666.io:88", cb); // with api.setWebhook
// wh = wh.set(otherBot2, "666.io:88", cb); // without api.setWebhook
// wh = wh.set(otherBot2, url, cb); // without api.setWebhook

@@ -152,5 +144,7 @@ // url = await wh.unbind(otherBot); // with api.deleteWebhook

void async function () {
void async function() {
await download(bot.token, fileId);
}();
// https://core.telegram.org/bots/api#file
```

@@ -165,3 +159,3 @@

void async function () {
void async function() {
bot.proxy = "127.0.0.1:1337"; // Only HTTPS

@@ -183,3 +177,3 @@

```js
void async function () {
void async function() {
const bot = tgb(process.env.TELEGRAM_BOT_TOKEN);

@@ -226,7 +220,3 @@ const params = {"chat_id": "0", "audio": "O://1.mp3"};

/*
Added the option to specify an HTTP URL for a file in all methods where InputFile or file_id can be used (except voice messages).
Telegram will get the file from the specified URL and send it to the user.
Files must be smaller than 5 MB for photos and smaller than 20 MB for all other types of content.
*/
// https://core.telegram.org/bots/api#sending-files
```

@@ -246,3 +236,3 @@

"text": "Hi"
}).keyboard(`A a| B b |C c\n X `));
}).keyboard(`A|B|C\nX|Y\nO`));

@@ -302,22 +292,2 @@ // Remove

<a name="refCLI"></a>
#### CLI
```js
> SET TELEGRAM_BOT_TOKEN=1:XXXX
> tgb-cli -j --method sendPhoto --d.chat_id 0 --d.photo "J://test.jpg"
> tgb-cli --method getMe
> tgb-cli --method getMe --token 0:XXXX
> tgb-cli --method getMe --token 0:XXXX --proxy "127.0.0.1:1337"
> tgb-cli --method sendMessage --data "{\"chat_id\":0,\"text\":\"Hi yo\"}"
> tgb-cli --method sendMessage --d.chat_id 1 --data "{\"chat_id\":0,\"text\":\"Hi yo\"}"
> tgb-cli --download TOKEN --name x --id "AgADAgAD36gxGwWj2EuIQ9vvX_3kbh-cmg4ABDhqGLqV07c_phkBAAEC"
> tgb-cli --download --dir "./temp/" --id "AgADAgAD36gxGwWj2EuIQ9vvX_3kbh-cmg4ABDhqGLqV07c_phkBAAEC"
```
<a name="refSendFileAsBuffer"></a>

@@ -343,2 +313,23 @@ #### File as Buffer

<a name="refCLI"></a>
#### CLI
```js
> SET TELEGRAM_BOT_TOKEN=1:XXXX
> tgb-cli --method sendPhoto --d.chat_id 0 --d.photo "J://test.jpg"
> tgb-cli --method getMe -j
> tgb-cli --method getMe --token 0:XXXX
> tgb-cli --method getMe --token 0:XXXX --proxy "127.0.0.1:1337"
> tgb-cli --method sendMessage --data "{\"chat_id\":0,\"text\":\"Hi yo\"}"
> tgb-cli --method sendMessage --d.chat_id 1 --data "{\"chat_id\":0,\"text\":\"Hi yo\"}"
> tgb-cli --download TOKEN --name x --id "AgADAgAD36gxGwWj2EuIQ9vvX_3kbh-cmg4ABDhqGLqV07c_phkBAAEC"
> tgb-cli --download --dir "./temp/" --id "AgADAgAD36gxGwWj2EuIQ9vvX_3kbh-cmg4ABDhqGLqV07c_phkBAAEC"
```
#### Misc

@@ -417,2 +408,9 @@

#### Goals:
1. High stability;
2. Low memory usage;
3. Maximum performance;
4. Flexibility.
## License

@@ -419,0 +417,0 @@

@@ -352,9 +352,12 @@ //-----------------------------------------------------

pump(src, dest, function(error, ended) {
pump(src, dest, function(error, finished, closed) {
instance.removeListener("pause", cbPause);
instance.removeListener("resume", cbResume);
if(ended) {
if(finished) {
cbDoneNT();
}
else if(closed) {
request.destroy(new Error("The stream was closed before all expected data was received"));
}
});

@@ -400,3 +403,3 @@ }

if(sk) {
if(sk && !sk.destroyed) {
sk.cork();

@@ -412,11 +415,15 @@ request.corked = true;

if(request.corked) {
const sk = request.socket;
const unc = () => {
const sk = request.socket;
if(now) {
if(sk) {
if(sk && !sk.destroyed) {
sk.uncork();
}
};
if(now) {
unc();
}
else {
process.nextTick(() => sk && sk.uncork());
process.nextTick(unc);
}

@@ -423,0 +430,0 @@

@@ -22,3 +22,3 @@ //-----------------------------------------------------

(function() {
let key, name;
let key;

@@ -39,11 +39,3 @@ //------------]>

key = null;
name = arg.replace(/^-+/, "");
if(arg[1] === "-") {
key = name;
}
else {
setOpt(name, true);
}
key = arg.replace(/^-+/, "");
}

@@ -50,0 +42,0 @@ else if(key) {

@@ -47,6 +47,9 @@ //-----------------------------------------------------

pump(response, ws, function(error, ended) {
pump(response, ws, function(error, finished, closed) {
if(error) {
reject(error);
}
else if(!finished) {
reject(new Error("The stream was closed before all expected data was received"));
}
else {

@@ -53,0 +56,0 @@ ws.end(function() {

@@ -81,5 +81,9 @@ //-----------------------------------------------------

abort() {
this.__destroy();
this.__aborted = true;
this.emit("abort");
if(!this.__aborted) {
this.__destroy();
this.__aborted = true;
this.__pause = false;
this.emit("abort");
}
}

@@ -95,4 +99,6 @@

pause() {
this.__pause = true;
this.emit("pause");
if(!this.aborted) {
this.__pause = true;
this.emit("pause");
}
}

@@ -197,2 +203,3 @@ }

response
.on("aborted", obAbort)
.on("error", onResponseError)

@@ -199,0 +206,0 @@ .on("data", onResponseData)

@@ -144,6 +144,9 @@ //-----------------------------------------------------

})
.once("end", function() {
.once("close", function() {
src.destroy();
done(null, true);
done(null, false, true);
})
.once("end", function() {
done(null, true, false);
})

@@ -154,7 +157,7 @@ .pipe(dest, pumpPipeOpts)

src.destroy();
done(null, false);
done(null, false, false);
})
.once("error", function(error) {
src.destroy();
done(error, false);
done(error, false, false);
});

@@ -161,0 +164,0 @@

@@ -306,4 +306,1 @@ //-----------------------------------------------------

}
//-----------------------------------------------------
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