From a6c64dc1a09538783ac046db8508244599dbeeb3 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Sun, 8 Sep 2024 17:49:01 +0100 Subject: [PATCH] chore: test --- src/bot/mtproto-api/workrooms.ts | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/src/bot/mtproto-api/workrooms.ts b/src/bot/mtproto-api/workrooms.ts index b178846..d116adf 100644 --- a/src/bot/mtproto-api/workrooms.ts +++ b/src/bot/mtproto-api/workrooms.ts @@ -23,41 +23,14 @@ export async function createChat(context: Context<"issues.labeled", SupportedEve let chatIdBigInt: bigInt.BigInteger; context.logger.info("Creating chat with name: ", { chatName }); - let user; - let userId; - let userAccessHash; - try { - const contacts = await mtProto.client.invoke(new mtProto.api.contacts.GetContacts({})) - if ("users" in contacts) { - user = contacts.users.find((user) => user.id.toJSNumber() === config.botId); - - if (!user) { - throw new Error("Bot user not found"); - } - if ("id" in user) { - userId = user.id; - } - - if ("accessHash" in user) { - userAccessHash = user.accessHash; - } + const bot = await mtProto.client.getPeerId(config.botUsername); - context.logger.info("Bot user found", { user }); - } - } catch (er) { - console.log("Failed to get contacts", er); - throw new Error("Failed to get contacts"); - } - - if (!userId || !userAccessHash) { - throw new Error("Failed to get bot user"); - } const chat = await mtProto.client.invoke( new mtProto.api.messages.CreateChat({ title: chatName, - users: [new mtProto.api.InputUser({ userId: userId, accessHash: userAccessHash })], + users: [bot], }) );