Skip to content

grammY

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

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

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

bot.start();

运行成功! 🎉


© 2021-2024 · grammY 支持 Telegram Bot API 7.2,该 API 于 2024 年 3 月 31 日 发布。 (新增: 集成企业账号)