Skip to content

grammY

Telegram Bot 框架。

愉快地创建 bot。

grammY 徽标

快速开始

bot 是用 TypeScript(或JavaScript)编写的,并在各种平台上运行,包括 Node.js

npm install grammy 并粘贴以下代码:

ts
import { Bot } from "grammy";

const bot = new Bot(""); // <-- 把你的 bot token 放在 "" 之间 (https://t.me/BotFather)

// 用"你好!"来回复任意信息
bot.on("message", (ctx) => ctx.reply("你好!"));

bot.start();
js
const { Bot } = require("grammy");

const bot = new Bot(""); // <-- 把你的 bot token 放在 "" 之间 (https://t.me/BotFather)

// 用"你好!"来回复任意信息
bot.on("message", (ctx) => ctx.reply("你好!"));

bot.start();
ts
import { Bot } from "https://deno.land/x/grammy@v1.35.0/mod.ts";

const bot = new Bot(""); // <-- 把你的 bot token 放在 "" 之间 (https://t.me/BotFather)

// 用"你好!"来回复任意信息
bot.on("message", (ctx) => ctx.reply("你好!"));

bot.start();

运行成功! 🎉


contributor's identiconmahovich

感谢 mahovich 成为 grammY 的贡献者。

© 2021-2025 · grammY 支持 Telegram Bot API 8.2,该 API 于 2025 年 1 月 1 日 发布。 (最新亮点: 聊天和用户验证)