Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
teletron-ts
Advanced tools
Readme
Fast and Flexible Telegram Bot API Framework for Node.js written in TypeScript.
npm i teletron-ts
import * as telegram from "teletron-ts";
import { TelegramAPI } from "teletron-ts"; // Individual classes
const telegram = require("teletron-ts");
const { TelegramAPI } = require("teletron-ts"); // Individual classes
import { TelegramAPI } from "teletron-ts";
const telegram = new TelegramAPI("token"); // bot token api
// listen for the message event
telegram.onMessage(async (message) => {
if (message.text === "Hi bot!")
await telegram.sendMessage(message.chat.id, "Hi there, human!"); // sendMessage will return an instance of IMessage
});
// OR
telegram.on("message", async (message) => {
if (message.text === "Hi bot!")
await telegram.sendMessage(message.chat.id, "Hi there, human!"); // sendMessage will return an instance of IMessage
});
// fetch new updates from the api
telegram.startPolling();
Events you can listen to usign teletron-ts
:
Please note that both inline_query
and chosen_inline_result
only work if you enabled this option by sending /setinline
to @BotFather
For more information regarding inline queries visit the telegram docs here
There are 3 ways to send files. You can use the file id of a file that already exist on telegram servers, provide an HTTP URL to the file which then will be downloaded by telegram servers or upload a local file. Lets assume we want to send a photo via the bot:
import { TelegramAPI } from "teletron-ts";
const telegram = new TelegramAPI("token"); // bot token
telegram.on("message", async (message) => {
// First Method: Using an already existing file_id of a file that has been previously uploaded on telegram
await telegram.sendPhoto(
message.chat.id,
"AgADBQADqacxG2gbbxCWBkgvcmeAgxVPyjIABBlug37DKyhDEU0AAgI"
);
// Second Method: Using an HTTP photo url
await telegram.sendPhoto(
message.chat.id,
"https://reshape.sport1.de/c/t/85599615-c80d-47f0-9179-4375d6e4fa93/976x549"
);
// Thrid Method: Using a local file
await telegram.sendPhoto(message.chat.id, { file: "./anime.jpg" });
});
// fetch updates from the api
telegram.startPolling();
Inline keyboards are buttons that will be sent along with the message. These become especially useful if you want to wait for user input to perform certain action!
import { TelegramAPI } from "teletron-ts";
import { IInlineKeyboardMarkup } from "teletron-ts";
const telegram = new TelegramAPI("token");
telegram.on("message", async (m) => {
const inlineKeyboards: IInlineKeyboardMarkup = {
inline_keyboard: [
[
{ text: "Very Good!", callback_data: "vgood" },
{ text: "Fine", callback_data: "fine" },
],
[{ text: "Amazing", callback_data: "amazing" }],
],
};
await telegram.sendMessage(
m.chat.id,
"Hey there, how are you feeling today?",
{
reply_markup: JSON.stringify(inlineKeyboards),
}
);
});
telegram.on("callback_query", async (query) => {
if (query.data && query.data === "vgood")
return await telegram.sendMessage(
query.message.chat.id,
"I am feeling very good today too!"
);
});
Software contributions are welcome. If you are not a dev, testing and reproting bugs can also be very helpful!
Please open an issue if you have questions, wish to request a feature, etc.
FAQs
Fast and Flexible Telegram Bot API Framework for Node.js written in TypeScript.
The npm package teletron-ts receives a total of 1 weekly downloads. As such, teletron-ts popularity was classified as not popular.
We found that teletron-ts 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.