1.0.5 • Published 11 days ago
telegramds v1.0.5
Create a telegram bot: https://www.directual.com/lesson-library/how-to-create-a-telegram-bot
In order to use the module, you must generate a config
const telegramds = require("telegramds")
const telegramBotToken = "xxxxxx:xxxxxxxxxxxxxx" // create a bot on telegram and replace the varbiable with ur bot token
const customPassphrase = "ANyTHING YOU WANT" // 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)
After running this script, go to telegram and dm your bot "/chatid"
It should respond with a number, copy this number and put it as the "chatid" field in ur config its a number, not a string
Now, copy ur config and use it everytime you want to run the DS, example:
const telegramds = require("telegramds")
telegramds.run({/* YOUR CONFIGURATION */}, __dirname, function(){
console.log("Telegram bot online!")
});
(async() =>{
// Saving a string
await telegramds.save("string", "content of the string here", "mycustomstring")
console.log(await telegramds.get("mycustomstring")) // "content of the string here"
// Deleting data
await telegramds.del("mycustomstring")
console.log(await telegramds.get("mycustomstring")) // null
// to access the bot:
const bot = telegramds.bot
// bot.on
// bot.sendMessage
// documentation for bot: https://www.npmjs.com/package/node-telegram-bot-api
})();
Saving methods:
"string" | Supports string
"gif" <filepath: string | Binary> | Supports .gif
"image" <filepath: string | Binary> | Supports .png, .jpg, .jpeg - any image file
"doc" <filepath: string | Binary> | Supports .txt, .lua - any other text file