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 e42603a commit e5c56be
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions src/bot/mtproto-api/workrooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,32 @@ export async function closeChat(context: Context<"issues.closed", SupportedEvent
throw new Error("Failed to fetch chat");
}

let chatParticipants;

if ("participants" in fetchChat.fullChat) {
chatParticipants = fetchChat.fullChat.participants;
} else {
throw new Error("Failed to fetch chat participants");
}

if (chatParticipants.className === "ChatParticipants") {
const userIDs = chatParticipants.participants.map((participant) => {
return participant.userId;
});

for (let i = 0; i < userIDs.length; i++) {
if (userIDs[i].toJSNumber() === context.config.botId) {
continue;
}
await mtProto.client.invoke(
new mtProto.api.messages.DeleteChatUser({
chatId: chat.chatId,
userId: userIDs[i],
})
);
}
}

// const chatFull = fetchChat.fullChat as Api.ChatFull
// const participants = chatFull.participants as Api.ChatParticipants;

Expand All @@ -94,12 +120,12 @@ export async function closeChat(context: Context<"issues.closed", SupportedEvent
// }
// }

await mtProto.client.invoke(
new mtProto.api.messages.DeleteChatUser({
chatId: chat.chatId,
userId: bigInt(0),
})
);
// await mtProto.client.invoke(
// new mtProto.api.messages.DeleteChatUser({
// chatId: chat.chatId,
// userId: bigInt(0),
// })
// );

await mtProto.client.invoke(
new mtProto.api.messages.SendMessage({
Expand Down

0 comments on commit e5c56be

Please sign in to comment.