Skip to main content
Deno 2 is finally here 🎉️
Learn more

Requires “BOT_TOKEN” environment variable

import { App, AppContext } from "https://deno.land/x/grammy_app/mod.ts"
import { Composer } from "https://deno.land/x/grammy/mod.ts"

interface Session {
  count: number
}

type Context = AppContext<Session>
const defaultSession: Session = { count: 0 }
const app = new App(defaultSession)
const handler = new Composer<Context>()

handler.on("msg", (ctx) => {
  const count = ++ctx.session.count
  return ctx.r(`${count}`)
})

app.run(handler)