knadh / tg-archive

A tool for exporting Telegram group chats into static websites like mailing list archives.
MIT License
829 stars 121 forks source link

Error with certain group type #93

Closed fhennies closed 1 year ago

fhennies commented 1 year ago

Hej,

I have been using the code successfully for extracting all but one of my groups and chats. All are private family chats, and it is great to be able to extract a memory of our chats

I have used both group/chat name and numerical ID to address the chats/groups, most work with both, some only with the numerical ID.

But one group gives the following error message if using the numerical ID (and can't be found with the name):

2023-02-05 21:01:06,151: starting Telegram sync (batch_size=2000, limit=0, wait=5, mode=takeout)
2023-02-05 21:01:06,154: Connecting to 149.154.167.92:443/TcpFull...
2023-02-05 21:01:06,180: Connection to 149.154.167.92:443/TcpFull complete!
2023-02-05 21:01:06,638: fetching from last message id=0 (None)
Traceback (most recent call last):
  File "/usr/local/bin/tg-archive", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/tgarchive/__init__.py", line 141, in main
    s.sync(args.id, args.from_id)
  File "/usr/local/lib/python3.10/dist-packages/tgarchive/sync.py", line 51, in sync
    group_id = self._get_group_id(self.config["group"])
  File "/usr/local/lib/python3.10/dist-packages/tgarchive/sync.py", line 386, in _get_group_id
    entity = self.client.get_entity(group)
  File "/usr/local/lib/python3.10/dist-packages/telethon/sync.py", line 39, in syncified
    return loop.run_until_complete(coro)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.10/dist-packages/telethon/client/users.py", line 316, in get_entity
    chats = (await self(
  File "/usr/local/lib/python3.10/dist-packages/telethon/client/account.py", line 77, in __call__
    return await self.__client(
  File "/usr/local/lib/python3.10/dist-packages/telethon/client/users.py", line 30, in __call__
    return await self._call(self._sender, request, ordered=ordered)
  File "/usr/local/lib/python3.10/dist-packages/telethon/client/users.py", line 84, in _call
    result = await future
telethon.errors.rpcerrorlist.ChatIdInvalidError: Invalid object ID for a chat. Make sure to pass the right types, for instance making sure that the request is designed for chats (not channels/megagroups) or otherwise look for a different one more suited\nAn example working with a megagroup and AddChatUserRequest, it will fail because megagroups are channels. Use InviteToChannelRequest instead (caused by InvokeWithTakeoutRequest(GetChatsRequest))
Segmentation fault

It is possible that this particular group is a supergroup (although it only has four members) but I can't find any way of confirming this.

Have you encountered this?

fhennies commented 1 year ago

Hmm, I found a solution, just after submitting this. I can reference this specific group with the numeric ID but omitting the "-" that usually distinguishes a group ID from a 1:1 chat ID. Now it works.