telegram-inline-calendar
Advanced tools
Comparing version 1.6.1 to 1.6.2
{ | ||
"name": "telegram-inline-calendar", | ||
"version": "1.6.1", | ||
"version": "1.6.2", | ||
"description": "Date and time picker and inline calendar for Node.js telegram bots", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
142
README.md
@@ -5,3 +5,3 @@ <h1 align="center">telegram-inline-calendar</h1> | ||
Date and time picker and Inline calendar for Node.js telegram bots. | ||
Date and time picker and inline calendar for Node.js telegram bots. | ||
@@ -36,11 +36,16 @@ | ||
## 📦 Install | ||
There are two versions: | ||
### v1.x - if you are using CommonJS module | ||
```sh | ||
npm i telegram-inline-calendar | ||
``` | ||
## [🎚️ Changelog](https://github.com/VDS13/telegram-inline-calendar/blob/main/CHANGELOG.md) | ||
### v2.x - if you are using ES modules | ||
```sh | ||
npm i telegram-inline-calendar@ecmascript | ||
``` | ||
## 🎚️ Changelog ([v1.x](https://github.com/VDS13/telegram-inline-calendar/blob/main/v1.x/CHANGELOG.md) or [v2.x](https://github.com/VDS13/telegram-inline-calendar/blob/main/v2.x/CHANGELOG.md)) | ||
## [🗺 API](https://github.com/VDS13/telegram-inline-calendar/blob/main/API.md) | ||
## 🗺 API ([v1.x](https://github.com/VDS13/telegram-inline-calendar/blob/main/v1.x/API.md) or [v2.x](https://github.com/VDS13/telegram-inline-calendar/blob/main/v2.x/API.md)) | ||
## [🖥️ Examples](https://github.com/VDS13/telegram-inline-calendar/blob/main/EXAMPLES.md) | ||
## 🖥️ Examples ([v1.x](https://github.com/VDS13/telegram-inline-calendar/blob/main/v1.x/EXAMPLES.md) or [v2.x](https://github.com/VDS13/telegram-inline-calendar/blob/main/v2.x/EXAMPLES.md)) | ||
@@ -50,2 +55,4 @@ ## 🚀 Usage | ||
### node-telegram-bot-api | ||
#### CommonJS | ||
```js | ||
@@ -55,3 +62,3 @@ const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN'; | ||
const TelegramBot = require('node-telegram-bot-api'); | ||
const Calendar = require('telegram-inline-calendar') | ||
const Calendar = require('telegram-inline-calendar'); | ||
process.env.NTBA_FIX_319 = 1; | ||
@@ -77,9 +84,37 @@ const bot = new TelegramBot(TOKEN, {polling: true}); | ||
#### ESM | ||
```js | ||
const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN'; | ||
import TelegramBot from 'node-telegram-bot-api'; | ||
import {Calendar} from 'telegram-inline-calendar'; | ||
process.env.NTBA_FIX_319 = 1; | ||
const bot = new TelegramBot(TOKEN, {polling: true}); | ||
const calendar = new Calendar(bot, { | ||
date_format: 'DD-MM-YYYY', | ||
language: 'en' | ||
}); | ||
bot.onText(/\/start/, (msg) => calendar.startNavCalendar(msg)); | ||
bot.on("callback_query", (query) => { | ||
if (query.message.message_id == calendar.chats.get(query.message.chat.id)) { | ||
var res; | ||
res = calendar.clickButtonCalendar(query); | ||
if (res !== -1) { | ||
bot.sendMessage(query.message.chat.id, "You selected: " + res); | ||
} | ||
} | ||
}); | ||
``` | ||
### telegraf | ||
#### CommonJS | ||
```js | ||
const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN'; | ||
const {Telegraf} = require('telegraf'); | ||
const Calendar = require('telegram-inline-calendar') | ||
const Calendar = require('telegram-inline-calendar'); | ||
const bot = new Telegraf(TOKEN); | ||
@@ -107,3 +142,34 @@ const calendar = new Calendar(bot, { | ||
#### ESM | ||
```js | ||
const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN'; | ||
import {Telegraf} from 'telegraf'; | ||
import {Calendar} from 'telegram-inline-calendar'; | ||
const bot = new Telegraf(TOKEN, {polling: true}); | ||
const calendar = new Calendar(bot, { | ||
date_format: 'DD-MM-YYYY', | ||
language: 'en', | ||
bot_api: 'telegraf' | ||
}); | ||
bot.start((ctx) => calendar.startNavCalendar(ctx)); | ||
bot.on("callback_query", (ctx) => { | ||
if (ctx.callbackQuery.message.message_id == calendar.chats.get(ctx.callbackQuery.message.chat.id)) { | ||
var res; | ||
res = calendar.clickButtonCalendar(ctx); | ||
if (res !== -1) { | ||
ctx.reply("You selected: " + res); | ||
} | ||
} | ||
}); | ||
bot.launch(); | ||
process.once('SIGINT', () => bot.stop('SIGINT')); | ||
process.once('SIGTERM', () => bot.stop('SIGTERM')); | ||
``` | ||
### telebot | ||
#### CommonJS | ||
```js | ||
@@ -113,3 +179,3 @@ const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN'; | ||
const Telebot = require('telebot'); | ||
const Calendar = require('telegram-inline-calendar') | ||
const Calendar = require('telegram-inline-calendar'); | ||
const bot = new Telebot(TOKEN); | ||
@@ -136,3 +202,32 @@ const calendar = new Calendar(bot, { | ||
#### ESM | ||
```js | ||
const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN'; | ||
import Telebot from 'telebot'; | ||
import {Calendar} from 'telegram-inline-calendar'; | ||
const bot = new Telebot(TOKEN, {polling: true}); | ||
const calendar = new Calendar(bot, { | ||
date_format: 'DD-MM-YYYY', | ||
language: 'en', | ||
bot_api: 'telebot' | ||
}); | ||
bot.on('/start', (msg) => calendar.startNavCalendar(msg)); | ||
bot.on("callbackQuery", (query) => { | ||
if (query.message.message_id == calendar.chats.get(query.message.chat.id)) { | ||
var res; | ||
res = calendar.clickButtonCalendar(query); | ||
if (res !== -1) { | ||
bot.sendMessage(query.message.chat.id, "You selected: " + res); | ||
} | ||
} | ||
}); | ||
bot.connect(); | ||
``` | ||
### grammY | ||
#### CommonJS | ||
```js | ||
@@ -142,3 +237,3 @@ const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN'; | ||
const { Bot } = require('grammy'); | ||
const Calendar = require('telegram-inline-calendar') | ||
const Calendar = require('telegram-inline-calendar'); | ||
const bot = new Bot(TOKEN); | ||
@@ -164,2 +259,29 @@ const calendar = new Calendar(bot, { | ||
#### ESM | ||
```js | ||
const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN'; | ||
import { Bot } from 'grammy'; | ||
import {Calendar} from 'telegram-inline-calendar'; | ||
const bot = new Bot(TOKEN, {polling: true}); | ||
const calendar = new Calendar(bot, { | ||
date_format: 'DD-MM-YYYY', | ||
language: 'en', | ||
bot_api: 'grammy' | ||
}); | ||
bot.command('start', ctx => calendar.startNavCalendar(ctx)) | ||
bot.on("callback_query:data", (ctx) => { | ||
if (ctx.msg.message_id == calendar.chats.get(ctx.chat.id)) { | ||
var res; | ||
res = calendar.clickButtonCalendar(ctx); | ||
if (res !== -1) { | ||
ctx.reply("You selected: " + res); | ||
} | ||
} | ||
}); | ||
bot.start(); | ||
``` | ||
## ⚙️ Default options | ||
@@ -166,0 +288,0 @@ |
36139
299