Socket
Socket
Sign inDemoInstall

grammy-calendar

Package Overview
Dependencies
13
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    grammy-calendar

Calendar menu for grammY


Version published
Weekly downloads
4
decreased by-20%
Maintainers
1
Install size
328 kB
Created
Weekly downloads
 

Readme

Source

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}`)
})

Keywords

FAQs

Last updated on 31 Jul 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc