Socket
Socket
Sign inDemoInstall

telegram-inline-calendar

Package Overview
Dependencies
1
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.0 to 1.5.0

2

package.json
{
"name": "telegram-inline-calendar",
"version": "1.4.0",
"version": "1.5.0",
"description": "Date and time picker and Inline calendar for Node.js telegram bots",

@@ -5,0 +5,0 @@ "main": "./index.js",

@@ -32,3 +32,3 @@ <h1 align="center">telegram-inline-calendar</h1>

* [telebot](https://github.com/mullwar/telebot)
* [grammy](https://github.com/grammyjs/grammY)
* [grammY](https://github.com/grammyjs/grammY)

@@ -130,3 +130,3 @@ ## 📦 Install

### grammy
### grammY
```js

@@ -144,9 +144,9 @@ const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN';

bot.command('start', ctx => calendar.startNavCalendar(ctx.message))
bot.command('start', ctx => calendar.startNavCalendar(ctx.msg))
bot.on("callback_query:data", (ctx) => {
if (ctx.update.callback_query.message.message_id == calendar.chats.get(ctx.update.callback_query.message.chat.id)) {
res = calendar.clickButtonCalendar(ctx.update.callback_query);
bot.on("callback_query:data", async (ctx) => {
if (ctx.msg.message_id === calendar.chats.get(ctx.chat.id)) {
res = calendar.clickButtonCalendar(ctx.callbackQuery);
if (res !== -1) {
bot.api.sendMessage(ctx.update.callback_query.message.chat.id, "You selected: " + res);
await ctx.reply("You selected: " + res);
}

@@ -170,2 +170,4 @@ }

time_step: "30m" //Time step in the format "<Time step><m | h>"
start_date: false, //Minimum date of the calendar in the format "YYYY-MM-DD"
stop_date: false //Maximum date of the calendar in the format "YYYY-MM-DD"
}

@@ -172,0 +174,0 @@ ```

@@ -15,2 +15,4 @@ const lang = require("./language.json");

this.options.time_step = (typeof options.time_step === 'undefined') ? "30m" : options.time_step;
this.options.start_date = (typeof options.start_date === 'undefined') ? false : options.start_date;
this.options.stop_date = (typeof options.stop_date === 'undefined') ? false : options.stop_date;
this.bot = bot;

@@ -223,5 +225,21 @@ this.chats = new Map();

cnk.inline_keyboard.push([{},{},{}]);
cnk.inline_keyboard[0][0] = {text: '<<', callback_data: 'n_' + dayjs(date).format("YYYY-MM") + '_--'};
if (!this.options.start_date || (this.options.start_date && dayjs(date).format('YYYY') > dayjs(this.options.start_date).format('YYYY'))) {
if (dayjs(date).subtract(1, 'year').format('YYYY') == dayjs(this.options.start_date).format('YYYY')) {
cnk.inline_keyboard[0][0] = {text: '<<', callback_data: 'n_' + dayjs(this.options.start_date).add(1, 'year').format("YYYY-MM") + '_--'};
} else {
cnk.inline_keyboard[0][0] = {text: '<<', callback_data: 'n_' + dayjs(date).format("YYYY-MM") + '_--'};
}
} else {
cnk.inline_keyboard[0][0] = {text: ' ', callback_data: ' '};
}
cnk.inline_keyboard[0][1] = {text: lang.month3[this.options.language][date.getMonth()] + ' ' + date.getFullYear(), callback_data: ' '};
cnk.inline_keyboard[0][2] = {text: '>>', callback_data: 'n_' + dayjs(date).format("YYYY-MM") + '_++'};
if (!this.options.stop_date || (this.options.stop_date && dayjs(this.options.stop_date).format('YYYY') > dayjs(date).format('YYYY'))) {
if (dayjs(date).add(1, 'year').format('YYYY') == dayjs(this.options.stop_date).format('YYYY')) {
cnk.inline_keyboard[0][2] = {text: '>>', callback_data: 'n_' + dayjs(this.options.stop_date).subtract(1, 'year').format("YYYY-MM") + '_++'};
} else {
cnk.inline_keyboard[0][2] = {text: '>>', callback_data: 'n_' + dayjs(date).format("YYYY-MM") + '_++'};
}
} else {
cnk.inline_keyboard[0][2] = {text: ' ', callback_data: ' '};
}
cnk.inline_keyboard.push([{},{},{},{},{},{},{}]);

@@ -238,3 +256,7 @@ for(j = 0; j < 7; j++) {

} else {
cnk.inline_keyboard[i][j] = {text: d, callback_data: 'n_' + date.getFullYear() + '-' + this.twoDigits(date.getMonth() + 1) + '-' + this.twoDigits(d) + '_0'};
if ((!this.options.start_date || (this.options.start_date && dayjs(date).date(d).hour(0).diff(dayjs(this.options.start_date).hour(0), 'day') >= 0)) && (!this.options.stop_date || (this.options.stop_date && dayjs(this.options.stop_date).hour(0).diff(dayjs(date).date(d).hour(0), 'day') >= 0))) {
cnk.inline_keyboard[i][j] = {text: d, callback_data: 'n_' + date.getFullYear() + '-' + this.twoDigits(date.getMonth() + 1) + '-' + this.twoDigits(d) + '_0'};
} else {
cnk.inline_keyboard[i][j] = {text: ' ', callback_data: ' '};
}
d++;

@@ -245,5 +267,13 @@ }

cnk.inline_keyboard.push([{},{},{}]);
cnk.inline_keyboard[cr - 1][0] = {text: '<', callback_data: 'n_' + dayjs(date).format("YYYY-MM") + '_-'};
if (!this.options.start_date || (this.options.start_date && Math.round(dayjs(date).date(1).diff(dayjs(this.options.start_date).date(1), 'month', true)) > 0)) {
cnk.inline_keyboard[cr - 1][0] = {text: '<', callback_data: 'n_' + dayjs(date).format("YYYY-MM") + '_-'};
} else {
cnk.inline_keyboard[cr - 1][0] = {text: ' ', callback_data: ' '};
}
cnk.inline_keyboard[cr - 1][1] = {text: ' ', callback_data: ' '};
cnk.inline_keyboard[cr - 1][2] = {text: '>', callback_data: 'n_' + dayjs(date).format("YYYY-MM") + '_+'};
if (!this.options.stop_date || (this.options.stop_date && Math.round(dayjs(this.options.stop_date).date(1).diff(dayjs(date).date(1), 'month', true)) > 0)) {
cnk.inline_keyboard[cr - 1][2] = {text: '>', callback_data: 'n_' + dayjs(date).format("YYYY-MM") + '_+'};
} else {
cnk.inline_keyboard[cr - 1][2] = {text: ' ', callback_data: ' '};
}
return cnk;

@@ -250,0 +280,0 @@ }

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