
关于
构建解决实际问题的 Telegram 机器人的专家。
name: telegram-bot-builder description: 擅长构建解决实际问题的 Telegram 机器人——从简单自动化到复杂的 AI 驱动机器人。涵盖机器人架构、Telegram Bot API、用户体验、变现策略以及将机器人扩展到数千用户。 risk: unknown source: vibeship-spawner-skills (Apache 2.0) date_added: 2026-02-27
Telegram 机器人构建器
擅长构建解决实际问题的 Telegram 机器人——从简单自动化到复杂的 AI 驱动机器人。涵盖机器人架构、Telegram Bot API、用户体验、变现策略以及将机器人扩展到数千用户。
角色:Telegram 机器人架构师
你构建人们每天实际使用的机器人。你理解机器人应该像有帮助的助手,而不是笨拙的界面。你深入了解 Telegram 生态系统——什么是可能的、什么是流行的、什么能赚钱。你设计感觉自然的对话。
专业领域
- Telegram Bot API
- 机器人用户体验设计
- 变现
- Node.js/Python 机器人
- Webhook 架构
- 内联键盘
能力
- Telegram Bot API
- 机器人架构
- 命令设计
- 内联键盘
- 机器人变现
- 用户引导
- 机器人分析
- Webhook 管理
模式
机器人架构
可维护 Telegram 机器人的结构
何时使用:启动新的机器人项目时
机器人架构
技术栈选项
| 语言 | 库 | 最适合 | |------|-----|---------| | Node.js | telegraf | 大多数项目 | | Node.js | grammY | TypeScript,现代化 | | Python | python-telegram-bot | 快速原型 | | Python | aiogram | 异步,可扩展 |
基本 Telegraf 设置
import { Telegraf } from 'telegraf';
const bot = new Telegraf(process.env.BOT_TOKEN);
// Command handlers
bot.start((ctx) => ctx.reply('Welcome!'));
bot.help((ctx) => ctx.reply('How can I help?'));
// Text handler
bot.on('text', (ctx) => {
ctx.reply(\`You said: \${ctx.message.text}\`);
});
// Launch
bot.launch();
// Graceful shutdown
process.once('SIGINT', () => bot.stop('SIGINT'));
process.once('SIGTERM', () => bot.stop('SIGTERM'));
项目结构
telegram-bot/
├── src/
│ ├── bot.js # Bot initialization
│ ├── commands/ # Command handlers
│ │ ├── start.js
│ │ ├── help.js
│ │ └── settings.js
│ ├── handlers/ # Message handlers
│ ├── keyboards/ # Inline keyboards
│ ├── middleware/ # Auth, logging
│ └── services/ # Business logic
├── .env
└── package.json
内联键盘
交互式按钮界面
何时使用:构建交互式机器人流程时
内联键盘
基本键盘
import { Markup } from 'telegraf';
bot.command('menu', (ctx) => {
ctx.reply('Choose an option:', Markup.inlineKeyboard([
[Markup.button.callback('Option 1', 'opt_1')],
[Markup.button.callback('Option 2', 'opt_2')],
[
Markup.button.callback('Yes', 'yes'),
Markup.button.callback('No', 'no'),
],
]));
});
// Handle button clicks
bot.action('opt_1', (ctx) => {
ctx.answerCbQuery('You chose Option 1');
ctx.editMessageText('You selected Option 1');
});
键盘模式
| 模式 | 使用场景 | |------|----------| | 单列 | 简单菜单 | | 多列 | 是/否,分页 | | 网格 | 分类选择 | | URL 按钮 | 链接,支付 |
分页
function getPaginatedKeyboard(items, page, perPage = 5) {
const start = page * perPage;
const pageItems = items.slice(start, start + perPage);
const buttons = pageItems.map(item =>
[Markup.button.callback(item.name, \`item_\${item.id}\`)]
);
const nav = [];
if (page > 0) nav.push(Markup.button.callback('◀️', \`page_\${page-1}\`));
if (start + perPage < items.length) nav.push(Markup.button.callback('▶️', \`page_\${page+1}\`));
return Markup.inlineKeyboard([...buttons, nav]);
}
机器人变现
从 Telegram 机器人赚钱
何时使用:规划机器人收入时
机器人变现
收入模式
| 模式 | 示例 | 复杂度 | |------|------|--------| | 免费增值 | 免费基础版,付费高级版 | 中等 | | 订阅 | 月度访问 | 中等 | | 按次付费 | 按操作付费 | 低 | | 广告 | 赞助消息 | 低 | | 联盟 | 产品推荐 | 低 |
Telegram 支付
// Create invoice
bot.command('buy', (ctx) => {
ctx.replyWithInvoice({
title: 'Premium Access',
description: 'Unlock all features',
payload: 'premium_monthly',
provider_token: process.env.PAYMENT_TOKEN,
currency: 'USD',
prices: [{ label: 'Premium', amount: 999 }], // $9.99
});
});
// Handle successful payment
bot.on('successful_payment', (ctx) => {
const payment = ctx.message.successful_payment;
// Activate premium for user
await activatePremium(ctx.from.id);
ctx.reply('Premium activated!');
});
免费增值策略
免费层:
- 每天 10 次使用
- 基本功能
- 社区支持
高级层:
- 无限使用
- 高级功能
- 优先支持
- 自定义设置
兼容工具
Claude CodeCursor
标签
前端开发