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.3.3 to 1.4.0

3

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

@@ -22,2 +22,3 @@ "main": "./index.js",

"telegraf",
"grammy",
"telebot",

@@ -24,0 +25,0 @@ "node-telegram-bot-api",

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

[![npm package](https://img.shields.io/npm/v/telegram-inline-calendar?logo=npm&style=flat-square)](https://www.npmjs.org/package/telegram-inline-calendar)
[![npm download](https://img.shields.io/npm/dm/telegram-inline-calendar)](https://www.npmjs.org/package/telegram-inline-calendar)
[![https://t.me/vds_13](https://img.shields.io/badge/💬%20Telegram-VDS13-blue.svg?style=flat-square)](https://t.me/vds_13)
[![npm download](https://img.shields.io/npm/dt/telegram-inline-calendar)](https://www.npmjs.org/package/telegram-inline-calendar)

@@ -34,2 +33,3 @@ </div>

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

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

bot.start((ctx) => calendar.startNavCalendar(ctx));
bot.start((ctx) => calendar.startNavCalendar(ctx.message));

@@ -132,2 +132,28 @@ bot.on("callback_query", (ctx) => {

### grammy
```js
const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN';
const { Bot } = require('grammy');
const NavCalendar = require('telegram-inline-calendar')
const bot = new Bot(TOKEN);
const calendar = new NavCalendar(bot, {
date_format: 'DD-MM-YYYY',
language: 'en',
bot_api: 'grammy'
});
bot.command('start', ctx => calendar.startNavCalendar(ctx.message))
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);
if (res !== -1) {
bot.api.sendMessage(ctx.update.callback_query.message.chat.id, "You selected: " + res);
}
}
});
bot.start();
```
## ⚙️ Default options

@@ -144,3 +170,3 @@

time_range: "00:00-23:59", //Allowed time range in "HH:mm-HH:mm" format
time_step: "30m" //Time step in the format "\<Time step\>\<m \| h\>"
time_step: "30m" //Time step in the format "<Time step><m | h>"
}

@@ -147,0 +173,0 @@ ```

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

this.bot.deleteMessage(query.message.chat.id,query.message.message_id)
},
replyMarkupObject(cnk) {
var menu = {};
menu.reply_markup = cnk;
return menu;
}

@@ -54,2 +59,7 @@ };

this.bot.telegram.deleteMessage(query.message.chat.id,query.message.message_id)
},
replyMarkupObject(cnk) {
var menu = {};
menu.reply_markup = cnk;
return menu;
}

@@ -59,8 +69,6 @@ };

editMessageReplyMarkupCalendar(date, query) {
var menu = {replyMarkup: this.createNavigationKeyboard(date)};
this.bot.editMessageReplyMarkup({messageId: query.message.message_id, chatId: query.message.chat.id}, menu);
this.bot.editMessageReplyMarkup({messageId: query.message.message_id, chatId: query.message.chat.id}, this.replyMarkupObject(this.createNavigationKeyboard(date)));
},
editMessageReplyMarkupTime(date, query, from_calendar) {
var menu = {replyMarkup: this.createTimeSelector(date, from_calendar)};
this.bot.editMessageReplyMarkup({messageId: query.message.message_id, chatId: query.message.chat.id}, menu);
this.bot.editMessageReplyMarkup({messageId: query.message.message_id, chatId: query.message.chat.id}, this.replyMarkupObject(this.createTimeSelector(date, from_calendar)));
},

@@ -76,4 +84,33 @@ sendMessageCalendar(menu, msg) {

this.bot.deleteMessage(query.message.chat.id,query.message.message_id)
},
replyMarkupObject(cnk) {
var menu = {};
menu.replyMarkup = cnk;
return menu;
}
};
Grammy = {
editMessageReplyMarkupCalendar(date, query) {
this.bot.api.editMessageReplyMarkup(query.message.chat.id, query.message.message_id, this.replyMarkupObject(this.createNavigationKeyboard(date)));
},
editMessageReplyMarkupTime(date, query, from_calendar) {
this.bot.api.editMessageReplyMarkup(query.message.chat.id, query.message.message_id, this.replyMarkupObject(this.createTimeSelector(date, from_calendar)));
},
sendMessageCalendar(menu, msg) {
var l = (this.options.time_selector_mod === true) ? lang.selectdatetime[this.options.language] : lang.select[this.options.language];
this.bot.api.sendMessage(msg.chat.id, l, menu).then((msg_promise) => this.chats.set(msg_promise.chat.id, msg_promise.message_id));
},
sendMessageTime(menu, msg) {
this.bot.api.sendMessage(msg.chat.id, lang.selecttime[this.options.language], menu).then((msg_promise) => this.chats.set(msg_promise.chat.id, msg_promise.message_id))
},
deleteMessage(query) {
this.bot.api.deleteMessage(query.message.chat.id,query.message.message_id)
},
replyMarkupObject(cnk) {
var menu = {};
menu.reply_markup = cnk;
return menu;
}
};
libraryInitialization() {

@@ -86,2 +123,3 @@ if (this.options.bot_api == 'node-telegram-bot-api') {

this.deleteMessage = this.NodeTelegramBotApi.deleteMessage;
this.replyMarkupObject = this.NodeTelegramBotApi.replyMarkupObject;
} else if (this.options.bot_api == 'telegraf') {

@@ -93,2 +131,3 @@ this.editMessageReplyMarkupCalendar = this.Telegraf.editMessageReplyMarkupCalendar;

this.deleteMessage = this.Telegraf.deleteMessage;
this.replyMarkupObject = this.Telegraf.replyMarkupObject;
} else if (this.options.bot_api == 'telebot') {

@@ -100,2 +139,10 @@ this.editMessageReplyMarkupCalendar = this.Telebot.editMessageReplyMarkupCalendar;

this.deleteMessage = this.Telebot.deleteMessage;
this.replyMarkupObject = this.Telebot.replyMarkupObject;
} else if (this.options.bot_api == 'grammy') {
this.editMessageReplyMarkupCalendar = this.Grammy.editMessageReplyMarkupCalendar;
this.editMessageReplyMarkupTime = this.Grammy.editMessageReplyMarkupTime;
this.sendMessageCalendar = this.Grammy.sendMessageCalendar;
this.sendMessageTime = this.Grammy.sendMessageTime;
this.deleteMessage = this.Grammy.deleteMessage;
this.replyMarkupObject = this.Grammy.replyMarkupObject;
}

@@ -213,16 +260,6 @@ }

now.setSeconds(0);
var menu = {};
if (this.options.bot_api === 'telebot')
menu.replyMarkup = this.createNavigationKeyboard(now);
else
menu.reply_markup = this.createNavigationKeyboard(now);
this.sendMessageCalendar(menu, msg);
this.sendMessageCalendar(this.replyMarkupObject(this.createNavigationKeyboard(now)), msg);
}
startTimeSelector(msg) {
var menu = {};
if (this.options.bot_api === 'telebot')
menu.replyMarkup = this.createTimeSelector();
else
menu.reply_markup = this.createTimeSelector();
this.sendMessageTime(menu, msg);
this.sendMessageTime(this.replyMarkupObject(this.createTimeSelector()), msg);
}

@@ -229,0 +266,0 @@ clickButtonCalendar(query) {

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