mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-01-11 22:51:06 +03:00
commit
14b7e134a0
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,7 +1,3 @@
|
|||||||
# lock
|
|
||||||
package-lock.json
|
|
||||||
yarn.lock
|
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
/node_modules
|
/node_modules
|
||||||
|
|
||||||
|
14
.npmignore
14
.npmignore
@ -1,8 +1,10 @@
|
|||||||
# source
|
.github
|
||||||
lib
|
lib
|
||||||
index.ts
|
sample
|
||||||
package-lock.json
|
|
||||||
tsconfig.json
|
|
||||||
.prettierrc
|
|
||||||
.eslintrc.js
|
|
||||||
website
|
website
|
||||||
|
.eslintrc.js
|
||||||
|
.prettierrc
|
||||||
|
package-lock.json
|
||||||
|
renovate.json
|
||||||
|
tsconfig.json
|
||||||
|
tsconfig.typedoc.json
|
||||||
|
56
README.md
56
README.md
@ -1,15 +1,21 @@
|
|||||||
<p align="center">
|
# NestJS Telegraf ![npm](https://img.shields.io/npm/dm/nestjs-telegraf) ![GitHub last commit](https://img.shields.io/github/last-commit/bukhalo/nestjs-telegraf) ![NPM](https://img.shields.io/npm/l/nestjs-telegraf)
|
||||||
<a href="http://nestjs.com/" target="blank">
|
|
||||||
<img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
# NestJS Telegraf
|
<img align="right" width="95" height="148" title="NestJS logotype"
|
||||||
![npm](https://img.shields.io/npm/dm/nestjs-telegraf)
|
src="https://nestjs.com/img/logo-small.svg">
|
||||||
![GitHub last commit](https://img.shields.io/github/last-commit/bukhalo/nestjs-telegraf)
|
|
||||||
![NPM](https://img.shields.io/npm/l/nestjs-telegraf)
|
|
||||||
|
|
||||||
[Telegraf](https://github.com/telegraf/telegraf) module for [NestJS](https://github.com/nestjs/nest).
|
NestJS Telegraf – powerful solution for creating Telegram bots.
|
||||||
|
|
||||||
|
This package uses the best of the NodeJS world under the hood. [Telegraf](https://github.com/telegraf/telegraf) is the most powerful library for creating bots and [NestJS](https://github.com/nestjs) is a progressive framework for creating well-architectured applications. This module provides fast and easy way for creating Telegram bots and deep integration with your NestJS application.
|
||||||
|
|
||||||
|
**Features**
|
||||||
|
|
||||||
|
- Simple. Easy to use.
|
||||||
|
- Ton of decorators available out of the box for handling bot actions.
|
||||||
|
- Ability to create custom decorators.
|
||||||
|
- Scenes support.
|
||||||
|
- Telegraf plugins and custom plugins support.
|
||||||
|
- Ability to run multiple bots simultaneously.
|
||||||
|
- Full support of NestJS guards, interceptors, filters and pipes! (*in progress...*)
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
If you want to dive fully into NestJS Telegraf then don't waste your time in this dump, check out the [documentation site](https://nestjs-telegraf.vercel.app).
|
If you want to dive fully into NestJS Telegraf then don't waste your time in this dump, check out the [documentation site](https://nestjs-telegraf.vercel.app).
|
||||||
@ -20,8 +26,8 @@ If you want to dive fully into NestJS Telegraf then don't waste your time in thi
|
|||||||
$ npm i nestjs-telegraf
|
$ npm i nestjs-telegraf
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
Once the installation process is complete, we can import the `TelegrafModule` into the root `AppModule`:
|
Once the installation process is complete, we can import the `TelegrafModule` into the root `AppModule`:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { TelegrafModule } from 'nestjs-telegraf';
|
import { TelegrafModule } from 'nestjs-telegraf';
|
||||||
@ -36,38 +42,42 @@ import { TelegrafModule } from 'nestjs-telegraf';
|
|||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
```
|
```
|
||||||
|
|
||||||
Then add some decorators into the `app.service.ts` for handling Telegram bot API updates:
|
Then create `app.update.ts` file and add some decorators for handling Telegram bot API updates:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import {
|
import {
|
||||||
|
Update,
|
||||||
Start,
|
Start,
|
||||||
Help,
|
Help,
|
||||||
On,
|
On,
|
||||||
Hears,
|
Hears,
|
||||||
Context,
|
Context,
|
||||||
} from 'nestjs-telegraf';
|
} from 'nestjs-telegraf';
|
||||||
|
import { AppService } from './app.service';
|
||||||
|
import { Context } from './context.interface';
|
||||||
|
|
||||||
|
@Update()
|
||||||
|
export class AppUpdate {
|
||||||
|
constructor(private readonly appService: AppService)
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class AppService {
|
|
||||||
@Start()
|
@Start()
|
||||||
start(ctx: Context) {
|
async startCommand(ctx: Context) {
|
||||||
ctx.reply('Welcome');
|
await ctx.reply('Welcome');
|
||||||
}
|
}
|
||||||
|
|
||||||
@Help()
|
@Help()
|
||||||
help(ctx: Context) {
|
async helpCommand(ctx: Context) {
|
||||||
ctx.reply('Send me a sticker');
|
await ctx.reply('Send me a sticker');
|
||||||
}
|
}
|
||||||
|
|
||||||
@On('sticker')
|
@On('sticker')
|
||||||
on(ctx: Context) {
|
async onSticker(ctx: Context) {
|
||||||
ctx.reply('👍');
|
await ctx.reply('👍');
|
||||||
}
|
}
|
||||||
|
|
||||||
@Hears('hi')
|
@Hears('hi')
|
||||||
hears(ctx: Context) {
|
async hearsHi(ctx: Context) {
|
||||||
ctx.reply('Hey there');
|
await ctx.reply('Hey there');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
1
index.d.ts
vendored
1
index.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export * from './dist';
|
|
6
index.js
6
index.js
@ -1,6 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
function __export(m) {
|
|
||||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
||||||
}
|
|
||||||
exports.__esModule = true;
|
|
||||||
__export(require("./dist"));
|
|
@ -1,5 +1,5 @@
|
|||||||
import { Inject } from '@nestjs/common';
|
import { Inject } from '@nestjs/common';
|
||||||
import { getBotToken } from '../../utils';
|
import { getBotToken } from '../../utils';
|
||||||
|
|
||||||
export const InjectBot = (name?: string): ParameterDecorator =>
|
export const InjectBot = (botName?: string): ParameterDecorator =>
|
||||||
Inject(getBotToken(name));
|
Inject(getBotToken(botName));
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers middleware for handling callback_data actions with regular expressions.
|
* Registers middleware for handling callback_data actions with regular expressions.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=action
|
* @see https://telegraf.js.org/#/?id=action
|
||||||
*/
|
*/
|
||||||
export const Action = createUpdateListenerDecorator('action');
|
export const Action = createListenerDecorator('action');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createMissedListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cashtag handling.
|
* Cashtag handling.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=cashtag
|
* @see https://telegraf.js.org/#/?id=cashtag
|
||||||
*/
|
*/
|
||||||
export const Cashtag = createUpdateListenerDecorator('cashtag');
|
export const Cashtag = createMissedListenerDecorator<[string | string[]]>('cashtag');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command handling.
|
* Command handling.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=command
|
* @see https://telegraf.js.org/#/?id=command
|
||||||
*/
|
*/
|
||||||
export const Command = createUpdateListenerDecorator('command');
|
export const Command = createListenerDecorator('command');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createMissedListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers middleware for handling messages with email entity.
|
* Registers middleware for handling messages with email entity.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=telegraf-email
|
* @see https://telegraf.js.org/#/?id=telegraf-email
|
||||||
*/
|
*/
|
||||||
export const Email = createUpdateListenerDecorator('email');
|
export const Email = createMissedListenerDecorator<[string | string[]]>('email');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers middleware for handling callback_data actions with game query.
|
* Registers middleware for handling callback_data actions with game query.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=inlinequery
|
* @see https://telegraf.js.org/#/?id=inlinequery
|
||||||
*/
|
*/
|
||||||
export const GameQuery = createUpdateListenerDecorator('gameQuery');
|
export const GameQuery = createListenerDecorator('gameQuery');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createMissedListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hashtag handling.
|
* Hashtag handling.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=hashtag
|
* @see https://telegraf.js.org/#/?id=hashtag
|
||||||
*/
|
*/
|
||||||
export const Hashtag = createUpdateListenerDecorator('hashtag');
|
export const Hashtag = createMissedListenerDecorator<[string | string[]]>('hashtag');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers middleware for handling text messages.
|
* Registers middleware for handling text messages.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=hears
|
* @see https://telegraf.js.org/#/?id=hears
|
||||||
*/
|
*/
|
||||||
export const Hears = createUpdateListenerDecorator('hears');
|
export const Hears = createListenerDecorator('hears');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for /help command.
|
* Handler for /help command.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=help
|
* @see https://telegraf.js.org/#/?id=help
|
||||||
*/
|
*/
|
||||||
export const Help = createUpdateListenerDecorator('help');
|
export const Help = createListenerDecorator('help');
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createMissedListenerDecorator } from '../../utils';
|
||||||
|
import { HearsTriggers } from 'telegraf/typings/composer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers middleware for handling inline_query actions with regular expressions.
|
* Registers middleware for handling inline_query actions with regular expressions.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=inlinequery
|
* @see https://telegraf.js.org/#/?id=inlinequery
|
||||||
*/
|
*/
|
||||||
export const InlineQuery = createUpdateListenerDecorator('inlineQuery');
|
export const InlineQuery = createMissedListenerDecorator<[HearsTriggers<unknown>]>('inlineQuery');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createMissedListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mention handling.
|
* Mention handling.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=mention
|
* @see https://telegraf.js.org/#/?id=mention
|
||||||
*/
|
*/
|
||||||
export const Mention = createUpdateListenerDecorator('mention');
|
export const Mention = createMissedListenerDecorator<[string | string[]]>('mention');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers middleware for provided update type.
|
* Registers middleware for provided update type.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=on
|
* @see https://telegraf.js.org/#/?id=on
|
||||||
*/
|
*/
|
||||||
export const On = createUpdateListenerDecorator('on');
|
export const On = createListenerDecorator('on');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createMissedListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Phone number handling.
|
* Phone number handling.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=phone
|
* @see https://telegraf.js.org/#/?id=phone
|
||||||
*/
|
*/
|
||||||
export const Phone = createUpdateListenerDecorator('phone');
|
export const Phone = createMissedListenerDecorator<[string | string[]]>('phone');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createMissedListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for /settings command.
|
* Handler for /settings command.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=settings
|
* @see https://telegraf.js.org/#/?id=settings
|
||||||
*/
|
*/
|
||||||
export const Settings = createUpdateListenerDecorator('settings');
|
export const Settings = createMissedListenerDecorator<[]>('settings');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for /start command.
|
* Handler for /start command.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=start
|
* @see https://telegraf.js.org/#/?id=start
|
||||||
*/
|
*/
|
||||||
export const Start = createUpdateListenerDecorator('start');
|
export const Start = createListenerDecorator('start');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createMissedListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers middleware for handling messages with text_link entity.
|
* Registers middleware for handling messages with text_link entity.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=telegraf-textlink
|
* @see https://telegraf.js.org/#/?id=telegraf-textlink
|
||||||
*/
|
*/
|
||||||
export const TextLink = createUpdateListenerDecorator('textLink');
|
export const TextLink = createMissedListenerDecorator<[string | string[]]>('textLink');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createMissedListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers middleware for handling messages with text_mention entity.
|
* Registers middleware for handling messages with text_mention entity.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=telegraf-textlink
|
* @see https://telegraf.js.org/#/?id=telegraf-textlink
|
||||||
*/
|
*/
|
||||||
export const TextMention = createUpdateListenerDecorator('textMention');
|
export const TextMention = createMissedListenerDecorator<[string | string[]]>('textMention');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createMissedListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers middleware for handling messages with url entity.
|
* Registers middleware for handling messages with url entity.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=telegraf-url
|
* @see https://telegraf.js.org/#/?id=telegraf-url
|
||||||
*/
|
*/
|
||||||
export const Url = createUpdateListenerDecorator('url');
|
export const Url = createMissedListenerDecorator<[string | string[]]>('url');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createUpdateListenerDecorator } from '../../helpers';
|
import { createListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a middleware.
|
* Registers a middleware.
|
||||||
*
|
*
|
||||||
* @see https://telegraf.js.org/#/?id=use
|
* @see https://telegraf.js.org/#/?id=use
|
||||||
*/
|
*/
|
||||||
export const Use = createUpdateListenerDecorator('use');
|
export const Use = createListenerDecorator('use');
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
import { createSceneListenerDecorator } from '../../helpers';
|
import { createListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
export const SceneEnter = createSceneListenerDecorator('enter');
|
export const SceneEnter = createListenerDecorator('enter');
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
import { createSceneListenerDecorator } from '../../helpers';
|
import { createListenerDecorator } from '../../utils';
|
||||||
|
|
||||||
export const SceneLeave = createSceneListenerDecorator('leave');
|
export const SceneLeave = createListenerDecorator('leave');
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
import { SetMetadata } from '@nestjs/common';
|
|
||||||
import { Composer } from 'telegraf';
|
|
||||||
import { ComposerMethodArgs, UpdateMethods } from '../types';
|
|
||||||
import { UPDATE_LISTENER_METADATA } from '../telegraf.constants';
|
|
||||||
import { ListenerMetadata } from '../interfaces';
|
|
||||||
|
|
||||||
export function createUpdateListenerDecorator<Method extends UpdateMethods>(
|
|
||||||
method: unknown,
|
|
||||||
) {
|
|
||||||
return (
|
|
||||||
...args: ComposerMethodArgs<Composer<never>, Method>
|
|
||||||
): MethodDecorator => {
|
|
||||||
return SetMetadata(UPDATE_LISTENER_METADATA, {
|
|
||||||
method,
|
|
||||||
args,
|
|
||||||
} as ListenerMetadata);
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
export * from './create-update-listener-decorator.helper';
|
|
||||||
export * from './create-scene-listener-decorator.helper';
|
|
13
lib/index.ts
13
lib/index.ts
@ -1,15 +1,6 @@
|
|||||||
export * as Composer from 'telegraf/composer';
|
|
||||||
export * as Markup from 'telegraf/markup';
|
|
||||||
export * as BaseScene from 'telegraf/scenes/base';
|
|
||||||
export * as session from 'telegraf/session';
|
|
||||||
export * as Stage from 'telegraf/stage';
|
|
||||||
export * as WizardScene from 'telegraf/scenes/wizard';
|
|
||||||
export * as Extra from 'telegraf/extra';
|
|
||||||
|
|
||||||
export * from './decorators';
|
export * from './decorators';
|
||||||
export * from './interfaces';
|
export * from './interfaces';
|
||||||
export * from './helpers';
|
|
||||||
export * from './utils';
|
export * from './utils';
|
||||||
export * from './telegraf.module';
|
|
||||||
export * from './types';
|
export * from './types';
|
||||||
export { Telegraf } from 'telegraf';
|
export * from './telegraf.constants';
|
||||||
|
export * from './telegraf.module';
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
export * from './telegraf-options.interface';
|
export * from './telegraf-options.interface';
|
||||||
export * from './listener-metadata.interface';
|
export * from './listener-metadata.interface';
|
||||||
export * from './update-metadata.interface';
|
|
||||||
|
@ -8,12 +8,12 @@ import {
|
|||||||
|
|
||||||
export interface TelegrafModuleOptions<C extends Context = Context> {
|
export interface TelegrafModuleOptions<C extends Context = Context> {
|
||||||
token: string;
|
token: string;
|
||||||
|
botName?: string;
|
||||||
options?: TelegrafOptions;
|
options?: TelegrafOptions;
|
||||||
launchOptions?: {
|
launchOptions?: {
|
||||||
polling?: LaunchPollingOptions;
|
polling?: LaunchPollingOptions;
|
||||||
webhook?: LaunchWebhookOptions;
|
webhook?: LaunchWebhookOptions;
|
||||||
};
|
};
|
||||||
botName?: string;
|
|
||||||
include?: Function[];
|
include?: Function[];
|
||||||
middlewares?: ReadonlyArray<Middleware<C>>;
|
middlewares?: ReadonlyArray<Middleware<C>>;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
export interface UpdateMetadata {
|
|
||||||
name: string;
|
|
||||||
type: string;
|
|
||||||
methodName: string;
|
|
||||||
callback?: Function | Record<string, any>;
|
|
||||||
}
|
|
@ -1,7 +1,6 @@
|
|||||||
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
|
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
|
||||||
import { Module } from '@nestjs/core/injector/module';
|
import { Module } from '@nestjs/core/injector/module';
|
||||||
import { flattenDeep, groupBy, identity, isEmpty, mapValues } from 'lodash';
|
import { flattenDeep, identity, isEmpty } from 'lodash';
|
||||||
import { UpdateMetadata } from '../interfaces';
|
|
||||||
|
|
||||||
export class BaseExplorerService {
|
export class BaseExplorerService {
|
||||||
getModules(
|
getModules(
|
||||||
@ -21,11 +20,11 @@ export class BaseExplorerService {
|
|||||||
): Module[] {
|
): Module[] {
|
||||||
const modules = [...modulesContainer.values()];
|
const modules = [...modulesContainer.values()];
|
||||||
return modules.filter(({ metatype }) =>
|
return modules.filter(({ metatype }) =>
|
||||||
include.some((item) => item === metatype),
|
include.includes(metatype),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
flatMap<T = UpdateMetadata>(
|
flatMap<T>(
|
||||||
modules: Module[],
|
modules: Module[],
|
||||||
callback: (instance: InstanceWrapper, moduleRef: Module) => T | T[],
|
callback: (instance: InstanceWrapper, moduleRef: Module) => T | T[],
|
||||||
): T[] {
|
): T[] {
|
||||||
@ -37,23 +36,4 @@ export class BaseExplorerService {
|
|||||||
};
|
};
|
||||||
return flattenDeep(invokeMap()).filter(identity);
|
return flattenDeep(invokeMap()).filter(identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
groupMetadata(resolvers: UpdateMetadata[]) {
|
|
||||||
const groupByType = groupBy(
|
|
||||||
resolvers,
|
|
||||||
(metadata: UpdateMetadata) => metadata.type,
|
|
||||||
);
|
|
||||||
const groupedMetadata = mapValues(
|
|
||||||
groupByType,
|
|
||||||
(resolversArr: UpdateMetadata[]) =>
|
|
||||||
resolversArr.reduce(
|
|
||||||
(prev, curr) => ({
|
|
||||||
...prev,
|
|
||||||
[curr.name]: curr.callback,
|
|
||||||
}),
|
|
||||||
{},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return groupedMetadata;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
export * from './updates-explorer.service';
|
export * from './listeners-explorer.service';
|
||||||
export * from './metadata-accessor.service';
|
export * from './metadata-accessor.service';
|
||||||
export * from './scenes-explorer.service';
|
export * from './listeners-explorer.service';
|
||||||
export * from './updates-explorer.service';
|
|
||||||
|
116
lib/services/listeners-explorer.service.ts
Normal file
116
lib/services/listeners-explorer.service.ts
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
import { Inject, Injectable, OnModuleInit } from '@nestjs/common';
|
||||||
|
import { DiscoveryService, ModuleRef, ModulesContainer } from '@nestjs/core';
|
||||||
|
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
|
||||||
|
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
|
||||||
|
import { Module } from '@nestjs/core/injector/module';
|
||||||
|
import { BaseScene, Composer, Stage, Telegraf } from 'telegraf';
|
||||||
|
|
||||||
|
import { MetadataAccessorService } from './metadata-accessor.service';
|
||||||
|
import {
|
||||||
|
TELEGRAF_BOT_NAME,
|
||||||
|
TELEGRAF_MODULE_OPTIONS,
|
||||||
|
} from '../telegraf.constants';
|
||||||
|
import { TelegrafModuleOptions } from '../interfaces';
|
||||||
|
import { BaseExplorerService } from './base-explorer.service';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ListenersExplorerService
|
||||||
|
extends BaseExplorerService
|
||||||
|
implements OnModuleInit {
|
||||||
|
private readonly stage = new Stage([]);
|
||||||
|
private bot: Telegraf<any>;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@Inject(TELEGRAF_BOT_NAME)
|
||||||
|
private readonly botName: string,
|
||||||
|
@Inject(TELEGRAF_MODULE_OPTIONS)
|
||||||
|
private readonly telegrafOptions: TelegrafModuleOptions,
|
||||||
|
private readonly moduleRef: ModuleRef,
|
||||||
|
private readonly discoveryService: DiscoveryService,
|
||||||
|
private readonly metadataAccessor: MetadataAccessorService,
|
||||||
|
private readonly metadataScanner: MetadataScanner,
|
||||||
|
private readonly modulesContainer: ModulesContainer,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
onModuleInit(): void {
|
||||||
|
this.bot = this.moduleRef.get<Telegraf<never>>(this.botName, {
|
||||||
|
strict: false,
|
||||||
|
});
|
||||||
|
this.bot.use(this.stage.middleware());
|
||||||
|
|
||||||
|
this.explore();
|
||||||
|
}
|
||||||
|
|
||||||
|
explore(): void {
|
||||||
|
const modules = this.getModules(
|
||||||
|
this.modulesContainer,
|
||||||
|
this.telegrafOptions.include || [],
|
||||||
|
);
|
||||||
|
|
||||||
|
this.registerUpdates(modules);
|
||||||
|
this.registerScenes(modules);
|
||||||
|
}
|
||||||
|
|
||||||
|
private registerUpdates(modules: Module[]): void {
|
||||||
|
const updates = this.flatMap<InstanceWrapper>(modules, (instance) =>
|
||||||
|
this.filterUpdates(instance),
|
||||||
|
);
|
||||||
|
updates.forEach(({ instance }) =>
|
||||||
|
this.registerInstanceMethodListeners(this.bot, instance),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private registerScenes(modules: Module[]): void {
|
||||||
|
const scenes = this.flatMap<InstanceWrapper>(modules, (instance) =>
|
||||||
|
this.filterScenes(instance),
|
||||||
|
);
|
||||||
|
scenes.forEach(({ instance }) => {
|
||||||
|
const sceneId = this.metadataAccessor.getSceneMetadata(
|
||||||
|
instance.constructor,
|
||||||
|
);
|
||||||
|
const scene = new BaseScene(sceneId);
|
||||||
|
this.stage.register(scene);
|
||||||
|
|
||||||
|
this.registerInstanceMethodListeners(scene, instance);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private filterUpdates(wrapper: InstanceWrapper): InstanceWrapper<unknown> {
|
||||||
|
const { instance } = wrapper;
|
||||||
|
if (!instance) return undefined;
|
||||||
|
|
||||||
|
const isUpdate = this.metadataAccessor.isUpdate(wrapper.metatype);
|
||||||
|
if (!isUpdate) return undefined;
|
||||||
|
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
private filterScenes(wrapper: InstanceWrapper): InstanceWrapper<unknown> {
|
||||||
|
const { instance } = wrapper;
|
||||||
|
if (!instance) return undefined;
|
||||||
|
|
||||||
|
const isScene = this.metadataAccessor.isScene(wrapper.metatype);
|
||||||
|
if (!isScene) return undefined;
|
||||||
|
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
private registerInstanceMethodListeners(
|
||||||
|
composer: Composer<never>,
|
||||||
|
instance: Record<string, Function>,
|
||||||
|
): void {
|
||||||
|
const prototype = Object.getPrototypeOf(instance);
|
||||||
|
this.metadataScanner.scanFromPrototype(instance, prototype, (name) => {
|
||||||
|
const methodRef = instance[name];
|
||||||
|
|
||||||
|
const metadata = this.metadataAccessor.getListenerMetadata(methodRef);
|
||||||
|
if (!metadata) return;
|
||||||
|
|
||||||
|
const middlewareFn = methodRef.bind(instance);
|
||||||
|
const { method, args } = metadata;
|
||||||
|
composer[method](...args, middlewareFn);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -18,13 +18,6 @@ export class MetadataAccessorService {
|
|||||||
return !!this.reflector.get(UPDATE_METADATA, target);
|
return !!this.reflector.get(UPDATE_METADATA, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
isUpdateListener(target: Function) {
|
|
||||||
if (!target) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return !!this.reflector.get(UPDATE_LISTENER_METADATA, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
isScene(target: Function): boolean {
|
isScene(target: Function): boolean {
|
||||||
if (!target) {
|
if (!target) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,98 +0,0 @@
|
|||||||
import { Inject, Injectable, OnModuleInit } from '@nestjs/common';
|
|
||||||
import { DiscoveryService, ModuleRef, ModulesContainer } from '@nestjs/core';
|
|
||||||
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
|
|
||||||
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
|
|
||||||
import { BaseScene as Scene, Stage, Telegraf } from 'telegraf';
|
|
||||||
import { MetadataAccessorService } from './metadata-accessor.service';
|
|
||||||
import { BaseExplorerService } from './base-explorer.service';
|
|
||||||
import {
|
|
||||||
TELEGRAF_BOT_NAME,
|
|
||||||
TELEGRAF_MODULE_OPTIONS,
|
|
||||||
} from '../telegraf.constants';
|
|
||||||
import { TelegrafModuleOptions } from '../interfaces';
|
|
||||||
import { Module } from '@nestjs/core/injector/module';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ScenesExplorerService
|
|
||||||
extends BaseExplorerService
|
|
||||||
implements OnModuleInit {
|
|
||||||
private readonly stage = new Stage([]);
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
@Inject(TELEGRAF_BOT_NAME)
|
|
||||||
private readonly botName: string,
|
|
||||||
@Inject(TELEGRAF_MODULE_OPTIONS)
|
|
||||||
private readonly telegrafModuleOptions: TelegrafModuleOptions,
|
|
||||||
private readonly moduleRef: ModuleRef,
|
|
||||||
private readonly discoveryService: DiscoveryService,
|
|
||||||
private readonly metadataAccessor: MetadataAccessorService,
|
|
||||||
private readonly metadataScanner: MetadataScanner,
|
|
||||||
private readonly modulesContainer: ModulesContainer,
|
|
||||||
) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
private bot: Telegraf<any>;
|
|
||||||
|
|
||||||
onModuleInit(): void {
|
|
||||||
this.bot = this.moduleRef.get<Telegraf<any>>(this.botName, {
|
|
||||||
strict: false,
|
|
||||||
});
|
|
||||||
this.bot.use(this.stage.middleware());
|
|
||||||
this.explore();
|
|
||||||
}
|
|
||||||
|
|
||||||
private explore(): void {
|
|
||||||
const modules = this.getModules(
|
|
||||||
this.modulesContainer,
|
|
||||||
this.telegrafModuleOptions.include || [],
|
|
||||||
);
|
|
||||||
const scenes = this.flatMap(modules, (instance, moduleRef) =>
|
|
||||||
this.applyScenes(instance, moduleRef),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private applyScenes(wrapper: InstanceWrapper, moduleRef: Module) {
|
|
||||||
const { instance } = wrapper;
|
|
||||||
if (!instance) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
const prototype = Object.getPrototypeOf(instance);
|
|
||||||
|
|
||||||
const providers: InstanceWrapper[] = this.discoveryService.getProviders();
|
|
||||||
const sceneProviders: InstanceWrapper[] = providers.filter(
|
|
||||||
(wrapper: InstanceWrapper) =>
|
|
||||||
this.metadataAccessor.isScene(wrapper.metatype),
|
|
||||||
);
|
|
||||||
|
|
||||||
sceneProviders.forEach((wrapper) => {
|
|
||||||
const { instance } = wrapper;
|
|
||||||
if (!instance) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const sceneId = this.metadataAccessor.getSceneMetadata(
|
|
||||||
instance.constructor,
|
|
||||||
);
|
|
||||||
|
|
||||||
const scene = new Scene(sceneId);
|
|
||||||
this.stage.register(scene);
|
|
||||||
|
|
||||||
this.metadataScanner.scanFromPrototype(
|
|
||||||
instance,
|
|
||||||
prototype,
|
|
||||||
(methodKey: string) => {
|
|
||||||
const methodRef = instance[methodKey];
|
|
||||||
if (this.metadataAccessor.isUpdateListener(methodRef)) {
|
|
||||||
const metadata = this.metadataAccessor.getListenerMetadata(
|
|
||||||
methodRef,
|
|
||||||
);
|
|
||||||
const middlewareFn = methodRef.bind(instance);
|
|
||||||
const { method, args } = metadata;
|
|
||||||
(scene[method] as any)(...args, middlewareFn);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
import { Inject, Injectable, OnModuleInit } from '@nestjs/common';
|
|
||||||
import { DiscoveryService, ModuleRef, ModulesContainer } from '@nestjs/core';
|
|
||||||
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
|
|
||||||
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
|
|
||||||
import { MetadataAccessorService } from './metadata-accessor.service';
|
|
||||||
import {
|
|
||||||
TELEGRAF_BOT_NAME,
|
|
||||||
TELEGRAF_MODULE_OPTIONS,
|
|
||||||
} from '../telegraf.constants';
|
|
||||||
import { Telegraf } from 'telegraf';
|
|
||||||
import { TelegrafModuleOptions } from '../interfaces';
|
|
||||||
import { BaseExplorerService } from './base-explorer.service';
|
|
||||||
import { Module } from '@nestjs/core/injector/module';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class UpdatesExplorerService
|
|
||||||
extends BaseExplorerService
|
|
||||||
implements OnModuleInit {
|
|
||||||
constructor(
|
|
||||||
@Inject(TELEGRAF_BOT_NAME)
|
|
||||||
private readonly botName: string,
|
|
||||||
@Inject(TELEGRAF_MODULE_OPTIONS)
|
|
||||||
private readonly telegrafModuleOptions: TelegrafModuleOptions,
|
|
||||||
private readonly moduleRef: ModuleRef,
|
|
||||||
private readonly discoveryService: DiscoveryService,
|
|
||||||
private readonly metadataAccessor: MetadataAccessorService,
|
|
||||||
private readonly metadataScanner: MetadataScanner,
|
|
||||||
private readonly modulesContainer: ModulesContainer,
|
|
||||||
) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
private bot: Telegraf<any>;
|
|
||||||
|
|
||||||
onModuleInit(): void {
|
|
||||||
this.bot = this.moduleRef.get<Telegraf<any>>(this.botName, {
|
|
||||||
strict: false,
|
|
||||||
});
|
|
||||||
this.explore();
|
|
||||||
}
|
|
||||||
|
|
||||||
explore() {
|
|
||||||
const modules = this.getModules(
|
|
||||||
this.modulesContainer,
|
|
||||||
this.telegrafModuleOptions.include || [],
|
|
||||||
);
|
|
||||||
const updates = this.flatMap(modules, (instance, moduleRef) =>
|
|
||||||
this.applyUpdates(instance, moduleRef),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private applyUpdates(wrapper: InstanceWrapper, moduleRef: Module) {
|
|
||||||
const { instance } = wrapper;
|
|
||||||
if (!instance) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
const prototype = Object.getPrototypeOf(instance);
|
|
||||||
|
|
||||||
const providers: InstanceWrapper[] = this.discoveryService.getProviders();
|
|
||||||
const updateProviders: InstanceWrapper[] = providers.filter(
|
|
||||||
(wrapper: InstanceWrapper) =>
|
|
||||||
this.metadataAccessor.isUpdate(wrapper.metatype),
|
|
||||||
);
|
|
||||||
|
|
||||||
updateProviders.forEach((wrapper: InstanceWrapper) => {
|
|
||||||
const { instance } = wrapper;
|
|
||||||
if (!instance) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
this.metadataScanner.scanFromPrototype(instance, prototype, (name) => {
|
|
||||||
const methodRef = instance[name];
|
|
||||||
if (this.metadataAccessor.isUpdateListener(methodRef)) {
|
|
||||||
const metadata = this.metadataAccessor.getListenerMetadata(methodRef);
|
|
||||||
const middlewareFn = methodRef.bind(instance);
|
|
||||||
const { method, args } = metadata;
|
|
||||||
// NOTE: Use "any" to disable "Expected at least 1 arguments, but got 1 or more." error.
|
|
||||||
// Use telegraf instance for non-scene listeners
|
|
||||||
(this.bot[method] as any)(...args, middlewareFn);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +1,48 @@
|
|||||||
import { DiscoveryModule, ModuleRef } from '@nestjs/core';
|
import { DiscoveryModule, ModuleRef } from '@nestjs/core';
|
||||||
import {
|
import {
|
||||||
Module,
|
|
||||||
DynamicModule,
|
DynamicModule,
|
||||||
Provider,
|
|
||||||
Type,
|
|
||||||
Global,
|
Global,
|
||||||
Inject,
|
Inject,
|
||||||
|
Module,
|
||||||
OnApplicationShutdown,
|
OnApplicationShutdown,
|
||||||
Logger,
|
Provider,
|
||||||
|
Type,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import {
|
import {
|
||||||
TelegrafModuleOptions,
|
|
||||||
TelegrafModuleAsyncOptions,
|
TelegrafModuleAsyncOptions,
|
||||||
|
TelegrafModuleOptions,
|
||||||
TelegrafOptionsFactory,
|
TelegrafOptionsFactory,
|
||||||
} from './interfaces';
|
} from './interfaces';
|
||||||
import {
|
import {
|
||||||
TELEGRAF_BOT_NAME,
|
TELEGRAF_BOT_NAME,
|
||||||
TELEGRAF_MODULE_OPTIONS,
|
TELEGRAF_MODULE_OPTIONS,
|
||||||
} from './telegraf.constants';
|
} from './telegraf.constants';
|
||||||
import {
|
import { ListenersExplorerService, MetadataAccessorService } from './services';
|
||||||
MetadataAccessorService,
|
import { createBotFactory, getBotToken } from './utils';
|
||||||
ScenesExplorerService,
|
|
||||||
UpdatesExplorerService,
|
|
||||||
} from './services';
|
|
||||||
import { getBotToken } from './utils';
|
|
||||||
import { Telegraf } from 'telegraf';
|
|
||||||
import { defer } from 'rxjs';
|
|
||||||
|
|
||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
imports: [DiscoveryModule],
|
imports: [DiscoveryModule],
|
||||||
providers: [
|
providers: [ListenersExplorerService, MetadataAccessorService],
|
||||||
UpdatesExplorerService,
|
|
||||||
ScenesExplorerService,
|
|
||||||
MetadataAccessorService,
|
|
||||||
],
|
|
||||||
})
|
})
|
||||||
export class TelegrafCoreModule implements OnApplicationShutdown {
|
export class TelegrafCoreModule implements OnApplicationShutdown {
|
||||||
private static logger = new Logger(TelegrafCoreModule.name);
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(TELEGRAF_BOT_NAME) private readonly botName: string,
|
@Inject(TELEGRAF_BOT_NAME)
|
||||||
|
private readonly botName: string,
|
||||||
private readonly moduleRef: ModuleRef,
|
private readonly moduleRef: ModuleRef,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public static forRoot(options: TelegrafModuleOptions): DynamicModule {
|
public static forRoot(options: TelegrafModuleOptions): DynamicModule {
|
||||||
const telegrafBotName = getBotToken(options.botName);
|
const telegrafBotName = getBotToken(options.botName);
|
||||||
|
|
||||||
const telegrafBotProvider = {
|
const telegrafBotNameProvider = {
|
||||||
|
provide: TELEGRAF_BOT_NAME,
|
||||||
|
useValue: telegrafBotName,
|
||||||
|
};
|
||||||
|
|
||||||
|
const telegrafBotProvider: Provider = {
|
||||||
provide: telegrafBotName,
|
provide: telegrafBotName,
|
||||||
useFactory: async (): Promise<any> =>
|
useFactory: async () => await createBotFactory(options),
|
||||||
await defer(async () => {
|
|
||||||
const bot = new Telegraf<any>(options.token);
|
|
||||||
this.applyBotMiddlewares(bot, options.middlewares);
|
|
||||||
await bot.launch(options.launchOptions);
|
|
||||||
return bot;
|
|
||||||
}).toPromise(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -65,10 +52,7 @@ export class TelegrafCoreModule implements OnApplicationShutdown {
|
|||||||
provide: TELEGRAF_MODULE_OPTIONS,
|
provide: TELEGRAF_MODULE_OPTIONS,
|
||||||
useValue: options,
|
useValue: options,
|
||||||
},
|
},
|
||||||
{
|
telegrafBotNameProvider,
|
||||||
provide: TELEGRAF_BOT_NAME,
|
|
||||||
useValue: telegrafBotName,
|
|
||||||
},
|
|
||||||
telegrafBotProvider,
|
telegrafBotProvider,
|
||||||
],
|
],
|
||||||
exports: [telegrafBotProvider],
|
exports: [telegrafBotProvider],
|
||||||
@ -80,20 +64,15 @@ export class TelegrafCoreModule implements OnApplicationShutdown {
|
|||||||
): DynamicModule {
|
): DynamicModule {
|
||||||
const telegrafBotName = getBotToken(options.botName);
|
const telegrafBotName = getBotToken(options.botName);
|
||||||
|
|
||||||
const telegrafBotProvider = {
|
const telegrafBotNameProvider = {
|
||||||
provide: telegrafBotName,
|
provide: TELEGRAF_BOT_NAME,
|
||||||
useFactory: async (
|
useValue: telegrafBotName,
|
||||||
telegrafModuleOptions: TelegrafModuleOptions,
|
};
|
||||||
): Promise<any> => {
|
|
||||||
const { botName, ...telegrafOptions } = telegrafModuleOptions;
|
|
||||||
|
|
||||||
return await defer(async () => {
|
const telegrafBotProvider: Provider = {
|
||||||
const bot = new Telegraf<any>(telegrafOptions.token);
|
provide: telegrafBotName,
|
||||||
this.applyBotMiddlewares(bot, telegrafOptions.middlewares);
|
useFactory: async (options: TelegrafModuleOptions) =>
|
||||||
await bot.launch(telegrafOptions.launchOptions);
|
await createBotFactory(options),
|
||||||
return bot;
|
|
||||||
}).toPromise();
|
|
||||||
},
|
|
||||||
inject: [TELEGRAF_MODULE_OPTIONS],
|
inject: [TELEGRAF_MODULE_OPTIONS],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -103,22 +82,16 @@ export class TelegrafCoreModule implements OnApplicationShutdown {
|
|||||||
imports: options.imports,
|
imports: options.imports,
|
||||||
providers: [
|
providers: [
|
||||||
...asyncProviders,
|
...asyncProviders,
|
||||||
{
|
telegrafBotNameProvider,
|
||||||
provide: TELEGRAF_BOT_NAME,
|
|
||||||
useValue: telegrafBotName,
|
|
||||||
},
|
|
||||||
telegrafBotProvider,
|
telegrafBotProvider,
|
||||||
],
|
],
|
||||||
exports: [telegrafBotProvider],
|
exports: [telegrafBotNameProvider, telegrafBotProvider],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static applyBotMiddlewares(bot, middlewares) {
|
async onApplicationShutdown(): Promise<void> {
|
||||||
if (middlewares) {
|
const bot = this.moduleRef.get<any>(this.botName);
|
||||||
middlewares.forEach((middleware) => {
|
bot && (await bot.stop());
|
||||||
bot.use(middleware);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static createAsyncProviders(
|
private static createAsyncProviders(
|
||||||
@ -158,9 +131,4 @@ export class TelegrafCoreModule implements OnApplicationShutdown {
|
|||||||
inject,
|
inject,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async onApplicationShutdown(): Promise<void> {
|
|
||||||
const bot = this.moduleRef.get<any>(this.botName);
|
|
||||||
bot && (await bot.stop());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -17,5 +17,5 @@ export type ComposerMethodArgs<
|
|||||||
U extends OnlyFunctionPropertyNames<T> = OnlyFunctionPropertyNames<T>
|
U extends OnlyFunctionPropertyNames<T> = OnlyFunctionPropertyNames<T>
|
||||||
> = Filter<Parameters<T[U]>, Middleware<never>>;
|
> = Filter<Parameters<T[U]>, Middleware<never>>;
|
||||||
|
|
||||||
export type UpdateMethods = OnlyFunctionPropertyNames<Composer<never>>;
|
export type ComposerMethods = OnlyFunctionPropertyNames<Composer<never>>;
|
||||||
export type SceneMethods = OnlyFunctionPropertyNames<BaseScene<never>>;
|
export type SceneMethods = OnlyFunctionPropertyNames<BaseScene<never>>;
|
||||||
|
13
lib/utils/create-bot-factory.util.ts
Normal file
13
lib/utils/create-bot-factory.util.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { Telegraf } from 'telegraf';
|
||||||
|
import { TelegrafModuleOptions } from '../interfaces';
|
||||||
|
|
||||||
|
export async function createBotFactory(
|
||||||
|
options: TelegrafModuleOptions,
|
||||||
|
): Promise<Telegraf<never>> {
|
||||||
|
const bot = new Telegraf<never>(options.token, options.options);
|
||||||
|
|
||||||
|
bot.use(...(options.middlewares ?? []));
|
||||||
|
await bot.launch(options.launchOptions);
|
||||||
|
|
||||||
|
return bot;
|
||||||
|
}
|
@ -4,11 +4,24 @@ import { ComposerMethodArgs, SceneMethods } from '../types';
|
|||||||
import { UPDATE_LISTENER_METADATA } from '../telegraf.constants';
|
import { UPDATE_LISTENER_METADATA } from '../telegraf.constants';
|
||||||
import { ListenerMetadata } from '../interfaces';
|
import { ListenerMetadata } from '../interfaces';
|
||||||
|
|
||||||
export function createSceneListenerDecorator<Method extends SceneMethods>(
|
export function createListenerDecorator<TMethod extends SceneMethods>(
|
||||||
method: Method,
|
method: TMethod,
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
...args: ComposerMethodArgs<Scene<never>, Method>
|
...args: ComposerMethodArgs<Scene<never>, TMethod>
|
||||||
|
): MethodDecorator => {
|
||||||
|
return SetMetadata(UPDATE_LISTENER_METADATA, {
|
||||||
|
method,
|
||||||
|
args,
|
||||||
|
} as ListenerMetadata);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createMissedListenerDecorator<TArgs extends any[]>(
|
||||||
|
method: string,
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
...args: TArgs
|
||||||
): MethodDecorator => {
|
): MethodDecorator => {
|
||||||
return SetMetadata(UPDATE_LISTENER_METADATA, {
|
return SetMetadata(UPDATE_LISTENER_METADATA, {
|
||||||
method,
|
method,
|
@ -1,7 +1,5 @@
|
|||||||
import { DEFAULT_BOT_NAME } from '../telegraf.constants';
|
import { DEFAULT_BOT_NAME } from '../telegraf.constants';
|
||||||
|
|
||||||
export function getBotToken(name?: string) {
|
export function getBotToken(name?: string): string {
|
||||||
return name && name !== DEFAULT_BOT_NAME
|
return name && name !== DEFAULT_BOT_NAME ? `${name}Bot` : DEFAULT_BOT_NAME;
|
||||||
? `${name}_BOT_NAME`
|
|
||||||
: DEFAULT_BOT_NAME;
|
|
||||||
}
|
}
|
||||||
|
@ -1 +1,3 @@
|
|||||||
export * from './get-bot-token.util';
|
export * from './get-bot-token.util';
|
||||||
|
export * from './create-bot-factory.util';
|
||||||
|
export * from './create-listener-decorator.util';
|
||||||
|
354
package-lock.json
generated
354
package-lock.json
generated
@ -6,6 +6,12 @@
|
|||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "individual",
|
||||||
|
"url": "https://www.tinkoff.ru/sl/95M2htqoxux"
|
||||||
|
}
|
||||||
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"telegraf": "3.38.0"
|
"telegraf": "3.38.0"
|
||||||
@ -14,8 +20,8 @@
|
|||||||
"@nestjs/common": "7.6.5",
|
"@nestjs/common": "7.6.5",
|
||||||
"@nestjs/core": "7.6.5",
|
"@nestjs/core": "7.6.5",
|
||||||
"@types/lodash": "4.14.167",
|
"@types/lodash": "4.14.167",
|
||||||
"@typescript-eslint/eslint-plugin": "4.11.1",
|
"@typescript-eslint/eslint-plugin": "4.12.0",
|
||||||
"@typescript-eslint/parser": "4.11.1",
|
"@typescript-eslint/parser": "4.12.0",
|
||||||
"eslint": "7.17.0",
|
"eslint": "7.17.0",
|
||||||
"eslint-config-prettier": "7.1.0",
|
"eslint-config-prettier": "7.1.0",
|
||||||
"eslint-plugin-import": "2.22.1",
|
"eslint-plugin-import": "2.22.1",
|
||||||
@ -25,7 +31,7 @@
|
|||||||
"prettier": "2.2.1",
|
"prettier": "2.2.1",
|
||||||
"reflect-metadata": "0.1.13",
|
"reflect-metadata": "0.1.13",
|
||||||
"rxjs": "6.6.3",
|
"rxjs": "6.6.3",
|
||||||
"typedoc": "0.20.9",
|
"typedoc": "0.20.13",
|
||||||
"typescript": "4.1.3"
|
"typescript": "4.1.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
@ -85,28 +91,6 @@
|
|||||||
"iterare": "1.2.1",
|
"iterare": "1.2.1",
|
||||||
"tslib": "2.0.3",
|
"tslib": "2.0.3",
|
||||||
"uuid": "8.3.2"
|
"uuid": "8.3.2"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/nest"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"cache-manager": "*",
|
|
||||||
"class-transformer": "*",
|
|
||||||
"class-validator": "*",
|
|
||||||
"reflect-metadata": "^0.1.12",
|
|
||||||
"rxjs": "^6.0.0"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"cache-manager": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"class-transformer": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"class-validator": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@nestjs/common/node_modules/tslib": {
|
"node_modules/@nestjs/common/node_modules/tslib": {
|
||||||
@ -120,7 +104,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-7.6.5.tgz",
|
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-7.6.5.tgz",
|
||||||
"integrity": "sha512-syRpXT09RDMySs1BLQSXJfq1NXGfG4VmF9hZYGef+/QWqTRfSMEDEH5MsCCLt2lK3AZnOXE9BQwWKeNBhKLplA==",
|
"integrity": "sha512-syRpXT09RDMySs1BLQSXJfq1NXGfG4VmF9hZYGef+/QWqTRfSMEDEH5MsCCLt2lK3AZnOXE9BQwWKeNBhKLplA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"hasInstallScript": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nuxtjs/opencollective": "0.3.2",
|
"@nuxtjs/opencollective": "0.3.2",
|
||||||
"fast-safe-stringify": "2.0.7",
|
"fast-safe-stringify": "2.0.7",
|
||||||
@ -129,29 +112,6 @@
|
|||||||
"path-to-regexp": "3.2.0",
|
"path-to-regexp": "3.2.0",
|
||||||
"tslib": "2.0.3",
|
"tslib": "2.0.3",
|
||||||
"uuid": "8.3.2"
|
"uuid": "8.3.2"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/nest"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"@nestjs/common": "^7.0.0",
|
|
||||||
"@nestjs/microservices": "^7.0.0",
|
|
||||||
"@nestjs/platform-express": "^7.0.0",
|
|
||||||
"@nestjs/websockets": "^7.0.0",
|
|
||||||
"reflect-metadata": "^0.1.12",
|
|
||||||
"rxjs": "^6.0.0"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"@nestjs/microservices": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@nestjs/platform-express": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@nestjs/websockets": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@nestjs/core/node_modules/tslib": {
|
"node_modules/@nestjs/core/node_modules/tslib": {
|
||||||
@ -308,13 +268,13 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||||
"version": "4.11.1",
|
"version": "4.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.12.0.tgz",
|
||||||
"integrity": "sha512-fABclAX2QIEDmTMk6Yd7Muv1CzFLwWM4505nETzRHpP3br6jfahD9UUJkhnJ/g2m7lwfz8IlswcwGGPGiq9exw==",
|
"integrity": "sha512-wHKj6q8s70sO5i39H2g1gtpCXCvjVszzj6FFygneNFyIAxRvNSVz9GML7XpqrB9t7hNutXw+MHnLN/Ih6uyB8Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/experimental-utils": "4.11.1",
|
"@typescript-eslint/experimental-utils": "4.12.0",
|
||||||
"@typescript-eslint/scope-manager": "4.11.1",
|
"@typescript-eslint/scope-manager": "4.12.0",
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"functional-red-black-tree": "^1.0.1",
|
"functional-red-black-tree": "^1.0.1",
|
||||||
"regexpp": "^3.0.0",
|
"regexpp": "^3.0.0",
|
||||||
@ -323,110 +283,70 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^10.12.0 || >=12.0.0"
|
"node": "^10.12.0 || >=12.0.0"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/typescript-eslint"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"@typescript-eslint/parser": "^4.0.0",
|
|
||||||
"eslint": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"typescript": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/experimental-utils": {
|
"node_modules/@typescript-eslint/experimental-utils": {
|
||||||
"version": "4.11.1",
|
"version": "4.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.12.0.tgz",
|
||||||
"integrity": "sha512-mAlWowT4A6h0TC9F+J5pdbEhjNiEMO+kqPKQ4sc3fVieKL71dEqfkKgtcFVSX3cjSBwYwhImaQ/mXQF0oaI38g==",
|
"integrity": "sha512-MpXZXUAvHt99c9ScXijx7i061o5HEjXltO+sbYfZAAHxv3XankQkPaNi5myy0Yh0Tyea3Hdq1pi7Vsh0GJb0fA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/json-schema": "^7.0.3",
|
"@types/json-schema": "^7.0.3",
|
||||||
"@typescript-eslint/scope-manager": "4.11.1",
|
"@typescript-eslint/scope-manager": "4.12.0",
|
||||||
"@typescript-eslint/types": "4.11.1",
|
"@typescript-eslint/types": "4.12.0",
|
||||||
"@typescript-eslint/typescript-estree": "4.11.1",
|
"@typescript-eslint/typescript-estree": "4.12.0",
|
||||||
"eslint-scope": "^5.0.0",
|
"eslint-scope": "^5.0.0",
|
||||||
"eslint-utils": "^2.0.0"
|
"eslint-utils": "^2.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^10.12.0 || >=12.0.0"
|
"node": "^10.12.0 || >=12.0.0"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/typescript-eslint"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"eslint": "*"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/parser": {
|
"node_modules/@typescript-eslint/parser": {
|
||||||
"version": "4.11.1",
|
"version": "4.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.12.0.tgz",
|
||||||
"integrity": "sha512-BJ3jwPQu1jeynJ5BrjLuGfK/UJu6uwHxJ/di7sanqmUmxzmyIcd3vz58PMR7wpi8k3iWq2Q11KMYgZbUpRoIPw==",
|
"integrity": "sha512-9XxVADAo9vlfjfoxnjboBTxYOiNY93/QuvcPgsiKvHxW6tOZx1W4TvkIQ2jB3k5M0pbFP5FlXihLK49TjZXhuQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/scope-manager": "4.11.1",
|
"@typescript-eslint/scope-manager": "4.12.0",
|
||||||
"@typescript-eslint/types": "4.11.1",
|
"@typescript-eslint/types": "4.12.0",
|
||||||
"@typescript-eslint/typescript-estree": "4.11.1",
|
"@typescript-eslint/typescript-estree": "4.12.0",
|
||||||
"debug": "^4.1.1"
|
"debug": "^4.1.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^10.12.0 || >=12.0.0"
|
"node": "^10.12.0 || >=12.0.0"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/typescript-eslint"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"eslint": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"typescript": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/scope-manager": {
|
"node_modules/@typescript-eslint/scope-manager": {
|
||||||
"version": "4.11.1",
|
"version": "4.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.12.0.tgz",
|
||||||
"integrity": "sha512-Al2P394dx+kXCl61fhrrZ1FTI7qsRDIUiVSuN6rTwss6lUn8uVO2+nnF4AvO0ug8vMsy3ShkbxLu/uWZdTtJMQ==",
|
"integrity": "sha512-QVf9oCSVLte/8jvOsxmgBdOaoe2J0wtEmBr13Yz0rkBNkl5D8bfnf6G4Vhox9qqMIoG7QQoVwd2eG9DM/ge4Qg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/types": "4.11.1",
|
"@typescript-eslint/types": "4.12.0",
|
||||||
"@typescript-eslint/visitor-keys": "4.11.1"
|
"@typescript-eslint/visitor-keys": "4.12.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
|
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/typescript-eslint"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/types": {
|
"node_modules/@typescript-eslint/types": {
|
||||||
"version": "4.11.1",
|
"version": "4.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.12.0.tgz",
|
||||||
"integrity": "sha512-5kvd38wZpqGY4yP/6W3qhYX6Hz0NwUbijVsX2rxczpY6OXaMxh0+5E5uLJKVFwaBM7PJe1wnMym85NfKYIh6CA==",
|
"integrity": "sha512-N2RhGeheVLGtyy+CxRmxdsniB7sMSCfsnbh8K/+RUIXYYq3Ub5+sukRCjVE80QerrUBvuEvs4fDhz5AW/pcL6g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
|
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/typescript-eslint"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/typescript-estree": {
|
"node_modules/@typescript-eslint/typescript-estree": {
|
||||||
"version": "4.11.1",
|
"version": "4.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.12.0.tgz",
|
||||||
"integrity": "sha512-tC7MKZIMRTYxQhrVAFoJq/DlRwv1bnqA4/S2r3+HuHibqvbrPcyf858lNzU7bFmy4mLeIHFYr34ar/1KumwyRw==",
|
"integrity": "sha512-gZkFcmmp/CnzqD2RKMich2/FjBTsYopjiwJCroxqHZIY11IIoN0l5lKqcgoAPKHt33H2mAkSfvzj8i44Jm7F4w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/types": "4.11.1",
|
"@typescript-eslint/types": "4.12.0",
|
||||||
"@typescript-eslint/visitor-keys": "4.11.1",
|
"@typescript-eslint/visitor-keys": "4.12.0",
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"globby": "^11.0.1",
|
"globby": "^11.0.1",
|
||||||
"is-glob": "^4.0.1",
|
"is-glob": "^4.0.1",
|
||||||
@ -436,32 +356,19 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^10.12.0 || >=12.0.0"
|
"node": "^10.12.0 || >=12.0.0"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/typescript-eslint"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"typescript": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/visitor-keys": {
|
"node_modules/@typescript-eslint/visitor-keys": {
|
||||||
"version": "4.11.1",
|
"version": "4.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.12.0.tgz",
|
||||||
"integrity": "sha512-IrlBhD9bm4bdYcS8xpWarazkKXlE7iYb1HzRuyBP114mIaj5DJPo11Us1HgH60dTt41TCZXMaTCAW+OILIYPOg==",
|
"integrity": "sha512-hVpsLARbDh4B9TKYz5cLbcdMIOAoBYgFPCSP9FFS/liSF+b33gVNq8JHY3QGhHNVz85hObvL7BEYLlgx553WCw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/types": "4.11.1",
|
"@typescript-eslint/types": "4.12.0",
|
||||||
"eslint-visitor-keys": "^2.0.0"
|
"eslint-visitor-keys": "^2.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
|
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/typescript-eslint"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": {
|
"node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": {
|
||||||
@ -489,10 +396,7 @@
|
|||||||
"version": "5.3.1",
|
"version": "5.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz",
|
||||||
"integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==",
|
"integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"peerDependencies": {
|
|
||||||
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"node_modules/aggregate-error": {
|
"node_modules/aggregate-error": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
@ -517,10 +421,6 @@
|
|||||||
"fast-json-stable-stringify": "^2.0.0",
|
"fast-json-stable-stringify": "^2.0.0",
|
||||||
"json-schema-traverse": "^0.4.1",
|
"json-schema-traverse": "^0.4.1",
|
||||||
"uri-js": "^4.2.2"
|
"uri-js": "^4.2.2"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "github",
|
|
||||||
"url": "https://github.com/sponsors/epoberezkin"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ansi-colors": {
|
"node_modules/ansi-colors": {
|
||||||
@ -1011,9 +911,6 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^10.12.0 || >=12.0.0"
|
"node": "^10.12.0 || >=12.0.0"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://opencollective.com/eslint"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-config-prettier": {
|
"node_modules/eslint-config-prettier": {
|
||||||
@ -1023,9 +920,6 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"eslint-config-prettier": "bin/cli.js"
|
"eslint-config-prettier": "bin/cli.js"
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"eslint": ">=7.0.0"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-import-resolver-node": {
|
"node_modules/eslint-import-resolver-node": {
|
||||||
@ -1543,19 +1437,8 @@
|
|||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.1.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.1.tgz",
|
||||||
"integrity": "sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg==",
|
"integrity": "sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"type": "individual",
|
|
||||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4.0"
|
"node": ">=4.0"
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"debug": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/fs-extra": {
|
"node_modules/fs-extra": {
|
||||||
@ -1624,9 +1507,6 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "*"
|
"node": "*"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/isaacs"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/glob-parent": {
|
"node_modules/glob-parent": {
|
||||||
@ -1651,9 +1531,6 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/globby": {
|
"node_modules/globby": {
|
||||||
@ -1671,9 +1548,6 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/globby/node_modules/ignore": {
|
"node_modules/globby/node_modules/ignore": {
|
||||||
@ -1763,7 +1637,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/husky/-/husky-4.3.6.tgz",
|
"resolved": "https://registry.npmjs.org/husky/-/husky-4.3.6.tgz",
|
||||||
"integrity": "sha512-o6UjVI8xtlWRL5395iWq9LKDyp/9TE7XMOTvIpEVzW638UcGxTmV5cfel6fsk/jbZSTlvfGVJf2svFtybcIZag==",
|
"integrity": "sha512-o6UjVI8xtlWRL5395iWq9LKDyp/9TE7XMOTvIpEVzW638UcGxTmV5cfel6fsk/jbZSTlvfGVJf2svFtybcIZag==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"hasInstallScript": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^4.0.0",
|
"chalk": "^4.0.0",
|
||||||
"ci-info": "^2.0.0",
|
"ci-info": "^2.0.0",
|
||||||
@ -1782,10 +1655,6 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/husky"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/husky/node_modules/ansi-styles": {
|
"node_modules/husky/node_modules/ansi-styles": {
|
||||||
@ -2128,9 +1997,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"graceful-fs": "^4.1.6",
|
"graceful-fs": "^4.1.6",
|
||||||
"universalify": "^2.0.0"
|
"universalify": "^2.0.0"
|
||||||
},
|
|
||||||
"optionalDependencies": {
|
|
||||||
"graceful-fs": "^4.1.6"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/jsonfile/node_modules/universalify": {
|
"node_modules/jsonfile/node_modules/universalify": {
|
||||||
@ -2185,9 +2051,6 @@
|
|||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"lint-staged": "bin/lint-staged.js"
|
"lint-staged": "bin/lint-staged.js"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://opencollective.com/lint-staged"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/lint-staged/node_modules/ansi-styles": {
|
"node_modules/lint-staged/node_modules/ansi-styles": {
|
||||||
@ -3214,30 +3077,13 @@
|
|||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"rimraf": "bin.js"
|
"rimraf": "bin.js"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/isaacs"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/run-parallel": {
|
"node_modules/run-parallel": {
|
||||||
"version": "1.1.10",
|
"version": "1.1.10",
|
||||||
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.10.tgz",
|
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.10.tgz",
|
||||||
"integrity": "sha512-zb/1OuZ6flOlH6tQyMPUrE3x3Ulxjlo9WIVXR4yVYi4H9UXQaeIsPbLn2R3O3vQCnDKkAl2qHiuocKKX4Tz/Sw==",
|
"integrity": "sha512-zb/1OuZ6flOlH6tQyMPUrE3x3Ulxjlo9WIVXR4yVYi4H9UXQaeIsPbLn2R3O3vQCnDKkAl2qHiuocKKX4Tz/Sw==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"type": "github",
|
|
||||||
"url": "https://github.com/sponsors/feross"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "patreon",
|
|
||||||
"url": "https://www.patreon.com/feross"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "consulting",
|
|
||||||
"url": "https://feross.org/support"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"node_modules/rxjs": {
|
"node_modules/rxjs": {
|
||||||
"version": "6.6.3",
|
"version": "6.6.3",
|
||||||
@ -3579,9 +3425,6 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/supports-color": {
|
"node_modules/supports-color": {
|
||||||
@ -3621,9 +3464,6 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/table/node_modules/color-convert": {
|
"node_modules/table/node_modules/color-convert": {
|
||||||
@ -3656,9 +3496,6 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/chalk/slice-ansi?sponsor=1"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/telegraf": {
|
"node_modules/telegraf": {
|
||||||
@ -3741,18 +3578,15 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/tsutils": {
|
"node_modules/tsutils": {
|
||||||
"version": "3.17.1",
|
"version": "3.18.0",
|
||||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz",
|
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.18.0.tgz",
|
||||||
"integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==",
|
"integrity": "sha512-D9Tu8nE3E7D1Bsf/V29oMHceMf+gnVO+pDguk/A5YRo1cLpkiQ48ZnbbS57pvvHeY+OIeNQx1vf4ASPlEtRpcA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tslib": "^1.8.1"
|
"tslib": "^1.8.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 6"
|
"node": ">= 6"
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/type-check": {
|
"node_modules/type-check": {
|
||||||
@ -3777,9 +3611,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/typedoc": {
|
"node_modules/typedoc": {
|
||||||
"version": "0.20.9",
|
"version": "0.20.13",
|
||||||
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.20.9.tgz",
|
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.20.13.tgz",
|
||||||
"integrity": "sha512-GCaE9Hn+VFY2i9wBxFbCv/KZCgHw4+6hiYRdJ0y2DudcWvpgLeCIBJYP1e70MtKCZzs4FT+ydLxInr/hyXrY4Q==",
|
"integrity": "sha512-SJVFn6NJd5bWJHMPgEkDUrKIEfMbja6ftIJv/tgd0xQZp5cWxGTdEnmRr56+egIQZkAJFB39eDvmNV4Lqqy4Gw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"colors": "^1.4.0",
|
"colors": "^1.4.0",
|
||||||
@ -4191,13 +4025,13 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@typescript-eslint/eslint-plugin": {
|
"@typescript-eslint/eslint-plugin": {
|
||||||
"version": "4.11.1",
|
"version": "4.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.12.0.tgz",
|
||||||
"integrity": "sha512-fABclAX2QIEDmTMk6Yd7Muv1CzFLwWM4505nETzRHpP3br6jfahD9UUJkhnJ/g2m7lwfz8IlswcwGGPGiq9exw==",
|
"integrity": "sha512-wHKj6q8s70sO5i39H2g1gtpCXCvjVszzj6FFygneNFyIAxRvNSVz9GML7XpqrB9t7hNutXw+MHnLN/Ih6uyB8Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@typescript-eslint/experimental-utils": "4.11.1",
|
"@typescript-eslint/experimental-utils": "4.12.0",
|
||||||
"@typescript-eslint/scope-manager": "4.11.1",
|
"@typescript-eslint/scope-manager": "4.12.0",
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"functional-red-black-tree": "^1.0.1",
|
"functional-red-black-tree": "^1.0.1",
|
||||||
"regexpp": "^3.0.0",
|
"regexpp": "^3.0.0",
|
||||||
@ -4206,55 +4040,55 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@typescript-eslint/experimental-utils": {
|
"@typescript-eslint/experimental-utils": {
|
||||||
"version": "4.11.1",
|
"version": "4.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.12.0.tgz",
|
||||||
"integrity": "sha512-mAlWowT4A6h0TC9F+J5pdbEhjNiEMO+kqPKQ4sc3fVieKL71dEqfkKgtcFVSX3cjSBwYwhImaQ/mXQF0oaI38g==",
|
"integrity": "sha512-MpXZXUAvHt99c9ScXijx7i061o5HEjXltO+sbYfZAAHxv3XankQkPaNi5myy0Yh0Tyea3Hdq1pi7Vsh0GJb0fA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/json-schema": "^7.0.3",
|
"@types/json-schema": "^7.0.3",
|
||||||
"@typescript-eslint/scope-manager": "4.11.1",
|
"@typescript-eslint/scope-manager": "4.12.0",
|
||||||
"@typescript-eslint/types": "4.11.1",
|
"@typescript-eslint/types": "4.12.0",
|
||||||
"@typescript-eslint/typescript-estree": "4.11.1",
|
"@typescript-eslint/typescript-estree": "4.12.0",
|
||||||
"eslint-scope": "^5.0.0",
|
"eslint-scope": "^5.0.0",
|
||||||
"eslint-utils": "^2.0.0"
|
"eslint-utils": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@typescript-eslint/parser": {
|
"@typescript-eslint/parser": {
|
||||||
"version": "4.11.1",
|
"version": "4.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.12.0.tgz",
|
||||||
"integrity": "sha512-BJ3jwPQu1jeynJ5BrjLuGfK/UJu6uwHxJ/di7sanqmUmxzmyIcd3vz58PMR7wpi8k3iWq2Q11KMYgZbUpRoIPw==",
|
"integrity": "sha512-9XxVADAo9vlfjfoxnjboBTxYOiNY93/QuvcPgsiKvHxW6tOZx1W4TvkIQ2jB3k5M0pbFP5FlXihLK49TjZXhuQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@typescript-eslint/scope-manager": "4.11.1",
|
"@typescript-eslint/scope-manager": "4.12.0",
|
||||||
"@typescript-eslint/types": "4.11.1",
|
"@typescript-eslint/types": "4.12.0",
|
||||||
"@typescript-eslint/typescript-estree": "4.11.1",
|
"@typescript-eslint/typescript-estree": "4.12.0",
|
||||||
"debug": "^4.1.1"
|
"debug": "^4.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@typescript-eslint/scope-manager": {
|
"@typescript-eslint/scope-manager": {
|
||||||
"version": "4.11.1",
|
"version": "4.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.12.0.tgz",
|
||||||
"integrity": "sha512-Al2P394dx+kXCl61fhrrZ1FTI7qsRDIUiVSuN6rTwss6lUn8uVO2+nnF4AvO0ug8vMsy3ShkbxLu/uWZdTtJMQ==",
|
"integrity": "sha512-QVf9oCSVLte/8jvOsxmgBdOaoe2J0wtEmBr13Yz0rkBNkl5D8bfnf6G4Vhox9qqMIoG7QQoVwd2eG9DM/ge4Qg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@typescript-eslint/types": "4.11.1",
|
"@typescript-eslint/types": "4.12.0",
|
||||||
"@typescript-eslint/visitor-keys": "4.11.1"
|
"@typescript-eslint/visitor-keys": "4.12.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@typescript-eslint/types": {
|
"@typescript-eslint/types": {
|
||||||
"version": "4.11.1",
|
"version": "4.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.12.0.tgz",
|
||||||
"integrity": "sha512-5kvd38wZpqGY4yP/6W3qhYX6Hz0NwUbijVsX2rxczpY6OXaMxh0+5E5uLJKVFwaBM7PJe1wnMym85NfKYIh6CA==",
|
"integrity": "sha512-N2RhGeheVLGtyy+CxRmxdsniB7sMSCfsnbh8K/+RUIXYYq3Ub5+sukRCjVE80QerrUBvuEvs4fDhz5AW/pcL6g==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@typescript-eslint/typescript-estree": {
|
"@typescript-eslint/typescript-estree": {
|
||||||
"version": "4.11.1",
|
"version": "4.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.12.0.tgz",
|
||||||
"integrity": "sha512-tC7MKZIMRTYxQhrVAFoJq/DlRwv1bnqA4/S2r3+HuHibqvbrPcyf858lNzU7bFmy4mLeIHFYr34ar/1KumwyRw==",
|
"integrity": "sha512-gZkFcmmp/CnzqD2RKMich2/FjBTsYopjiwJCroxqHZIY11IIoN0l5lKqcgoAPKHt33H2mAkSfvzj8i44Jm7F4w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@typescript-eslint/types": "4.11.1",
|
"@typescript-eslint/types": "4.12.0",
|
||||||
"@typescript-eslint/visitor-keys": "4.11.1",
|
"@typescript-eslint/visitor-keys": "4.12.0",
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"globby": "^11.0.1",
|
"globby": "^11.0.1",
|
||||||
"is-glob": "^4.0.1",
|
"is-glob": "^4.0.1",
|
||||||
@ -4264,12 +4098,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@typescript-eslint/visitor-keys": {
|
"@typescript-eslint/visitor-keys": {
|
||||||
"version": "4.11.1",
|
"version": "4.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.12.0.tgz",
|
||||||
"integrity": "sha512-IrlBhD9bm4bdYcS8xpWarazkKXlE7iYb1HzRuyBP114mIaj5DJPo11Us1HgH60dTt41TCZXMaTCAW+OILIYPOg==",
|
"integrity": "sha512-hVpsLARbDh4B9TKYz5cLbcdMIOAoBYgFPCSP9FFS/liSF+b33gVNq8JHY3QGhHNVz85hObvL7BEYLlgx553WCw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@typescript-eslint/types": "4.11.1",
|
"@typescript-eslint/types": "4.12.0",
|
||||||
"eslint-visitor-keys": "^2.0.0"
|
"eslint-visitor-keys": "^2.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -4291,8 +4125,7 @@
|
|||||||
"version": "5.3.1",
|
"version": "5.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz",
|
||||||
"integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==",
|
"integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"aggregate-error": {
|
"aggregate-error": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
@ -4784,8 +4617,7 @@
|
|||||||
"version": "7.1.0",
|
"version": "7.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-7.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-7.1.0.tgz",
|
||||||
"integrity": "sha512-9sm5/PxaFG7qNJvJzTROMM1Bk1ozXVTKI0buKOyb0Bsr1hrwi0H/TzxF/COtf1uxikIK8SwhX7K6zg78jAzbeA==",
|
"integrity": "sha512-9sm5/PxaFG7qNJvJzTROMM1Bk1ozXVTKI0buKOyb0Bsr1hrwi0H/TzxF/COtf1uxikIK8SwhX7K6zg78jAzbeA==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"eslint-import-resolver-node": {
|
"eslint-import-resolver-node": {
|
||||||
"version": "0.3.4",
|
"version": "0.3.4",
|
||||||
@ -6859,9 +6691,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"tsutils": {
|
"tsutils": {
|
||||||
"version": "3.17.1",
|
"version": "3.18.0",
|
||||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz",
|
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.18.0.tgz",
|
||||||
"integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==",
|
"integrity": "sha512-D9Tu8nE3E7D1Bsf/V29oMHceMf+gnVO+pDguk/A5YRo1cLpkiQ48ZnbbS57pvvHeY+OIeNQx1vf4ASPlEtRpcA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"tslib": "^1.8.1"
|
"tslib": "^1.8.1"
|
||||||
@ -6883,9 +6715,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"typedoc": {
|
"typedoc": {
|
||||||
"version": "0.20.9",
|
"version": "0.20.13",
|
||||||
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.20.9.tgz",
|
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.20.13.tgz",
|
||||||
"integrity": "sha512-GCaE9Hn+VFY2i9wBxFbCv/KZCgHw4+6hiYRdJ0y2DudcWvpgLeCIBJYP1e70MtKCZzs4FT+ydLxInr/hyXrY4Q==",
|
"integrity": "sha512-SJVFn6NJd5bWJHMPgEkDUrKIEfMbja6ftIJv/tgd0xQZp5cWxGTdEnmRr56+egIQZkAJFB39eDvmNV4Lqqy4Gw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"colors": "^1.4.0",
|
"colors": "^1.4.0",
|
||||||
|
22
package.json
22
package.json
@ -21,8 +21,19 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "Alexander Bukhalo <a@bukhalo.com>",
|
"author": "Alexander Bukhalo <a@bukhalo.com>",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"Alexander Bukhalo <a@bukhalo.com> (https://bukhalo.com/)"
|
{
|
||||||
|
"name": "Arthur Asimov",
|
||||||
|
"email": "arthur.asimov.z0@gmail.com"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "individual",
|
||||||
|
"url": "https://www.tinkoff.ru/sl/95M2htqoxux"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "./dist/index.js",
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
"repository": "git@github.com:bukhalo/nestjs-telegraf.git",
|
"repository": "git@github.com:bukhalo/nestjs-telegraf.git",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rm -rf dist && tsc -p tsconfig.json",
|
"build": "rm -rf dist && tsc -p tsconfig.json",
|
||||||
@ -39,8 +50,8 @@
|
|||||||
"@nestjs/common": "7.6.5",
|
"@nestjs/common": "7.6.5",
|
||||||
"@nestjs/core": "7.6.5",
|
"@nestjs/core": "7.6.5",
|
||||||
"@types/lodash": "4.14.167",
|
"@types/lodash": "4.14.167",
|
||||||
"@typescript-eslint/eslint-plugin": "4.11.1",
|
"@typescript-eslint/eslint-plugin": "4.12.0",
|
||||||
"@typescript-eslint/parser": "4.11.1",
|
"@typescript-eslint/parser": "4.12.0",
|
||||||
"eslint": "7.17.0",
|
"eslint": "7.17.0",
|
||||||
"eslint-config-prettier": "7.1.0",
|
"eslint-config-prettier": "7.1.0",
|
||||||
"eslint-plugin-import": "2.22.1",
|
"eslint-plugin-import": "2.22.1",
|
||||||
@ -50,7 +61,7 @@
|
|||||||
"prettier": "2.2.1",
|
"prettier": "2.2.1",
|
||||||
"reflect-metadata": "0.1.13",
|
"reflect-metadata": "0.1.13",
|
||||||
"rxjs": "6.6.3",
|
"rxjs": "6.6.3",
|
||||||
"typedoc": "0.20.9",
|
"typedoc": "0.20.13",
|
||||||
"typescript": "4.1.3"
|
"typescript": "4.1.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
@ -65,8 +76,7 @@
|
|||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.ts": [
|
"*.ts": [
|
||||||
"prettier --write",
|
"prettier --write"
|
||||||
"git add"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
sample/01-complete-app/.env.example
Normal file
2
sample/01-complete-app/.env.example
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
ECHO_BOT_TOKEN=
|
||||||
|
GREETER_BOT_TOKEN=
|
25
sample/01-complete-app/.eslintrc.js
Normal file
25
sample/01-complete-app/.eslintrc.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
module.exports = {
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
parserOptions: {
|
||||||
|
project: 'tsconfig.json',
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
plugins: ['@typescript-eslint/eslint-plugin'],
|
||||||
|
extends: [
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'prettier/@typescript-eslint',
|
||||||
|
'plugin:prettier/recommended',
|
||||||
|
],
|
||||||
|
root: true,
|
||||||
|
env: {
|
||||||
|
node: true,
|
||||||
|
jest: true,
|
||||||
|
},
|
||||||
|
ignorePatterns: ['.eslintrc.js'],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/interface-name-prefix': 'off',
|
||||||
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||||
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
},
|
||||||
|
};
|
398
sample/01-complete-app/.gitignore
vendored
Normal file
398
sample/01-complete-app/.gitignore
vendored
Normal file
@ -0,0 +1,398 @@
|
|||||||
|
# Created by .ignore support plugin (hsz.mobi)
|
||||||
|
### JetBrains template
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff:
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/dictionaries
|
||||||
|
|
||||||
|
# Sensitive or high-churn files:
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.xml
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
|
||||||
|
# Gradle:
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-debug/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin:
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
## File-based project format:
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
## Plugin-specific files:
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
### VisualStudio template
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
|
||||||
|
# Visual Studio 2015 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUNIT
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
**/Properties/launchSettings.json
|
||||||
|
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_i.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# JustCode is a .NET coding add-in
|
||||||
|
.JustCode
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Typescript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
.idea/
|
||||||
|
*.sln.iml
|
||||||
|
|
||||||
|
# IDE - VSCode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
|
||||||
|
# CodeRush
|
||||||
|
.cr/
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
coverage/
|
||||||
|
|
||||||
|
### macOS template
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
=======
|
||||||
|
# Local
|
||||||
|
.env
|
||||||
|
dist
|
14
sample/01-complete-app/jest.json
Normal file
14
sample/01-complete-app/jest.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"moduleFileExtensions": [
|
||||||
|
"ts",
|
||||||
|
"tsx",
|
||||||
|
"js",
|
||||||
|
"json"
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.tsx?$": "ts-jest"
|
||||||
|
},
|
||||||
|
"testRegex": "/src/.*\\.(test|spec).(ts|tsx|js)$",
|
||||||
|
"collectCoverageFrom" : ["src/**/*.{js,jsx,tsx,ts}", "!**/node_modules/**", "!**/vendor/**"],
|
||||||
|
"coverageReporters": ["json", "lcov"]
|
||||||
|
}
|
9917
sample/01-complete-app/package-lock.json
generated
Normal file
9917
sample/01-complete-app/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
72
sample/01-complete-app/package.json
Normal file
72
sample/01-complete-app/package.json
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
{
|
||||||
|
"name": "nest-typescript-starter",
|
||||||
|
"private": true,
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Nest TypeScript starter repository",
|
||||||
|
"license": "MIT",
|
||||||
|
"scripts": {
|
||||||
|
"prebuild": "rimraf dist",
|
||||||
|
"build": "nest build",
|
||||||
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||||
|
"start": "nest start",
|
||||||
|
"start:dev": "nest start --watch",
|
||||||
|
"start:debug": "nest start --debug --watch",
|
||||||
|
"start:prod": "node dist/main",
|
||||||
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||||
|
"test": "jest",
|
||||||
|
"test:watch": "jest --watch",
|
||||||
|
"test:cov": "jest --coverage",
|
||||||
|
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||||
|
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@nestjs/common": "7.6.5",
|
||||||
|
"@nestjs/core": "7.6.5",
|
||||||
|
"@nestjs/platform-express": "7.6.5",
|
||||||
|
"dotenv": "8.2.0",
|
||||||
|
"nestjs-telegraf": "*",
|
||||||
|
"reflect-metadata": "0.1.13",
|
||||||
|
"rimraf": "3.0.2",
|
||||||
|
"rxjs": "6.6.3",
|
||||||
|
"telegraf": "3.38.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nestjs/cli": "7.5.4",
|
||||||
|
"@nestjs/schematics": "7.2.6",
|
||||||
|
"@nestjs/testing": "7.6.5",
|
||||||
|
"@types/express": "4.17.9",
|
||||||
|
"@types/jest": "26.0.19",
|
||||||
|
"@types/node": "14.14.20",
|
||||||
|
"@types/supertest": "2.0.10",
|
||||||
|
"@typescript-eslint/eslint-plugin": "4.12.0",
|
||||||
|
"@typescript-eslint/parser": "4.12.0",
|
||||||
|
"eslint": "7.12.1",
|
||||||
|
"eslint-config-prettier": "6.15.0",
|
||||||
|
"eslint-plugin-prettier": "3.3.1",
|
||||||
|
"jest": "26.6.3",
|
||||||
|
"prettier": "2.1.2",
|
||||||
|
"supertest": "6.0.1",
|
||||||
|
"ts-jest": "26.4.4",
|
||||||
|
"ts-loader": "8.0.14",
|
||||||
|
"ts-node": "9.1.1",
|
||||||
|
"tsconfig-paths": "3.9.0",
|
||||||
|
"typescript": "4.1.3"
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"moduleFileExtensions": [
|
||||||
|
"js",
|
||||||
|
"json",
|
||||||
|
"ts"
|
||||||
|
],
|
||||||
|
"rootDir": "src",
|
||||||
|
"testRegex": ".*\\.spec\\.ts$",
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.(t|j)s$": "ts-jest"
|
||||||
|
},
|
||||||
|
"collectCoverageFrom": [
|
||||||
|
"**/*.(t|j)s"
|
||||||
|
],
|
||||||
|
"coverageDirectory": "../coverage",
|
||||||
|
"testEnvironment": "node"
|
||||||
|
}
|
||||||
|
}
|
@ -1 +1,3 @@
|
|||||||
export const HELLO_SCENE_ID = 'HELLO_SCENE_ID';
|
export const HELLO_SCENE_ID = 'HELLO_SCENE_ID';
|
||||||
|
|
||||||
|
export const GreeterBotName = 'greeter';
|
27
sample/01-complete-app/src/app.module.ts
Normal file
27
sample/01-complete-app/src/app.module.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { TelegrafModule } from 'nestjs-telegraf';
|
||||||
|
import { EchoModule } from './echo/echo.module';
|
||||||
|
import { GreeterModule } from './greeter/greeter.module';
|
||||||
|
import { sessionMiddleware } from './middleware/session.middleware';
|
||||||
|
import { GreeterBotName } from './app.constants';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
TelegrafModule.forRoot({
|
||||||
|
token: process.env.ECHO_BOT_TOKEN,
|
||||||
|
middlewares: [sessionMiddleware],
|
||||||
|
include: [EchoModule],
|
||||||
|
}),
|
||||||
|
TelegrafModule.forRootAsync({
|
||||||
|
botName: GreeterBotName,
|
||||||
|
useFactory: () => ({
|
||||||
|
token: process.env.GREETER_BOT_TOKEN,
|
||||||
|
middlewares: [sessionMiddleware],
|
||||||
|
include: [GreeterModule],
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
EchoModule,
|
||||||
|
GreeterModule,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class AppModule {}
|
9
sample/01-complete-app/src/echo/echo.module.ts
Normal file
9
sample/01-complete-app/src/echo/echo.module.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { EchoUpdate } from './echo.update';
|
||||||
|
import { EchoService } from './echo.service';
|
||||||
|
import { HelloScene } from './scenes/hello.scene';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [EchoUpdate, EchoService, HelloScene],
|
||||||
|
})
|
||||||
|
export class EchoModule {}
|
@ -1,14 +1,22 @@
|
|||||||
import { Telegraf } from 'telegraf';
|
import { Telegraf } from 'telegraf';
|
||||||
import { Command, Help, InjectBot, On, Start, Update } from '../lib';
|
import {
|
||||||
|
Command,
|
||||||
|
getBotToken,
|
||||||
|
Help,
|
||||||
|
InjectBot,
|
||||||
|
On,
|
||||||
|
Start,
|
||||||
|
Update,
|
||||||
|
} from 'nestjs-telegraf';
|
||||||
import { EchoService } from './echo.service';
|
import { EchoService } from './echo.service';
|
||||||
import { HELLO_SCENE_ID } from './app.constants';
|
import { GreeterBotName, HELLO_SCENE_ID } from '../app.constants';
|
||||||
import { Context } from './interfaces/context.interface';
|
import { Context } from '../interfaces/context.interface';
|
||||||
|
|
||||||
@Update()
|
@Update()
|
||||||
export class AppUpdate {
|
export class EchoUpdate {
|
||||||
constructor(
|
constructor(
|
||||||
@InjectBot()
|
@InjectBot(GreeterBotName)
|
||||||
private readonly bot: Telegraf<any>, // TODO: fix any
|
private readonly bot: Telegraf<Context>,
|
||||||
private readonly echoService: EchoService,
|
private readonly echoService: EchoService,
|
||||||
) {}
|
) {}
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
import { HELLO_SCENE_ID } from '../app.constants';
|
import { Scene, SceneEnter, SceneLeave, Command } from 'nestjs-telegraf';
|
||||||
import { Context } from '../interfaces/context.interface';
|
import { HELLO_SCENE_ID } from '../../app.constants';
|
||||||
import { Scene, SceneEnter, SceneLeave, Command } from '../../lib';
|
import { Context } from '../../interfaces/context.interface';
|
||||||
|
|
||||||
@Scene(HELLO_SCENE_ID)
|
@Scene(HELLO_SCENE_ID)
|
||||||
export class HelloScene {
|
export class HelloScene {
|
7
sample/01-complete-app/src/greeter/greeter.module.ts
Normal file
7
sample/01-complete-app/src/greeter/greeter.module.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { GreeterUpdate } from './greeter.update';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [GreeterUpdate],
|
||||||
|
})
|
||||||
|
export class GreeterModule {}
|
16
sample/01-complete-app/src/greeter/greeter.update.ts
Normal file
16
sample/01-complete-app/src/greeter/greeter.update.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { Hears, Start, Update } from '../../../../lib';
|
||||||
|
import { Context } from '../interfaces/context.interface';
|
||||||
|
|
||||||
|
@Update()
|
||||||
|
export class GreeterUpdate {
|
||||||
|
@Start()
|
||||||
|
async onStart(ctx: Context): Promise<void> {
|
||||||
|
await ctx.reply('Say hello to me');
|
||||||
|
}
|
||||||
|
|
||||||
|
@Hears(['hi', 'hello', 'hey', 'qq'])
|
||||||
|
async onGreetings(ctx: Context): Promise<void> {
|
||||||
|
const { first_name } = ctx.from;
|
||||||
|
await ctx.reply(`Hey ${first_name}`);
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'dotenv/config';
|
||||||
import { NestFactory } from '@nestjs/core';
|
import { NestFactory } from '@nestjs/core';
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
|
|
4
sample/01-complete-app/tsconfig.build.json
Normal file
4
sample/01-complete-app/tsconfig.build.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
|
||||||
|
}
|
16
sample/01-complete-app/tsconfig.json
Normal file
16
sample/01-complete-app/tsconfig.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs",
|
||||||
|
"declaration": true,
|
||||||
|
"removeComments": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"target": "es2017",
|
||||||
|
"sourceMap": true,
|
||||||
|
"outDir": "./dist",
|
||||||
|
"baseUrl": "./src",
|
||||||
|
"incremental": true
|
||||||
|
},
|
||||||
|
"include": ["src/**/*"]
|
||||||
|
}
|
@ -1,17 +0,0 @@
|
|||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { TelegrafModule } from '../lib';
|
|
||||||
import { EchoService } from './echo.service';
|
|
||||||
import { AppUpdate } from './app.update';
|
|
||||||
import { HelloScene } from './scenes/hello.scene';
|
|
||||||
import { sessionMiddleware } from './middleware/session.middleware';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
imports: [
|
|
||||||
TelegrafModule.forRoot({
|
|
||||||
token: '1467731595:AAHCvH65H9VQYKF9jE-E8c2rXsQBVAYseg8', // Don't steal >:(
|
|
||||||
middlewares: [sessionMiddleware],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
providers: [EchoService, AppUpdate, HelloScene],
|
|
||||||
})
|
|
||||||
export class AppModule {}
|
|
@ -7,12 +7,12 @@
|
|||||||
"noLib": false,
|
"noLib": false,
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"target": "es6",
|
"target": "es2017",
|
||||||
"sourceMap": false,
|
"sourceMap": false,
|
||||||
"outDir": "./dist",
|
|
||||||
"rootDir": "./lib",
|
"rootDir": "./lib",
|
||||||
|
"outDir": "./dist",
|
||||||
"skipLibCheck": true
|
"skipLibCheck": true
|
||||||
},
|
},
|
||||||
"include": ["lib/**/*", "../index.ts"],
|
"include": ["lib/**/*"],
|
||||||
"exclude": ["node_modules", "**/*.spec.ts"]
|
"exclude": ["node_modules", "**/*.spec.ts"]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user