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

get_chats() does not work as expected. #502

Open
asarubbo opened this issue Sep 2, 2024 · 2 comments
Open

get_chats() does not work as expected. #502

asarubbo opened this issue Sep 2, 2024 · 2 comments

Comments

@asarubbo
Copy link

asarubbo commented Sep 2, 2024

Hello, I noticed this behavior more that once.

I have a group that sends ~1000 messages per day, where in each message there is an image, so it takes a while to synchronize.

The original code was:

tg.login()

result_get_chats = tg.get_chats()
result_get_chats.wait()
if result_get_chats.error:
    print(f'get chats error: {result_get_chats.error_info}')

def new_message_handler(update):
    ....

tg.add_message_handler(new_message_handler)
tg.idle()
tg.stop()

And with this code, when I launch a bot (after e.g. 2 days that I wasn't use it), it fails to synchronize the messages in a short time interval and then it behaves like that messages are received in real time.

I added also a time.sleep(30) before def new_message_handler(update) but it does not improve.

How to be sure that get_chats() works as expected and fetches everything before start to work? Basically result_get_chats.wait() should do the job but it doesn't.

To reproduce, I think you need to setup a bot, make a login, then shutdown and fill a group with thousand of messages/photos and then start again the bot.

@alexander-akhmetov
Copy link
Owner

Hi,

I suspect that you’ll need to use getChatHistory (reference) to properly load all messages.

@asarubbo
Copy link
Author

I see that the current limit for get_chats() is 100.

Do you think that overwrite the limit could help?

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

2 participants