一键导入
using-telegram-bot
Build and run Telegram bots in Node.js using Telegraf with practical command patterns.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Build and run Telegram bots in Node.js using Telegraf with practical command patterns.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Upload and host files anonymously using decentralized storage with Originless and IPFS.
Automate web browsers for AI agents using agent-browser CLI with deterministic element selection.
Log all file changes (write, edit, delete) to a SQLite database for debugging and audit. Use when: (1) Tracking code changes, (2) Debugging issues, (3) Auditing file modifications, or (4) The user asks to track file changes.
Fetch current and historical crypto prices and compute ATH or ATL over common time windows.
Host static websites and assets via zip upload to Originless IPFS. Use when: (1) Deploying static sites, (2) Hosting HTML/CSS/JS projects, (3) Sharing web assets publicly, or (4) User asks to host static files.
Search for torrents by title or IMDB ID via a Torznab-compatible API. Use when: (1) User asks to find a torrent for a movie or show, (2) You need a magnet link for a given title, or (3) User provides an IMDB ID and wants download options.
| name | using-telegram-bot |
| description | Build and run Telegram bots in Node.js using Telegraf with practical command patterns. |
Short guide to build Telegram bots with telegraf (Node.js).
npm install telegrafBOT_TOKEN.// bot.js
const { Telegraf, Markup } = require('telegraf');
const bot = new Telegraf(process.env.BOT_TOKEN);
bot.start(ctx => ctx.reply('Welcome! I can help with commands.'));
bot.command('echo', ctx => {
const text = ctx.message.text.split(' ').slice(1).join(' ');
ctx.reply(text || 'usage: /echo your message');
});
bot.on('text', ctx => ctx.reply(`You said: ${ctx.message.text}`));
bot.launch();
process.once('SIGINT', () => bot.stop('SIGINT'));
process.once('SIGTERM', () => bot.stop('SIGTERM'));
Run:
BOT_TOKEN=123:ABC node bot.js
// send photo
await ctx.replyWithPhoto('https://example.com/image.jpg', { caption: 'Nice pic' });
// send document
await ctx.replyWithDocument('https://example.com/file.pdf');
// show inline buttons
await ctx.reply('Choose:', Markup.inlineKeyboard([
Markup.button.callback('OK', 'ok'),
Markup.button.callback('Cancel', 'cancel')
]));
bot.action('ok', ctx => ctx.reply('You pressed OK'));
bot.action('cancel', ctx => ctx.reply('Cancelled'));
const express = require('express');
const { Telegraf } = require('telegraf');
const bot = new Telegraf(process.env.BOT_TOKEN);
const app = express();
app.use(bot.webhookCallback('/telegraf'));
bot.telegram.setWebhook(`${process.env.PUBLIC_URL}/telegraf`);
app.listen(process.env.PORT || 3000);
Use webhooks for production deployments (faster, lower resource use).
bot.catch((err, ctx) => {
console.error('Bot error', err);
});
NODE_ENV=production and graceful shutdown hooks for reliability.This doc shows the most common Telegraf patterns: start/command handlers, text handlers, media, inline buttons, webhook setup, and error handling.