Comparing version 0.0.23 to 0.0.24
@@ -82,3 +82,3 @@ import { CallbackData } from "@gramio/callback-data"; | ||
callbackQuery<Trigger extends CallbackData | string | RegExp>(trigger: Trigger, handler: (context: Omit<ContextType<typeof this, "callback_query">, "data"> & Derives["global"] & Derives["callback_query"] & { | ||
data: Trigger extends CallbackData ? ReturnType<Trigger["unpack"]> : RegExpMatchArray | null; | ||
queryData: Trigger extends CallbackData ? ReturnType<Trigger["unpack"]> : RegExpMatchArray | null; | ||
}) => unknown): this; | ||
@@ -93,2 +93,3 @@ hears<Ctx = ContextType<typeof this, "message"> & Derives["global"] & Derives["message"]>(trigger: RegExp | string | ((context: Ctx) => boolean), handler: (context: Ctx & { | ||
group(grouped: (bot: typeof this) => Bot<any, any>): Bot<any, any>; | ||
init(): Promise<void>; | ||
start({ webhook, dropPendingUpdates, allowedUpdates, }?: { | ||
@@ -98,3 +99,5 @@ webhook?: Omit<APIMethodParams<"setWebhook">, "drop_pending_updates" | "allowed_updates">; | ||
allowedUpdates?: NonNullable<APIMethodParams<"getUpdates">>["allowed_updates"]; | ||
}): Promise<TelegramUser>; | ||
}): Promise<TelegramUser | undefined>; | ||
/** Currently does not implement graceful shutdown */ | ||
stop(): Promise<void>; | ||
} |
@@ -87,2 +87,3 @@ "use strict"; | ||
onStart: [], | ||
onStop: [], | ||
}; | ||
@@ -320,3 +321,3 @@ constructor(token, options) { | ||
// @ts-expect-error | ||
context.data = trigger.unpack(context.data); | ||
context.queryData = trigger.unpack(context.data); | ||
//@ts-expect-error | ||
@@ -369,5 +370,8 @@ return handler(context); | ||
} | ||
async start({ webhook, dropPendingUpdates, allowedUpdates, } = {}) { | ||
async init() { | ||
await Promise.all(this.lazyloadPlugins.map(async (plugin) => this.extend(await plugin))); | ||
this.info = await this.api.getMe(); | ||
} | ||
async start({ webhook, dropPendingUpdates, allowedUpdates, } = {}) { | ||
await this.init(); | ||
if (!webhook) { | ||
@@ -382,2 +386,3 @@ await this.api.deleteWebhook({ | ||
plugins: this.dependencies, | ||
// biome-ignore lint/style/noNonNullAssertion: bot.init() guarantees this.info | ||
info: this.info, | ||
@@ -397,2 +402,3 @@ updatesFrom: "long-polling", | ||
plugins: this.dependencies, | ||
// biome-ignore lint/style/noNonNullAssertion: bot.init() guarantees this.info | ||
info: this.info, | ||
@@ -403,2 +409,14 @@ updatesFrom: "webhook", | ||
} | ||
/** Currently does not implement graceful shutdown */ | ||
async stop() { | ||
if (this.updates.isStarted) | ||
this.updates.stopPolling(); | ||
else | ||
await this.api.deleteWebhook(); | ||
await this.runImmutableHooks("onStop", { | ||
plugins: this.dependencies, | ||
// biome-ignore lint/style/noNonNullAssertion: bot.init() guarantees this.info | ||
info: this.info, | ||
}); | ||
} | ||
}; | ||
@@ -405,0 +423,0 @@ return Bot = _classThis; |
@@ -40,2 +40,6 @@ import type { BotLike, Context, UpdateName } from "@gramio/contexts"; | ||
}) => unknown; | ||
type OnStop = (context: { | ||
plugins: string[]; | ||
info: TelegramUser; | ||
}) => unknown; | ||
interface Store<T extends ErrorDefinitions> { | ||
@@ -45,2 +49,3 @@ preRequest: PreRequest[]; | ||
onStart: OnStart[]; | ||
onStop: OnStop[]; | ||
} | ||
@@ -47,0 +52,0 @@ } |
{ | ||
"name": "gramio", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "Powerful Telegram Bot API framework", | ||
@@ -33,3 +33,3 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"@gramio/callback-data": "^0.0.1", | ||
"@gramio/callback-data": "^0.0.2", | ||
"@gramio/contexts": "^0.0.7", | ||
@@ -36,0 +36,0 @@ "@gramio/files": "^0.0.3", |
43223
968
+ Added@gramio/callback-data@0.0.2(transitive)
- Removed@gramio/callback-data@0.0.1(transitive)
Updated@gramio/callback-data@^0.0.2