From 348173baca16a69b5cc294e40d93d6776980bb32 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Sun, 8 Sep 2024 16:50:13 +0100 Subject: [PATCH] chore: test --- src/bot/mtproto-api/workrooms.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/bot/mtproto-api/workrooms.ts b/src/bot/mtproto-api/workrooms.ts index bbe89c8..9cb7e10 100644 --- a/src/bot/mtproto-api/workrooms.ts +++ b/src/bot/mtproto-api/workrooms.ts @@ -8,7 +8,7 @@ function isPriceLabelChange(label: string): boolean { } export async function createChat(context: Context<"issues.labeled", SupportedEvents["issues.labeled"]>): Promise { - const { payload, config } = context; + const { payload, config, env } = context; const chatName = payload.issue.title; const labelName = payload.label?.name; @@ -45,12 +45,26 @@ export async function createChat(context: Context<"issues.labeled", SupportedEve } try { - const botEntity = await mtProto.client.getEntity(config.botUsername); + + const bot = await mtProto.client.invoke( + new mtProto.api.auth.ImportBotAuthorization({ + apiId: env.TELEGRAM_APP_ID, + apiHash: env.TELEGRAM_API_HASH, + botAuthToken: env.BOT_TOKEN, + }) + ); + + let botId; + + if (bot.className === "auth.Authorization") { + console.log("auth.Authorization"); + botId = bot.user.id; + } await mtProto.client.invoke( new mtProto.api.messages.AddChatUser({ chatId: chatIdBigInt, - userId: botEntity, + userId: botId, fwdLimit: 50, }) );