Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Сan't get messages using offsetDate that were sent before being added to the telegram group #667

Open
Simon-Skorentsev opened this issue Apr 22, 2024 · 0 comments

Comments

@Simon-Skorentsev
Copy link

Simon-Skorentsev commented Apr 22, 2024

I wrote a method for getting messages grom telegram group (didn't check in telegram channel):

  async getHistory() {
    const telegramClient = await this.getClient();
    const messages = await telegramClient.getMessages('-4174797018');

    messages.forEach((message) => {
      console.log(
        '\nMessage:',
        message.message,
        `with id`,
        message.id,
        '\nDate:',
        message.date,
      );
    });
  }

And I get in the console:

Message: /get_chat_id@LeadConverterToolkitBot with id 41
Date: 1713342868

Message: Неизвестное действие with id 40
Date: 1713342860

Message: undefined with id 39
Date: 1713342859

Message: Всем привет! Я Гаш - Плевок Тайдхантера with id 38
Date: 1713342536

Message: undefined with id 37
Date: 1713342042

Message: 13 with id 36
Date: 1713178841

Message: 66 with id 35
Date: 1713178819

In the telegram it looks like this:
image

And now, if I try to get messages using the date 1713342042 (from a message with ID 37), then I will get all messages up to 37, but if I use the date 1713178841 (from a message with ID 36) or less, then I will not get anything in the logs:

  async getHistory() {
    const telegramClient = await this.getClient();
    const messages = await telegramClient.getMessages('-4174797018', {
      offsetDate: 1713178841,
    });
    console.log(messages); // in console: TotalList(0) [ total: 140 ]

    // in console: empty
    for await (const message of messages) {
      console.log('for of message:', message);
    }

    // in console: empty
    messages.forEach((message) => {
      console.log(
        '\nMessage:',
        message.message,
        `with id`,
        message.id,
        '\nDate:',
        message.date,
      );
    });
  }

When using telegramClient.iterMessages or maxDate from Api.messages.Search, the same behavior occurs.
The user has the administrator role and the restriction on the visibility of messages to new users in the group has been removed

Is there a way to get messages within a specific time interval, without encountering the restriction on messages visible to the user but sent before their addition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant