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.38.1/mod.ts";

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

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

bot.start();

运行成功! 🎉


contributor's identiconroziscoding

感谢 Roz 成为 grammY 的贡献者。

© 2021-2025 · grammY 支持 Telegram Bot API 9.2,该 API 于 2025 年 8 月 15 日 发布。 (最新亮点: 私信频道和推荐帖子)