File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ const plugin: FastifyPluginAsync<FastifyGrammyOptions> = async (
13
13
fastify ,
14
14
options ,
15
15
) => {
16
- const { name, token } = options
16
+ const { name, token, pollingOptions } = options
17
17
18
18
if ( ! token ) {
19
19
throw new MissingBotTokenError ( )
@@ -46,7 +46,13 @@ const plugin: FastifyPluginAsync<FastifyGrammyOptions> = async (
46
46
fastify . addHook ( 'onClose' , ( ) => bot . stop ( ) )
47
47
48
48
bot
49
- . start ( { onStart : ( ) => fastify . log . info ( 'Bot started' ) } )
49
+ . start ( {
50
+ ...pollingOptions ,
51
+ onStart : ( botInfo ) => {
52
+ fastify . log . info ( 'Bot started' )
53
+ pollingOptions ?. onStart ?.( botInfo )
54
+ } ,
55
+ } )
50
56
. catch ( ( ) => { } )
51
57
}
52
58
Original file line number Diff line number Diff line change 1
1
import type { FastifyPluginCallback } from 'fastify'
2
- import type { BotConfig , Middleware } from 'grammy'
2
+ import type { BotConfig , Middleware , PollingOptions } from 'grammy'
3
3
4
4
declare module 'fastify' {
5
5
export interface FastifyInstance {
@@ -14,4 +14,5 @@ export interface FastifyGrammyOptions {
14
14
name ?: string
15
15
middlewares ?: Middleware [ ]
16
16
config ?: BotConfig < any >
17
+ pollingOptions ?: PollingOptions
17
18
}
You can’t perform that action at this time.
0 commit comments