From df322aeb4f9e66ab9fb621345ff0ae40bb6b4179 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Sun, 8 Sep 2024 15:53:14 +0100 Subject: [PATCH] chore: test --- src/bot/mtproto-api/workrooms.ts | 35 +++++++++++++++++--------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/bot/mtproto-api/workrooms.ts b/src/bot/mtproto-api/workrooms.ts index bf0b739..caf5187 100644 --- a/src/bot/mtproto-api/workrooms.ts +++ b/src/bot/mtproto-api/workrooms.ts @@ -19,25 +19,28 @@ export async function createChat(context: Context<"issues.labeled", SupportedEve }) ); - console.log("Chat created: ", chat.updates.chats); + let chatId: number; + let chatIdBigInt: bigInt.BigInteger; - console.log("Chat ID created: ", chat.updates.chats[0].id); + if ("chats" in chat.updates) { + chatId = chat.updates.chats[0].id.toJSNumber(); + chatIdBigInt = chat.updates.chats[0].id; + } else { + throw new Error("Failed to create chat"); + } + + await context.adapters.supabase.chats.saveChat(chatId, payload.issue.title, payload.issue.node_id); - /** - * updates: { - CONSTRUCTOR_ID: 1957577280, - SUBCLASS_OF_ID: 2331323052, - className: 'Updates', - classType: 'constructor', - updates: [ [Object], [Object], [Object], [Object] ], - users: [ [Object] ], - chats: [ [Object] ], - date: 1725806466, - seq: 0 - }, - */ - // await context.adapters.supabase.chats.saveChat(chatId, payload.issue.title, payload.issue.node_id); + const botId = config.botId; + + await mtProto.client.invoke( + new mtProto.api.messages.AddChatUser({ + chatId: chatIdBigInt, + userId: botId, + fwdLimit: 50, + }) + ); return { status: 200, reason: "chat_created" }; } catch (er) {