Skip to content

Commit 334a456

Browse files
committed
feat: add pollingOptions to plugin options
1 parent e303d55 commit 334a456

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/plugin.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const plugin: FastifyPluginAsync<FastifyGrammyOptions> = async (
1313
fastify,
1414
options,
1515
) => {
16-
const { name, token } = options
16+
const { name, token, pollingOptions } = options
1717

1818
if (!token) {
1919
throw new MissingBotTokenError()
@@ -46,7 +46,13 @@ const plugin: FastifyPluginAsync<FastifyGrammyOptions> = async (
4646
fastify.addHook('onClose', () => bot.stop())
4747

4848
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+
})
5056
.catch(() => {})
5157
}
5258

src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { FastifyPluginCallback } from 'fastify'
2-
import type { BotConfig, Middleware } from 'grammy'
2+
import type { BotConfig, Middleware, PollingOptions } from 'grammy'
33

44
declare module 'fastify' {
55
export interface FastifyInstance {
@@ -14,4 +14,5 @@ export interface FastifyGrammyOptions {
1414
name?: string
1515
middlewares?: Middleware[]
1616
config?: BotConfig<any>
17+
pollingOptions?: PollingOptions
1718
}

0 commit comments

Comments
 (0)