Giter VIP home page Giter VIP logo

Comments (6)

RamallahS avatar RamallahS commented on July 28, 2024 2

Ну как костыль для этого репозитория, может кому пригодится

let Calendar: any
async function getCalendar() {
  if (!Calendar) {
    const calendar = await (eval('import("telegram-inline-calendar")') as Promise<typeof import('telegram-inline-calendar')>);
    Calendar = calendar.Calendar
  }
  return Calendar
}

    const lCalnedar = await getCalendar()
    calendar = new lCalnedar(false, {
      date_format: 'DD-MM-YYYY',
    });

from telegram-inline-calendar.

VDS13 avatar VDS13 commented on July 28, 2024 1

Полноценную версию под TS я ещё не выпускал, пока нет времени.
Если есть желание и время, вы можете сами создать форк и сделать полноценную поддержку TS(планирую им отдать версии серии 3.х.х.), став котрибьютером проекта.

Также скину вам ссылку на проект одного из пользователей, который переделал библиотеку под TS. - https://github.com/youjob13/tg-bot

from telegram-inline-calendar.

VDS13 avatar VDS13 commented on July 28, 2024

Добрый день, @almaziphone,
Как подключаете библиотеку?
Какую версию используете?
В какой момент отображается ошибка(запуске через npm/ VSCode просто подсвечивает)?

from telegram-inline-calendar.

almaziphone avatar almaziphone commented on July 28, 2024

ESM
Использую grammY
локально скачал библиотеку
Could not find a declaration file for module './calendar/Calendar.js'. 'e:/ProgJava/grammy_bot/src/bot/utilites/calendar/Calendar.js' implicitly has an 'any' type.ts(7016)

Если установить через npm:
Could not find a declaration file for module 'telegram-inline-calendar'. 'e:/ProgJava/grammy_bot/node_modules/telegram-inline-calendar/index.js' implicitly has an 'any' type.
Try npm i --save-dev @types/telegram-inline-calendar if it exists or add a new declaration (.d.ts) file containing declare module 'telegram-inline-calendar';ts(7016)

from telegram-inline-calendar.

VDS13 avatar VDS13 commented on July 28, 2024

Ответы на остальные два вопроса?

from telegram-inline-calendar.

almaziphone avatar almaziphone commented on July 28, 2024

Создал файл объявления типов. Клавиатуру запустил. Можете поправить?

// Calendar.d.ts
// Путь к файлу: #root/src/bot/utilites/calendar/src/calendar.d.ts
import { Context, InlineKeyboardMarkup } from "grammy";

export class Calendar {
chats: any;
constructor(bot?: any, options?: CalendarOptions);
NodeTelegramBotApi: BotApi;
Telegraf: BotApi;
Telebot: BotApi;
Grammy: BotApi;
DatetimeFunc: DatetimeFunc;
DateFunc: DateFunc;
addCustomStartMsg(): void;
libraryInitialization(): void;
dateFuncInitialization(): void;
datetimeFuncInitialization(): void;
weekDaysButtons(day: number): number;
startWeekDay(day: number): number;
twoDigits(num: number): string;
colRowNavigation(date: Date, cd: number): number;
howMuchDays(year: number, month: number): number;
createTimeSelector(date?: string, from_calendar?: boolean): InlineKeyboardMarkup;
createNavigationKeyboard(date: Date): InlineKeyboardMarkup;
startNavCalendar(ctx: any): void;
clickButtonCalendar(ctx: any): any;
}

interface CalendarOptions {
language?: string;
date_format?: string;
bot_api?: string;
close_calendar?: boolean;
start_week_day?: number;
time_selector_mod?: boolean;
time_range?: string;
time_step?: string;
start_date?: string | boolean;
stop_date?: string | boolean;
custom_start_msg?: string | boolean;
lock_datetime?: boolean;
lock_date?: boolean;
}

interface BotApi {
editMessageReplyMarkupCalendar(date: Date, queryOrCtx: any): void;
editMessageReplyMarkupTime(date: Date, queryOrCtx: any, from_calendar: boolean): void;
sendMessageCalendar(menu: any, msgOrCtx: any): void;
sendMessageTime(menu: any, msgOrCtx: any): void;
deleteMessage(queryOrCtx: any): void;
replyMarkupObject(cnk: any): any;
clickButtonCalendar(queryOrCtx: any): any;
startNavCalendar(msgOrCtx: any): void;
startTimeSelector(msgOrCtx: any): void;
}

interface DatetimeFunc {
withoutLockDatetime(stop: string, datetime: string, type: string): boolean;
withLockDatetime(stop: string, datetime: string, type: string): boolean;
}

interface DateFunc {
withoutLockDate(date: Date, d: number): boolean;
withLockDate(date: Date, d: number): boolean;
}

from telegram-inline-calendar.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.