diff --git a/esm/client/1_business_connection_manager.d.ts b/esm/client/1_business_connection_manager.d.ts index e84fb8e..282bf84 100644 --- a/esm/client/1_business_connection_manager.d.ts +++ b/esm/client/1_business_connection_manager.d.ts @@ -1,6 +1,10 @@ +import { enums, types } from "../2_tl.js"; import { C } from "./0_types.js"; +export type BusinessConnectionManagerUpdate = types.UpdateBotBusinessConnect; export declare class BusinessConnectionManager { #private; constructor(c: C); getBusinessConnection(id: string): Promise; + static canHandleUpdate(update: enums.Update): update is BusinessConnectionManagerUpdate; + handleUpdate(update: BusinessConnectionManagerUpdate): Promise; } diff --git a/esm/client/1_business_connection_manager.js b/esm/client/1_business_connection_manager.js index f18d8d2..f23dbde 100644 --- a/esm/client/1_business_connection_manager.js +++ b/esm/client/1_business_connection_manager.js @@ -30,5 +30,11 @@ export class BusinessConnectionManager { return await constructBusinessConnection(connection_, __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").getEntity); } } + static canHandleUpdate(update) { + return update instanceof types.UpdateBotBusinessConnect; + } + async handleUpdate(update) { + await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.setBusinessConnection(update.connection.connection_id, update.connection); + } } _BusinessConnectionManager_c = new WeakMap(); diff --git a/esm/client/4_client.js b/esm/client/4_client.js index bf67edd..f3a900e 100644 --- a/esm/client/4_client.js +++ b/esm/client/4_client.js @@ -2241,6 +2241,9 @@ _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) { promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, upd)); } } + if (BusinessConnectionManager.canHandleUpdate(update)) { + await __classPrivateFieldGet(this, _Client_businessConnectionManager, "f").handleUpdate(update); + } return () => Promise.all(promises); }, _Client_getMe = async function _Client_getMe() { if (__classPrivateFieldGet(this, _Client_lastGetMe, "f") != null) { diff --git a/script/client/1_business_connection_manager.d.ts b/script/client/1_business_connection_manager.d.ts index e84fb8e..282bf84 100644 --- a/script/client/1_business_connection_manager.d.ts +++ b/script/client/1_business_connection_manager.d.ts @@ -1,6 +1,10 @@ +import { enums, types } from "../2_tl.js"; import { C } from "./0_types.js"; +export type BusinessConnectionManagerUpdate = types.UpdateBotBusinessConnect; export declare class BusinessConnectionManager { #private; constructor(c: C); getBusinessConnection(id: string): Promise; + static canHandleUpdate(update: enums.Update): update is BusinessConnectionManagerUpdate; + handleUpdate(update: BusinessConnectionManagerUpdate): Promise; } diff --git a/script/client/1_business_connection_manager.js b/script/client/1_business_connection_manager.js index 4df9a5f..6306103 100644 --- a/script/client/1_business_connection_manager.js +++ b/script/client/1_business_connection_manager.js @@ -33,6 +33,12 @@ class BusinessConnectionManager { return await (0, _3_types_js_1.constructBusinessConnection)(connection_, __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").getEntity); } } + static canHandleUpdate(update) { + return update instanceof _2_tl_js_1.types.UpdateBotBusinessConnect; + } + async handleUpdate(update) { + await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.setBusinessConnection(update.connection.connection_id, update.connection); + } } exports.BusinessConnectionManager = BusinessConnectionManager; _BusinessConnectionManager_c = new WeakMap(); diff --git a/script/client/4_client.js b/script/client/4_client.js index 1c6f607..c3433a0 100644 --- a/script/client/4_client.js +++ b/script/client/4_client.js @@ -2246,6 +2246,9 @@ _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) { promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, upd)); } } + if (_1_business_connection_manager_js_1.BusinessConnectionManager.canHandleUpdate(update)) { + await __classPrivateFieldGet(this, _Client_businessConnectionManager, "f").handleUpdate(update); + } return () => Promise.all(promises); }, _Client_getMe = async function _Client_getMe() { if (__classPrivateFieldGet(this, _Client_lastGetMe, "f") != null) {