Open yoburtu opened 2 months ago
AFAIK the Telegram servers tend to throttle down clients that are causing a lot of traffic/requests or even (as in your case) prevent from processing new request for certain amount of time. Another possible explanation is that CheckChatInviteRequest
indicates that you're not a member of the group or you need to wait some time after joining the group before you can import chats to it.
I have been a member of the group for a long time.
Do you know how I can use the channel_id instead of the join link in the --peer parameter?. I have used the id of result.json:
{
"name": "Name Group",
"type": "private_supergroup",
"id": 1234567890,
"messages": [
but it doesn't work:
$ python3 telegram_import.py --path /home/user/backup/Family-ChatExport_2024-08-29 --peer 1234567890
Loading config.ini
Loading result.json
Converting format
Traceback (most recent call last):
File "/home/user/git/telegram_import/telegram_import.py", line 251, in <module>
import_history(
File "/home/user/git/telegram_import/telegram_import.py", line 200, in import_history
client(functions.messages.CheckHistoryImportPeerRequest(
File "/home/user/.local/lib/python3.12/site-packages/telethon/sync.py", line 39, in syncified
return loop.run_until_complete(coro)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.12/site-packages/telethon/client/users.py", line 30, in __call__
return await self._call(self._sender, request, ordered=ordered)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.12/site-packages/telethon/client/users.py", line 43, in _call
await r.resolve(self, utils)
File "/home/user/.local/lib/python3.12/site-packages/telethon/tl/functions/messages.py", line 218, in resolve
self.peer = utils.get_input_peer(await client.get_input_entity(self.peer))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.12/site-packages/telethon/client/users.py", line 439, in get_input_entity
await self._get_entity_from_string(peer))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.12/site-packages/telethon/client/users.py", line 576, in _get_entity_from_string
raise ValueError(
ValueError: Cannot find any entity corresponding to "1234567890"
Regards,
I have added this bot to members group for get my chat_id group:
@get_id_bot
My chat_id is something like this:
-1001234567890
Please, can you check if this works in your script with the peer?.
Regards.
Some info about Entities
is here: https://docs.telethon.dev/en/stable/concepts/entities.html#getting-entities. This code does'nt do any peer/entities checking and I've simply used join link for group import without problems.
Please be advised that we're converting from Telegram json export to Whatsapp txt format as Telegram can't import it's own export. The code uses only some of stuff from json as not all of the stuff has any meaningful place in txt. We're use --peer
to tell Telegram where to import the messages from txt and the Telethon/Telegram then uses CheckHistoryImportPeerRequest to see if it can recognize the entity/peer and if the peer/entity is valid for import (for example group must be supergroup)
I have done several tests importing a group chat using a telegram user's phone number directly and all of them work correctly. So it seems that the import limitation has something to do with the group join link.
If I try to use the group chat ID, I get the error specified in this issue:
ValueError: Cannot find any entity corresponding to "-100XXXXXXXXXX"
For some reason, your script is not able to identify the group chat ID as an entity and I don't know why.
Please, could you check why it doesn't identify the chat ID correctly? I would appreciate it. Thank you very much.
Best regards.
Could you (just for test) export your group content and try to import that chat using group join link? If that works the problem is not in the join link... The export of a group chat and export of a "normal" chat might be slightly different and creating problems if you're trying to import the "normal" chat into a group.
could you check why it doesn't identify the chat ID correctly
As note previously, this code is not responsible for that - it uses Telethon library which in turn uses Telegram servers via it's API so the error you're seeing comes back from Telegram servers.
Yes, I have tried to import the chat history with the join link and it doesn't work. And it is a group that has very little history.:
python3 telegram_import.py --path /home/user/backup/ChatExport_2024-09-06 --peer https://t.me/+yjoinkink
Loading config.ini
Loading result.json
Converting format
Traceback (most recent call last):
File "/home/user/git/telegram_import/telegram_import.py", line 251, in
telethon.errors.rpcerrorlist.FloodWaitError: A wait of 279 seconds is required (caused by CheckChatInviteRequest)
This error is not telling you that it couldn't find the chat you're trying to import to. It's telling you that you have to wait a certain amount of time before you try again, as you're previous attempts have failed so their servers are protecting them from too much traffic (https://docs.telethon.dev/en/stable/concepts/errors.html#common-errors)
But the difference is that if I use the recipient's phone number for the Telegram, there is no traffic restriction. All my tests are working fine. It only fails if I use the group join link.
Telethon explanation on how to avoid FloodWaitError
is here: https://docs.telethon.dev/en/stable/concepts/errors.html#avoiding-limits.
If you still think that there is some kind of bug reading the --peer
parameter you can try to use some of the methods Telethon is mentioning here: https://docs.telethon.dev/en/stable/concepts/chats-vs-channels.html#converting-ids
I am trying to import a chat backup to a private group. The backup size is 2.5 GB. I have some kind of error related to flood. This is the first test I've done since yesterday, so I don't quite understand the second wait thing.
By the way, I have to thank you for making this script. I'm trying to recover a 10-year chat history of family conversations, videos, and photos. My wife accidentally left the group and lost all of this.
This is the error:
Best regards.