Alpha
The project is currently in development (but it can already be used)
This command will help you create a project with GramIO (and ORM, linters and plugins) the easiest way.
npm create gramio@latest ./bot
yarn create gramio@latest ./bot
pnpm create gramio@latest ./bot
bun create gramio@latest ./bot
TODO://
For more information, see the «Get started» section.
Example which uses some interesting features.
import { Bot, format, bold, code } from "gramio";
import { findOrRegisterUser } from "./utils";
const bot = new Bot(process.env.BOT_TOKEN as string)
.derive("message", async () => {
const user = await findOrRegisterUser();
return {
user,
};
})
.on("message", (context) => {
context.user;
//
//
//
//
//
//
//
return context.send(format`
Hi, ${bold(context.user.name)}!
You balance: ${code(context.user.balance)}`);
})
.on("callback_query", (context) => {
//
//
context.user; });