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 aa1e8d2 commit df322ae
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/bot/mtproto-api/workrooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,28 @@ export async function createChat(context: Context<"issues.labeled", SupportedEve
})
);

console.log("Chat created: ", chat.updates.chats);
let chatId: number;
let chatIdBigInt: bigInt.BigInteger;

console.log("Chat ID created: ", chat.updates.chats[0].id);
if ("chats" in chat.updates) {
chatId = chat.updates.chats[0].id.toJSNumber();
chatIdBigInt = chat.updates.chats[0].id;
} else {
throw new Error("Failed to create chat");
}

await context.adapters.supabase.chats.saveChat(chatId, payload.issue.title, payload.issue.node_id);

/**
* updates: {
CONSTRUCTOR_ID: 1957577280,
SUBCLASS_OF_ID: 2331323052,
className: 'Updates',
classType: 'constructor',
updates: [ [Object], [Object], [Object], [Object] ],
users: [ [Object] ],
chats: [ [Object] ],
date: 1725806466,
seq: 0
},
*/

// await context.adapters.supabase.chats.saveChat(chatId, payload.issue.title, payload.issue.node_id);
const botId = config.botId;

await mtProto.client.invoke(
new mtProto.api.messages.AddChatUser({
chatId: chatIdBigInt,
userId: botId,
fwdLimit: 50,
})
);

return { status: 200, reason: "chat_created" };
} catch (er) {
Expand Down

0 comments on commit df322ae

Please sign in to comment.