API.md

March 26, 2025 · View on GitHub

API Reference

Calendar

Calendar

Kind: global class

new Calendar(bot, [options])

ParamTypeDefaultDescription
botTelegramBotTelegramBot 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]BooleantrueClose calendar after date selection.
[options.start_week_day]Number0First day of the week (Sunday - 0, Monday - 1, Tuesday - 2 and so on).
[options.time_selector_mod]BooleanfalseEnable 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]BooleanfalseAbility to select the user's language.
[options.start_date]Boolean|StringfalseMinimum date of the calendar in the format "YYYY-MM-DD".
[options.stop_date]Boolean|StringfalseMaximum date of the calendar in the format "YYYY-MM-DD".
[options.custom_start_msg]Boolean|StringfalseText of the message sent with the calendar/time selector.
[options.lock_date]BooleanfalseEnable blocked dates list.
[options.lock_datetime]BooleanfalseEnable list of blocked dates and times.
[options.skip_years]Boolean|NumberfalseNumber 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

ParamTypeDescription
msgObjecthttps://core.telegram.org/bots/api#message

calendar.startTimeSelector(msg)

Generating and sending a time selector to the user.

Kind: instance method of Calendar

ParamTypeDescription
msgObjecthttps://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.

ParamTypeDescription
queryObjecthttps://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)

ParamTypeDescription
languageStringundefined
dateDateYear 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)

ParamTypeDefaultDescription
languageStringundefinedLanguage (en/es/de/es/fr/it/tr/id/uk/pt-br).
dateDateundefinedDate Objects for which you want to get a time selector.
from_calendarBooleanfalseCalling the time selector from the calendar.

calendar.changeLang(language)

Changes the language of the bot messages.

Kind: instance method of Calendar

ParamTypeDefaultDescription
languageStringundefinedLanguage (en/es/de/es/fr/it/tr/id/uk/pt-br).