Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
latest
phaux/tinygramTiny (smol) Telegram Bot API client library with TypeScript types
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers




JSR Score
100%
Published
2 months ago (3.0.0)
Main Telegram Bot API client module.
To begin, initialize your bot with initTgBot.
Reply to private commands.
Reply to private commands.
const bot = initTgBot({ botToken: "YOUR_TOKEN" }); for await (const update of bot.listUpdates()) { if (update.message) { const { chat, text, message_id, from } = update.message; if (chat.type === "private" && text?.startsWith("/start")) { await bot.sendMessage({ chat_id: chat.id, reply_parameters: { message_id }, text: `Hello, ${from?.first_name}!` }); } } }
Say hello when added to a group.
Say hello when added to a group.
const bot = initTgBot({ botToken: "YOUR_TOKEN" }); for await (const update of bot.listUpdates()) { if (update.my_chat_member) { const { chat, new_chat_member } = update.my_chat_member; if ( (chat.type === "group" || chat.type === "supergroup") && (new_chat_member.status === "member" || new_chat_member.status === "administrator") ) { await bot.sendMessage({ chat_id: chat.id, text: "Hello, everyone!" }); } } }
Download and show/save bot's profile photo.
Download and show/save bot's profile photo.
/// <reference lib="dom" /> import { writeFile } from "node:fs/promises" const bot = initTgBot({ botToken: "YOUR_TOKEN" }); // Download bot's profile photo const botUser = await bot.getMe(); const botPhoto = await bot.getUserProfilePhotos({ user_id: botUser.id }); const botPhotoFileId = botPhoto.photos[0]?.[0]?.file_id; if (botPhotoFileId == null) throw new Error("No profile photo"); const botPhotoFile = await bot.getFile({ file_id: botPhotoFileId }); if (botPhotoFile.file_path == null) throw new Error("Photo file unavailable"); const botPhotoBlob = await bot.getFileData(botPhotoFile.file_path); // Save to file await writeFile("bot.jpg", botPhotoBlob.stream()); // Set as img src const img = document.createElement("img"); img.src = URL.createObjectURL(botPhotoBlob);
Built and signed on
GitHub Actions
Add Package
deno add jsr:@smol/gram
Import symbol
import * as gram from "@smol/gram";
Import directly with a jsr specifier
import * as gram from "jsr:@smol/gram";
Add Package
pnpm i jsr:@smol/gram
pnpm dlx jsr add @smol/gram
Import symbol
import * as gram from "@smol/gram";
Add Package
yarn add jsr:@smol/gram
yarn dlx jsr add @smol/gram
Import symbol
import * as gram from "@smol/gram";
Add Package
vlt install jsr:@smol/gram
Import symbol
import * as gram from "@smol/gram";
Add Package
npx jsr add @smol/gram
Import symbol
import * as gram from "@smol/gram";
Add Package
bunx jsr add @smol/gram
Import symbol
import * as gram from "@smol/gram";