![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
tgb
Advanced tools
Readme
npm -g install tgb
git clone https://github.com/Daeren/tgb.git
await require("tgb")("T", "sendmessage", [0, "+"], proxy)
await require("tgb").sendMessage("T", {chat_id: 0, text: "+"}, proxy)
- All methods in the Bot API are case-insensitive (.buffer, .json, .require)
- message: buffer, stream, string
- location|venue|contact: buffer, stream, string
- photo|audio|voice|video|document|sticker|video_note: buffer, stream, path, url, file_id
- certificate: buffer, stream, path, url
const tgb = require("tgb");
const bot = tgb(process.env.TELEGRAM_BOT_TOKEN);
const {polling, entities} = tgb;
//-----------------------------------------------------
polling(
bot.token,
function({message}) {
bot.sendMessage([message.from.id, entities(message)]);
})
.catch(function(error) {
if(error.code === bot.ERR_INVALID_TOKEN) {
this.stop();
console.log("There's a problem with the token...");
}
else {
delete error.response;
console.log(error);
}
});
// > send: tg @gamebot /start x http://db.gg
const tgb = require("tgb");
const bot = tgb(process.env.TELEGRAM_BOT_TOKEN);
const {download} = tgb;
const fileId = "AgADAgAD36gxGwWj2EuIQ9vvX_3kbh-cmg4ABDhqGLqV07c_phkBAAEC";
//-----------------------------------------------------
void async function () {
await download(bot.token, fileId);
}();
const bot = tgb(process.env.TELEGRAM_BOT_TOKEN);
void async function () {
bot.proxy = "127.0.0.1:1337"; // Only HTTPS
try {
await bot.getMe();
await bot.getMe(null, "0.0.0.0:1337");
} catch(e) {
console.log(e);
}
}();
void async function () {
const bot = tgb(process.env.TELEGRAM_BOT_TOKEN);
const params = {"chat_id": "0", "audio": "O://1.mp3"};
const [res, req] = bot.sendAudio(params);
setTimeout(() => {
req.pause();
}, 500);
setTimeout(() => {
req.resume();
}, 2500);
setTimeout(() => {
req.abort();
}, 4500);
console.log(await res);
console.log(req.ended, req.aborted, req.paused);
}();
const bot = tgb(process.env.TELEGRAM_BOT_TOKEN);
// You
bot.sendPhoto({
"chat_id": "0",
"photo": "https://avatars0.githubusercontent.com/u/5007624"
});
// Tg
bot.sendPhoto({
"chat_id": "0",
"photo": "tg+https://avatars0.githubusercontent.com/u/5007624"
});
/*
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.
*/
> 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\"}"
const fs = require("fs");
const bot = tgb(process.env.TELEGRAM_BOT_TOKEN);
bot.sendMediaGroup({
"chat_id": "59725308",
"media": [
{"type": "photo","media": "O://test.jpg"},
{"type": "photo","media": fs.createReadStream("O://test.jpg")},
{"type": "photo","media": ["test.jpg", fs.readFileSync("O://test.jpg")]},
{"type": "photo","media": "AgADAgAD36gxGwWj2EuIQ9vvX_3kbh-cmg4ABDhqGLqV07c_phkBAAEC"},
{"type": "photo","media": "tg+https://avatars0.githubusercontent.com/u/5007624"},
{"type": "photo","media": "https://avatars0.githubusercontent.com/u/5007624"},
]
});
/*
tgb = require("tgb");
-
tgb.buffer(proxy, token, method, data, callback(error, buf, res))
tgb.json(proxy, token, method, data, callback(error, buf, res))
-
tgb.polling(token, onMessage(data));
tgb.polling(token, options{limit, timeout, interval}, onMessage(data));
await tgb.download(token, fileId[, dir = "./", filename = ""]);
-
x = tgb(token);
x.token; // Read|Write
x.proxy; // Read|Write
await x.method([data, proxy]);
await x(method[, data, proxy]);
-
await tgb(token, method[, data, proxy]);
client = await tgb(token, method[, data, proxy]);
[client, request] = await tgb(token, method[, data, proxy]);
client.request === request;
~~~
error.code = data.error_code;
error.retryAfter = data.parameters.retry_after;
error.migrateToChatId = data.parameters.migrate_to_chat_id;
https://core.telegram.org/bots/api#responseparameters
~~~ Sys Code |
EBADPROXY
EBADREQUEST
EBADDATA
EWCMAXSIZE
EWCLONGREDIRECT
~~~ Tg Code |
tgb.ERR_INTERNAL_SERVER
tgb.ERR_NOT_FOUND
tgb.ERR_FORBIDDEN
tgb.ERR_MESSAGE_LIMITS
tgb.ERR_USED_WEBHOOK
tgb.ERR_INVALID_TOKEN
*/
Me? Him? Me? You? Me? ... Him? Me ... npm -g i tgb
.... Whaat is Love ♫•¨•.¸¸♪
MIT
FAQs
The best choice for your Telegram Bots
The npm package tgb receives a total of 0 weekly downloads. As such, tgb popularity was classified as not popular.
We found that tgb demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.