Skip to content

daniharo/grammy-calendar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grammy Calendar Menu

npm

WARNING: unstable. This is not completely stable yet. Please try it out and provide feedback, either by opening an issue or in the group chat.

This grammY plugin ports telegraf-calendar-telegram to the grammY framework.

Usage

import { Calendar, type CalendarContext, type CalendarOptions } from "grammy-calendar";
import { Bot } from "grammy";

type MyContext = Context & CalendarContext;
type SessionData = {
  calendarOptions: CalendarOptions;
}

const bot = new Bot<MyContext>("BOT-TOKEN");
bot.use(session({
  initial: () => ({ 
    calendarOptions: {} 
  })
}));
const calendarMenu = new Calendar<MyContext>(
  (ctx) => ctx.session.calendarOptions
);
bot.use(calendarMenu);

bot.on("message:text", async (ctx) => {
  ctx.session.calendarOptions = { defaultDate: new Date() };
  await ctx.reply("This is a calendar", { reply_markup: calendarMenu })
})
bot.filter((ctx) => !!ctx.calendarSelectedDate, async (ctx) => {
  const dateText = ctx.calendarSelectedDate!.toString()
  await ctx.reply(`You have selected this date: ${dateText}`)
})

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published