Skip to main content

Day picker

Provides an API for day of the month.

demo.ts
import {Telegraf} from 'telegraf';
import {DayPicker} from '@tlgr/date-picker';

const picker = new DayPicker(bot, {
controls: {
empty: { symbol: '💀' },
},
showPast: false,
mode: 'edit'
});


picker.on('click', (ctx, date) => {
ctx.reply('You selected ' + date.toLocaleString());
});

picker.on('day', (ctx, date) => {
ctx.reply('day event ' + date);
});
picker.on('weekday', (ctx, weekday) => {
ctx.reply('weekday event: ' + weekday);
});

picker.on('next', (ctx, date) => {
ctx.reply('next month is ' + dayjs(date).format('MMMM'));
});

picker.on('prev', (ctx, date) => {
ctx.reply('prev month is ' + dayjs(date).format('MMMM'));
});

bot.command('calendar', (ctx) => {
// when user types /calendar command - bot reply text with calendar.
ctx.reply('Pick Date', {
reply_markup: {
inline_keyboard: picker.render(),
},
});
});

bot.command('start', ctx => {
ctx.reply('Hello!. You can write "/calendar" command and pick a future date')
});

bot.launch();

Demo​

day demo