Skip to content

Commit

Permalink
chore: test
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Sep 8, 2024
1 parent 3d07de6 commit 348173b
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/bot/mtproto-api/workrooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function isPriceLabelChange(label: string): boolean {
}

export async function createChat(context: Context<"issues.labeled", SupportedEvents["issues.labeled"]>): Promise<CallbackResult> {
const { payload, config } = context;
const { payload, config, env } = context;
const chatName = payload.issue.title;

const labelName = payload.label?.name;
Expand Down Expand Up @@ -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,
})
);
Expand Down

0 comments on commit 348173b

Please sign in to comment.