-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbin.ts
83 lines (63 loc) · 1.76 KB
/
bin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { Dayjs } from 'dayjs';
import { Telegraf } from 'telegraf';
import MonthPicker from './month';
import DayPicker from './day';
const TOKEN = ''
const bot = new Telegraf(TOKEN);
// combined example
// month picker
// const monthPicker = new MonthPicker(bot);
// monthPicker.on('click', (ctx, date) => {
// console.log('click to date', date);
// ctx.reply('you choose' + (date as Dayjs).format('MM/YYYY'));
// });
// monthPicker.on('next', (ctx, date) => {
// console.log('next year', date);
// ctx.reply('next year' + (date as Dayjs).format('YYYY'));
// });
// monthPicker.on('prev', (ctx, date) => {
// console.log('prev year', date);
// ctx.reply('prev year' + (date as Dayjs).format('YYYY'));
// });
// bot.command('month', ctx => {
// ctx.reply('pick month', {
// reply_markup: {
// inline_keyboard: monthPicker.render()
// }
// })
// })
// day picker example
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 ' + (date as Dayjs).format('MMMM'));
});
picker.on('prev', (ctx, date) => {
ctx.reply('prev month is ' + (date as Dayjs).format('MMMM'));
});
bot.command('calendar', (ctx) => {
ctx.reply('Pick Date', {
reply_markup: {
// inline_keyboard: picker.render(),
keyboard: picker.render(),
},
});
});
bot.command('start', ctx => {
ctx.reply('Hello!. You can write "/calendar" command and pick a future date')
})
bot.launch();