Comments (6)
@lasthead Hi!
app.module.ts:
@Module({
imports: [
...,
TelegrafModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
botName: 'admin',
useFactory: async (config: ConfigService) => {
return {
middlewares: [adminSessions.middleware()],
token: config.get<string>('BOT_ADMIN_TOKEN'),
include: [AdminBotModule]
}
}
}),
TelegrafModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
botName: 'client',
useFactory: async (config: ConfigService) => {
return {
middlewares: [clientSessions.middleware()],
token: config.get<string>('BOT_CLIENT_TOKEN'),
include: [ClientBotModule]
}
}
}),
AdminBotModule,
ClientBotModule
],
providers: [],
})
export class AppModule {}
client-bot.module.ts:
@Module({
providers: [
ClientBotUpdate,
ClientBotService
],
imports: []
})
export class ClientBotModule {}
admin-bot.module.ts:
@Module({
providers: [
AdminBotUpdate,
AdminBotService
],
imports: []
})
export class AdminBotModule {}
from nestjs-telegraf.
Solved it by dividing into 2 modules: AdminBotModule, ClientBotModule
. And include: [AdminBotModule]
to admin
TelegrafModule.forRootAsync()
, and include: [ClientBotModule]
to client
TelegrafModule.forRootAsync()
from nestjs-telegraf.
@Daniyar111 , Hi! Could you share a more detailed code of your main app.module and AdminBotModule? I trying add a second Bot to my app, but it doesn't work :(
from nestjs-telegraf.
@Daniyar111 , many thanks! However, I don't quite understand what to specify in middleware to divided requests from each other?
For example:
in app1.app.update.ts
@Start() async startCommand(ctx: Context) { await ctx.reply('test') }
in app2.app.update.ts i have the same method and they conflict with each other
I think I misunderstand the concept and... maybe this check needs to be implemented inside the app.update.ts
from nestjs-telegraf.
@lasthead If you did app.module
and bot1.module, bot2.module
as I wrote, it must not conflict with each other.. could you share your more detailed code?
I don't quite understand what to specify in middleware to divided requests from each other
Nothing need to add there.. I added just sessions to middleware, it doesn't affect to requests
maybe this check needs to be implemented inside the app.update.ts
no check needed..
just divide your code structure to
-- bot1
---- bot1.service (for working with db and etc)
---- bot1.update (for Telegram requests)
---- bot1.module (for moduling bot1)
-- bot2
---- bot2.service (for working with db and etc)
---- bot2.update (for Telegram requests)
---- bot2.module (for moduling bot2)
-- app.module
So they must work independent of each other
from nestjs-telegraf.
@Daniyar111 , After your comment, I rechecked my code again and... found my error. I just missed row: imports: [bot.module]
, to TelegrafModule.forRootAsync({ ... })
that's all 🙂. Now it works correctly.
Thank you for your help!
from nestjs-telegraf.
Related Issues (20)
- Not able to handle requests in parallel HOT 1
- Text listeners don`t work in Scene
- Cannot go backwards in wizard
- Incorrect bot shutdown
- Error on lazy TelegrafModule import
- Cannot install on Nest v10 HOT 4
- connect to the same bot from another app HOT 1
- Doesn't work middleware function (blocked other middlewares HOT 1
- How to get callback_data from context HOT 1
- Handle callback_query HOT 2
- Issue with middlewares HOT 1
- Not working properly in Nestjs 10.0.0 version HOT 5
- Multiple Dynamic Bot HOT 1
- pre_checkout_query & successful_payment doesn't work HOT 1
- Bot Error Handling in NestJS Application
- NestJS guard crashing server when canActivate is false HOT 3
- changing bot token while application is running
- scene is undefined in middleware
- How to use wizard with composer? HOT 1
- Webhook(s) for multiple telegram bots HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nestjs-telegraf.