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
|
||||
package-lock.json
|
||||
tsconfig.json
|
||||
.prettierrc
|
||||
.eslintrc.js
|
||||
sample
|
||||
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">
|
||||
<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 ![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)
|
||||
|
||||
# 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)
|
||||
<img align="right" width="95" height="148" title="NestJS logotype"
|
||||
src="https://nestjs.com/img/logo-small.svg">
|
||||
|
||||
[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
|
||||
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
|
||||
```
|
||||
|
||||
## Usage
|
||||
Once the installation process is complete, we can import the `TelegrafModule` into the root `AppModule`:
|
||||
|
||||
```typescript
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TelegrafModule } from 'nestjs-telegraf';
|
||||
@ -36,38 +42,42 @@ import { TelegrafModule } from 'nestjs-telegraf';
|
||||
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
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import {
|
||||
Update,
|
||||
Start,
|
||||
Help,
|
||||
On,
|
||||
Hears,
|
||||
Context,
|
||||
} 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(ctx: Context) {
|
||||
ctx.reply('Welcome');
|
||||
async startCommand(ctx: Context) {
|
||||
await ctx.reply('Welcome');
|
||||
}
|
||||
|
||||
@Help()
|
||||
help(ctx: Context) {
|
||||
ctx.reply('Send me a sticker');
|
||||
async helpCommand(ctx: Context) {
|
||||
await ctx.reply('Send me a sticker');
|
||||
}
|
||||
|
||||
@On('sticker')
|
||||
on(ctx: Context) {
|
||||
ctx.reply('👍');
|
||||
async onSticker(ctx: Context) {
|
||||
await ctx.reply('👍');
|
||||
}
|
||||
|
||||
@Hears('hi')
|
||||
hears(ctx: Context) {
|
||||
ctx.reply('Hey there');
|
||||
async hearsHi(ctx: Context) {
|
||||
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",
|
||||
"version": "2.0.0",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"description": "Telegraf module for NestJS",
|
||||
"keywords": [
|
||||
"nest",
|
||||
@ -23,8 +21,19 @@
|
||||
"license": "MIT",
|
||||
"author": "Alexander Bukhalo <a@bukhalo.com>",
|
||||
"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",
|
||||
"scripts": {
|
||||
"build": "rm -rf dist && tsc -p tsconfig.json",
|
||||
@ -41,8 +50,8 @@
|
||||
"@nestjs/common": "7.6.5",
|
||||
"@nestjs/core": "7.6.5",
|
||||
"@types/lodash": "4.14.167",
|
||||
"@typescript-eslint/eslint-plugin": "4.11.1",
|
||||
"@typescript-eslint/parser": "4.11.1",
|
||||
"@typescript-eslint/eslint-plugin": "4.12.0",
|
||||
"@typescript-eslint/parser": "4.12.0",
|
||||
"eslint": "7.17.0",
|
||||
"eslint-config-prettier": "7.1.0",
|
||||
"eslint-plugin-prettier": "^3.3.1",
|
||||
@ -52,7 +61,7 @@
|
||||
"prettier": "2.2.1",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"rxjs": "6.6.3",
|
||||
"typedoc": "0.20.9",
|
||||
"typedoc": "0.20.13",
|
||||
"typescript": "4.1.3"
|
||||
},
|
||||
"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"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "7.5.1",
|
||||
"@nestjs/core": "7.5.1",
|
||||
"@nestjs/platform-express": "7.5.1",
|
||||
"@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",
|
||||
@ -31,24 +31,24 @@
|
||||
"telegraf": "3.38.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "7.5.1",
|
||||
"@nestjs/schematics": "7.1.3",
|
||||
"@nestjs/testing": "7.5.1",
|
||||
"@types/express": "4.17.8",
|
||||
"@types/jest": "26.0.15",
|
||||
"@types/node": "14.14.6",
|
||||
"@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.6.1",
|
||||
"@typescript-eslint/parser": "4.6.1",
|
||||
"@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.1.4",
|
||||
"eslint-plugin-prettier": "3.3.1",
|
||||
"jest": "26.6.3",
|
||||
"prettier": "2.1.2",
|
||||
"supertest": "6.0.0",
|
||||
"ts-jest": "26.4.3",
|
||||
"ts-loader": "8.0.8",
|
||||
"ts-node": "9.0.0",
|
||||
"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"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user