mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-01-11 22:51:06 +03:00
Merge remote-tracking branch 'origin/master' into feature/execution-context
This commit is contained in:
commit
3e10acf070
13
.npmignore
13
.npmignore
@ -1,7 +1,10 @@
|
|||||||
# source
|
.github
|
||||||
lib
|
lib
|
||||||
package-lock.json
|
sample
|
||||||
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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
3903
package-lock.json
generated
3903
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
@ -1,8 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nestjs-telegraf",
|
"name": "nestjs-telegraf",
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"main": "./dist/index.js",
|
|
||||||
"types": "./dist/index.d.ts",
|
|
||||||
"description": "Telegraf module for NestJS",
|
"description": "Telegraf module for NestJS",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"nest",
|
"nest",
|
||||||
@ -23,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",
|
||||||
@ -41,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-prettier": "^3.3.1",
|
"eslint-plugin-prettier": "^3.3.1",
|
||||||
@ -52,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": {
|
||||||
|
2860
sample/01-complete-app/package-lock.json
generated
2860
sample/01-complete-app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -20,9 +20,9 @@
|
|||||||
"test:e2e": "jest --config ./test/jest-e2e.json"
|
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nestjs/common": "7.5.1",
|
"@nestjs/common": "7.6.5",
|
||||||
"@nestjs/core": "7.5.1",
|
"@nestjs/core": "7.6.5",
|
||||||
"@nestjs/platform-express": "7.5.1",
|
"@nestjs/platform-express": "7.6.5",
|
||||||
"dotenv": "8.2.0",
|
"dotenv": "8.2.0",
|
||||||
"nestjs-telegraf": "*",
|
"nestjs-telegraf": "*",
|
||||||
"reflect-metadata": "0.1.13",
|
"reflect-metadata": "0.1.13",
|
||||||
@ -31,24 +31,24 @@
|
|||||||
"telegraf": "3.38.0"
|
"telegraf": "3.38.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nestjs/cli": "7.5.1",
|
"@nestjs/cli": "7.5.4",
|
||||||
"@nestjs/schematics": "7.1.3",
|
"@nestjs/schematics": "7.2.6",
|
||||||
"@nestjs/testing": "7.5.1",
|
"@nestjs/testing": "7.6.5",
|
||||||
"@types/express": "4.17.8",
|
"@types/express": "4.17.9",
|
||||||
"@types/jest": "26.0.15",
|
"@types/jest": "26.0.19",
|
||||||
"@types/node": "14.14.6",
|
"@types/node": "14.14.20",
|
||||||
"@types/supertest": "2.0.10",
|
"@types/supertest": "2.0.10",
|
||||||
"@typescript-eslint/eslint-plugin": "4.6.1",
|
"@typescript-eslint/eslint-plugin": "4.12.0",
|
||||||
"@typescript-eslint/parser": "4.6.1",
|
"@typescript-eslint/parser": "4.12.0",
|
||||||
"eslint": "7.12.1",
|
"eslint": "7.12.1",
|
||||||
"eslint-config-prettier": "6.15.0",
|
"eslint-config-prettier": "6.15.0",
|
||||||
"eslint-plugin-prettier": "3.1.4",
|
"eslint-plugin-prettier": "3.3.1",
|
||||||
"jest": "26.6.3",
|
"jest": "26.6.3",
|
||||||
"prettier": "2.1.2",
|
"prettier": "2.1.2",
|
||||||
"supertest": "6.0.0",
|
"supertest": "6.0.1",
|
||||||
"ts-jest": "26.4.3",
|
"ts-jest": "26.4.4",
|
||||||
"ts-loader": "8.0.8",
|
"ts-loader": "8.0.14",
|
||||||
"ts-node": "9.0.0",
|
"ts-node": "9.1.1",
|
||||||
"tsconfig-paths": "3.9.0",
|
"tsconfig-paths": "3.9.0",
|
||||||
"typescript": "4.1.3"
|
"typescript": "4.1.3"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user