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 b2381c3 commit 839a701
Showing 1 changed file with 4 additions and 35 deletions.
39 changes: 4 additions & 35 deletions src/bot/mtproto-api/workrooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,48 +44,17 @@ export async function createChat(context: Context<"issues.labeled", SupportedEve
return { status: 500, reason: "chat_create_failed", content: { error: er } };
}

let botId: bigInt.BigInteger | undefined;

try {
botId = new mtProto.api.PeerUser({ userId: bigInt(context.config.botId) }).userId;
console.log("using peer user", botId);
} catch (er) {
console.log(er);
}

if (!botId) {
try {
botId = new mtProto.api.BotInfo({ userId: bigInt(context.config.botId) }).userId
console.log("using bot info", botId);
} catch (er) {
console.log(er);
}
}

if (!botId) {
try {
botId = new mtProto.api.User({ id: bigInt(context.config.botId), bot: true }).id
console.log("using user", botId);
} catch (er) {
console.log(er);
}
}

if (!botId) {
throw new Error("Failed to get bot id");
}


try {
await mtProto.client.invoke(
new mtProto.api.messages.AddChatUser({
chatId: chatIdBigInt,
userId: botId,
fwdLimit: 50,
userId: new mtProto.api.PeerUser({ userId: bigInt(context.config.botId) }),
fwdLimit: 1,
})
);
} catch (er) {
console.log(`Failed to add bot to chat: ${JSON.stringify(er)}`);
console.log(`Failed to add bot to chat: `, er);
throw new Error("Failed to add bot to chat");
}

return { status: 200, reason: "chat_created" };
Expand Down

0 comments on commit 839a701

Please sign in to comment.