Skip to content

Commit

Permalink
f235472195c42b056104053a3a5297ee24bef9df
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Apr 3, 2024
1 parent 2b2112f commit dffab11
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 14 deletions.
3 changes: 2 additions & 1 deletion esm/client/1_business_connection_manager.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { enums, types } from "../2_tl.js";
import { Update } from "../3_types.js";
import { C } from "./0_types.js";
export type BusinessConnectionManagerUpdate = types.UpdateBotBusinessConnect;
export declare class BusinessConnectionManager {
#private;
constructor(c: C);
getBusinessConnection(id: string): Promise<import("../3_types.js").BusinessConnection>;
static canHandleUpdate(update: enums.Update): update is BusinessConnectionManagerUpdate;
handleUpdate(update: BusinessConnectionManagerUpdate): Promise<void>;
handleUpdate(update: BusinessConnectionManagerUpdate): Promise<Update>;
}
9 changes: 8 additions & 1 deletion esm/client/1_business_connection_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ export class BusinessConnectionManager {
return update instanceof types.UpdateBotBusinessConnect;
}
async handleUpdate(update) {
await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.setBusinessConnection(update.connection.connection_id, update.connection);
if (update.connection.disabled) {
await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.setBusinessConnection(update.connection.connection_id, null);
}
else {
await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.setBusinessConnection(update.connection.connection_id, update.connection);
}
const businessConnection = await constructBusinessConnection(update.connection, __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").getEntity);
return { businessConnection };
}
}
_BusinessConnectionManager_c = new WeakMap();
2 changes: 1 addition & 1 deletion esm/client/4_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2242,7 +2242,7 @@ _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
}
}
if (BusinessConnectionManager.canHandleUpdate(update)) {
await __classPrivateFieldGet(this, _Client_businessConnectionManager, "f").handleUpdate(update);
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, await __classPrivateFieldGet(this, _Client_businessConnectionManager, "f").handleUpdate(update)));
}
return () => Promise.all(promises);
}, _Client_getMe = async function _Client_getMe() {
Expand Down
2 changes: 1 addition & 1 deletion esm/storage/0_storage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export declare abstract class Storage {
setFilePartCount(id: bigint, partCount: number, chunkSize: number): Promise<void>;
setCustomEmojiDocument(id: bigint, document: types.Document): Promise<void>;
getCustomEmojiDocument(id: bigint): Promise<[types.Document, Date] | null>;
setBusinessConnection(id: string, connection: types.BotBusinessConnection): Promise<void>;
setBusinessConnection(id: string, connection: types.BotBusinessConnection | null): Promise<void>;
getBusinessConnection(id: string): Promise<types.BotBusinessConnection | null>;
setUpdate(boxId: bigint, update: enums.Update): Promise<void>;
deleteUpdates(): Promise<void>;
Expand Down
2 changes: 1 addition & 1 deletion esm/storage/0_storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export class Storage {
}
}
async setBusinessConnection(id, connection) {
await this.set(K.cache.businessConnection(id), this.isMemoryStorage ? connection : rleEncode(connection[serialize]()));
await this.set(K.cache.businessConnection(id), connection == null ? null : this.isMemoryStorage ? connection : rleEncode(connection[serialize]()));
}
async getBusinessConnection(id) {
const v = await this.get(K.cache.businessConnection(id));
Expand Down
13 changes: 11 additions & 2 deletions esm/types/6_update.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AuthorizationState } from "./0_authorization_state.js";
import { ConnectionState } from "./0_connection_state.js";
import { MessageReference } from "./0_message_reference.js";
import { StoryReference } from "./0_story_reference.js";
import { BusinessConnection } from "./2_business_connection.js";
import { ChosenInlineResult } from "./2_chosen_inline_result.js";
import { InlineQuery } from "./2_inline_query.js";
import { MessageInteractions } from "./2_message_interactions.js";
Expand Down Expand Up @@ -214,6 +215,13 @@ export interface UpdateDeletedStory {
export interface UpdateNewStory {
story: Story;
}
/**
* A business connection was added, modified, or removed.
* @unlisted
*/
export interface UpdateBusinessConnection {
businessConnection: BusinessConnection;
}
/** @unlisted */
export interface UpdateMap {
message: UpdateNewMessage;
Expand All @@ -234,8 +242,9 @@ export interface UpdateMap {
myChatMember: UpdateMyChatMember;
deletedStory: UpdateDeletedStory;
story: UpdateNewStory;
businessConnection: UpdateBusinessConnection;
}
/** @unlisted */
export type UpdateIntersection<T> = T & Partial<UpdateConnectionState & UpdateAuthorizationState & UpdateNewMessage & UpdateEditedMessage & UpdateDeletedMessages & UpdateCallbackQuery & UpdateInlineQuery & UpdateChosenInlineResult & UpdateNewChat & UpdateEditedChat & UpdateDeletedChat & UpdateMessageInteractions & UpdateMessageReactionCount & UpdateMessageReactions & UpdateChatMember & UpdateMyChatMember & UpdateDeletedStory & UpdateNewStory>;
export type UpdateIntersection<T> = T & Partial<UpdateConnectionState & UpdateAuthorizationState & UpdateNewMessage & UpdateEditedMessage & UpdateDeletedMessages & UpdateCallbackQuery & UpdateInlineQuery & UpdateChosenInlineResult & UpdateNewChat & UpdateEditedChat & UpdateDeletedChat & UpdateMessageInteractions & UpdateMessageReactionCount & UpdateMessageReactions & UpdateChatMember & UpdateMyChatMember & UpdateDeletedStory & UpdateNewStory & UpdateBusinessConnection>;
/** An incoming update. */
export type Update = UpdateConnectionState | UpdateAuthorizationState | UpdateNewMessage | UpdateEditedMessage | UpdateDeletedMessages | UpdateCallbackQuery | UpdateInlineQuery | UpdateChosenInlineResult | UpdateNewChat | UpdateEditedChat | UpdateDeletedChat | UpdateMessageInteractions | UpdateMessageReactionCount | UpdateMessageReactions | UpdateChatMember | UpdateMyChatMember | UpdateDeletedStory | UpdateNewStory;
export type Update = UpdateConnectionState | UpdateAuthorizationState | UpdateNewMessage | UpdateEditedMessage | UpdateDeletedMessages | UpdateCallbackQuery | UpdateInlineQuery | UpdateChosenInlineResult | UpdateNewChat | UpdateEditedChat | UpdateDeletedChat | UpdateMessageInteractions | UpdateMessageReactionCount | UpdateMessageReactions | UpdateChatMember | UpdateMyChatMember | UpdateDeletedStory | UpdateNewStory | UpdateBusinessConnection;
3 changes: 2 additions & 1 deletion script/client/1_business_connection_manager.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { enums, types } from "../2_tl.js";
import { Update } from "../3_types.js";
import { C } from "./0_types.js";
export type BusinessConnectionManagerUpdate = types.UpdateBotBusinessConnect;
export declare class BusinessConnectionManager {
#private;
constructor(c: C);
getBusinessConnection(id: string): Promise<import("../3_types.js").BusinessConnection>;
static canHandleUpdate(update: enums.Update): update is BusinessConnectionManagerUpdate;
handleUpdate(update: BusinessConnectionManagerUpdate): Promise<void>;
handleUpdate(update: BusinessConnectionManagerUpdate): Promise<Update>;
}
9 changes: 8 additions & 1 deletion script/client/1_business_connection_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ class BusinessConnectionManager {
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);
if (update.connection.disabled) {
await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.setBusinessConnection(update.connection.connection_id, null);
}
else {
await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.setBusinessConnection(update.connection.connection_id, update.connection);
}
const businessConnection = await (0, _3_types_js_1.constructBusinessConnection)(update.connection, __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").getEntity);
return { businessConnection };
}
}
exports.BusinessConnectionManager = BusinessConnectionManager;
Expand Down
2 changes: 1 addition & 1 deletion script/client/4_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,7 @@ _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
}
}
if (_1_business_connection_manager_js_1.BusinessConnectionManager.canHandleUpdate(update)) {
await __classPrivateFieldGet(this, _Client_businessConnectionManager, "f").handleUpdate(update);
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, await __classPrivateFieldGet(this, _Client_businessConnectionManager, "f").handleUpdate(update)));
}
return () => Promise.all(promises);
}, _Client_getMe = async function _Client_getMe() {
Expand Down
2 changes: 1 addition & 1 deletion script/storage/0_storage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export declare abstract class Storage {
setFilePartCount(id: bigint, partCount: number, chunkSize: number): Promise<void>;
setCustomEmojiDocument(id: bigint, document: types.Document): Promise<void>;
getCustomEmojiDocument(id: bigint): Promise<[types.Document, Date] | null>;
setBusinessConnection(id: string, connection: types.BotBusinessConnection): Promise<void>;
setBusinessConnection(id: string, connection: types.BotBusinessConnection | null): Promise<void>;
getBusinessConnection(id: string): Promise<types.BotBusinessConnection | null>;
setUpdate(boxId: bigint, update: enums.Update): Promise<void>;
deleteUpdates(): Promise<void>;
Expand Down
2 changes: 1 addition & 1 deletion script/storage/0_storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class Storage {
}
}
async setBusinessConnection(id, connection) {
await this.set(exports.K.cache.businessConnection(id), this.isMemoryStorage ? connection : (0, _1_utilities_js_1.rleEncode)(connection[_2_tl_js_1.serialize]()));
await this.set(exports.K.cache.businessConnection(id), connection == null ? null : this.isMemoryStorage ? connection : (0, _1_utilities_js_1.rleEncode)(connection[_2_tl_js_1.serialize]()));
}
async getBusinessConnection(id) {
const v = await this.get(exports.K.cache.businessConnection(id));
Expand Down
13 changes: 11 additions & 2 deletions script/types/6_update.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AuthorizationState } from "./0_authorization_state.js";
import { ConnectionState } from "./0_connection_state.js";
import { MessageReference } from "./0_message_reference.js";
import { StoryReference } from "./0_story_reference.js";
import { BusinessConnection } from "./2_business_connection.js";
import { ChosenInlineResult } from "./2_chosen_inline_result.js";
import { InlineQuery } from "./2_inline_query.js";
import { MessageInteractions } from "./2_message_interactions.js";
Expand Down Expand Up @@ -214,6 +215,13 @@ export interface UpdateDeletedStory {
export interface UpdateNewStory {
story: Story;
}
/**
* A business connection was added, modified, or removed.
* @unlisted
*/
export interface UpdateBusinessConnection {
businessConnection: BusinessConnection;
}
/** @unlisted */
export interface UpdateMap {
message: UpdateNewMessage;
Expand All @@ -234,8 +242,9 @@ export interface UpdateMap {
myChatMember: UpdateMyChatMember;
deletedStory: UpdateDeletedStory;
story: UpdateNewStory;
businessConnection: UpdateBusinessConnection;
}
/** @unlisted */
export type UpdateIntersection<T> = T & Partial<UpdateConnectionState & UpdateAuthorizationState & UpdateNewMessage & UpdateEditedMessage & UpdateDeletedMessages & UpdateCallbackQuery & UpdateInlineQuery & UpdateChosenInlineResult & UpdateNewChat & UpdateEditedChat & UpdateDeletedChat & UpdateMessageInteractions & UpdateMessageReactionCount & UpdateMessageReactions & UpdateChatMember & UpdateMyChatMember & UpdateDeletedStory & UpdateNewStory>;
export type UpdateIntersection<T> = T & Partial<UpdateConnectionState & UpdateAuthorizationState & UpdateNewMessage & UpdateEditedMessage & UpdateDeletedMessages & UpdateCallbackQuery & UpdateInlineQuery & UpdateChosenInlineResult & UpdateNewChat & UpdateEditedChat & UpdateDeletedChat & UpdateMessageInteractions & UpdateMessageReactionCount & UpdateMessageReactions & UpdateChatMember & UpdateMyChatMember & UpdateDeletedStory & UpdateNewStory & UpdateBusinessConnection>;
/** An incoming update. */
export type Update = UpdateConnectionState | UpdateAuthorizationState | UpdateNewMessage | UpdateEditedMessage | UpdateDeletedMessages | UpdateCallbackQuery | UpdateInlineQuery | UpdateChosenInlineResult | UpdateNewChat | UpdateEditedChat | UpdateDeletedChat | UpdateMessageInteractions | UpdateMessageReactionCount | UpdateMessageReactions | UpdateChatMember | UpdateMyChatMember | UpdateDeletedStory | UpdateNewStory;
export type Update = UpdateConnectionState | UpdateAuthorizationState | UpdateNewMessage | UpdateEditedMessage | UpdateDeletedMessages | UpdateCallbackQuery | UpdateInlineQuery | UpdateChosenInlineResult | UpdateNewChat | UpdateEditedChat | UpdateDeletedChat | UpdateMessageInteractions | UpdateMessageReactionCount | UpdateMessageReactions | UpdateChatMember | UpdateMyChatMember | UpdateDeletedStory | UpdateNewStory | UpdateBusinessConnection;

0 comments on commit dffab11

Please sign in to comment.