API.md
March 26, 2025 · View on GitHub
API Reference
Calendar
Calendar
Kind: global class
new Calendar(bot, [options])
| Param | Type | Default | Description |
|---|---|---|---|
| bot | TelegramBot | TelegramBot class instance (Telegraf/Telebot/node-telegram-bot-api//grammY) | |
| [options] | Object | ||
| [options.language] | String | "en" | Calendar language. |
| [options.date_format] | String | "YYYY-MM-DD" | Date output format. |
| [options.bot_api] | String | "node-telegram-bot-api" | Telegram bot library. |
| [options.close_calendar] | Boolean | true | Close calendar after date selection. |
| [options.start_week_day] | Number | 0 | First day of the week (Sunday - 0, Monday - 1, Tuesday - 2 and so on). |
| [options.time_selector_mod] | Boolean | false | Enable time selection after a date is selected. |
| [options.time_range] | String | "00:00-23:59" | Allowed time range in "HH:mm-HH:mm" format. |
| [options.time_step] | String | "30m" | Time step in the format "<Time step><m | h>", where "m" - minutes, "h" - hours. (For example: "30m", "1h", "150m"). |
| [options.user_lang_select] | Boolean | false | Ability to select the user's language. |
| [options.start_date] | Boolean|String | false | Minimum date of the calendar in the format "YYYY-MM-DD". |
| [options.stop_date] | Boolean|String | false | Maximum date of the calendar in the format "YYYY-MM-DD". |
| [options.custom_start_msg] | Boolean|String | false | Text of the message sent with the calendar/time selector. |
| [options.lock_date] | Boolean | false | Enable blocked dates list. |
| [options.lock_datetime] | Boolean | false | Enable list of blocked dates and times. |
| [options.skip_years] | Boolean|Number | false | Number of years to skip (1 < skip_years < 10). |
| [lock_date_array] | Array | [] | Аrray of blocked dates in string format in the format "YYYY-MM-DD". |
| [lock_datetime_array] | Array | [] | Аrray of blocked dates and times in string format in the format "YYYY-MM-DD HH:mm". |
calendar.startNavCalendar(msg)
Generating and sending a calendar to the user. Sets the current month and year.
Kind: instance method of Calendar
| Param | Type | Description |
|---|---|---|
| msg | Object | https://core.telegram.org/bots/api#message |
calendar.startTimeSelector(msg)
Generating and sending a time selector to the user.
Kind: instance method of Calendar
| Param | Type | Description |
|---|---|---|
| msg | Object | https://core.telegram.org/bots/api#message |
calendar.clickButtonCalendar(query) ⇒ String | Number
Handle clicking on the calendar or the time selector.
Kind: instance method of Calendar
Returns: String | Number - If a date is selected, it will return a string in the specified format, otherwise it will return -1.
| Param | Type | Description |
|---|---|---|
| query | Object | https://core.telegram.org/bots/api#callbackquery |
calendar.createNavigationKeyboard(language, date) ⇒ Object
Calendar generation.
Kind: instance method of Calendar
Returns: Object - InlineKeyboardMarkup (https://core.telegram.org/bots/api#inlinekeyboardmarkup)
| Param | Type | Description |
|---|---|---|
| language | String | undefined |
| date | Date | Year and month for which you want to get a calendar. |
calendar.createTimeSelector(language, date, from_calendar) ⇒ Object
Time selector generation.
Kind: instance method of Calendar
Returns: Object - InlineKeyboardMarkup (https://core.telegram.org/bots/api#inlinekeyboardmarkup)
| Param | Type | Default | Description |
|---|---|---|---|
| language | String | undefined | Language (en/es/de/es/fr/it/tr/id/uk/pt-br). |
| date | Date | undefined | Date Objects for which you want to get a time selector. |
| from_calendar | Boolean | false | Calling the time selector from the calendar. |
calendar.changeLang(language)
Changes the language of the bot messages.
Kind: instance method of Calendar
| Param | Type | Default | Description |
|---|---|---|---|
| language | String | undefined | Language (en/es/de/es/fr/it/tr/id/uk/pt-br). |