npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

telegramds

v1.2.7

Published

Fast and efficient way of storing data to telegram with multiple capabilities

Downloads

41

Readme

TelegramDS

This package allows you to use telegram's API to store, retrieve and delete data securely between you and the bot or a group

Install: npm i telegramds

Encryption Method: AES-CBC-256

  • [x] Cached Data - retrieve data faster, data in the cache is still encrypted.
  • [x] Data Encryption - you don't have to worry about ur files being decrypted.
  • [x] Store Objects, Images and Videos

Initialization

Firstly, Create a Telegram Bot

const telegramds = require("telegramds");
const telegramBotToken = "xxxxxx:xxxxxxxxxxxxxx"; // create a bot on telegram and replace the varbiable with ur bot token
const customPassphrase = "ANYTHING, BUT MUST BE SECURE"; // should not be any longer than 64 characters

const config = telegramds.genconfig(customPassphrase, telegramBotToken); // ur config will be outputted to the console in json
console.log(config); // copy the config for future uses

telegramds.run(JSON.parse(config), __dirname);

#1: After running this script, text your bot on telegram /chatid

#2: It should respond with a positive or sometimes negative number.

#3: Copy this number and put it as the "chatid" field in ur config.

#4: Store your config in a JSON file and require it whenever using, Example:

const telegramds = require("telegramds");
const config = require("PATH_TO_JSON_FILE");
telegramds.run(config, __dirname, function(){
    console.log("TelegramDS bot online!");
});

// Access the Datastore
const ds = telegramds.ds; // Scroll down to see functions

// Access the BOT
const bot = telegramds.bot;
// bot.on(text<string/regex>, (...) => {});
// bot.onText(text<regex/regex>, (msg<{}>, match<{}>) => {});
// bot.sendMessage(chatid<number/string>, <string>);
// documentation: https://www.npmjs.com/package/node-telegram-bot-api

Functions

|Functions Usage with Types|Return Type| Type | |--|--|--| |ds.set(id<string>, data<any>)**| boolean | async |ds.get(id<string>)| any |async |ds.del(id<string>)| boolean |async |ds.exist(id<string>)| boolean |non-async |ds.getAll()| object | async



const fs = require("fs");
const bot = telegramds.bot;
const ds = telegramds.ds;
const config = require("PATH_TO_JSON_FILE")
telegramds.run(config, __dirname, function(){
    console.log("TelegramDS bot online!");
}); // only run this 1 time

async function main() {   
 // Strings/Numbers
 await ds.set("test","hello");
 console.log(await ds.get("test")); // "hello"
 await ds.del("test"); // delete the data
 console.log(await ds.get("test")); // undefined
 
 // Objects
 await ds.set("eatit", {hi: true});
 console.log(await ds.get("eatit")); // {hi: true}
 await ds.del("eatit"); // delete the data
 console.log(await ds.get("eatit")); // undefined
 
 // Files
 let file = fs.readFileSync("./path/to/image.png"); // read the file
 // typeof(file) == "object";
 await ds.set("file", file.toString("hex"));
 console.log(Buffer.from(await ds.get("file"), "hex")); // <Buffer>
 
 /* Others */
 // Retrieve all data with their values [ could be slow if data is big ]
 let allData = ds.getAll();
 console.log(allData) // -> { "file": <Buffer> }
 
 // Checks if the data id/key exist without getting the actual data
 // Useful for when you want to check an id without waiting for the data
 let exist = ds.exist("example"); // <boolean>
 consol.log(exist);
}
main(); // Run the function