-
Notifications
You must be signed in to change notification settings - Fork 210
Open
Description
I'm trying to retrieve almost 80000 messages from a Telegram channel, but it only gets around 15000. I used offsetId to try and retrieve more older ones and it works, but it only retrieves around ~100-200 messages after. I can't keep modifying the offsetId as that would be extremely tedious with around 60000 messages to go.
My code so far
export async function Telegram_DRI(
canonical_identifier: string,
limit: number // Ignored variable for debugging
) {
const client = TelegramServiceClient.getInstance(); // Singleton class I set up.
let manifest: TotalList<Api.Message> = [];
try {
await client.connect();
const user = await client.getEntity(canonical_identifier);
for await (const message of client.iterMessages(user, {
limit: undefined,
offsetId: 65050, // !!! I keep having to modify this to get older messages, and it still only returns ~100-200 messages each time
})) {
clc.log(
`-- FOUND MESSAGE ${message.id} FROM AUTHOR ${
message.postAuthor
} OF LENGTH ${message.text.length} WITH MEDIA ${
message.media ? "AVAILABLE" : "NOT AVAILABLE"
} --`,
ANSI_COLORS.BRIGHT_WHITE
);
manifest.push(message);
}
} catch (e: any) {
clc.log(e, ANSI_COLORS.RED);
} finally {
await client.destroy();
}
return manifest;
}
I am logged into my Telegram account rather than using a bot token.
Metadata
Metadata
Assignees
Labels
No labels