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

'struct.error: required argument is not an integer' when inviting a user bot to a group #443

Closed
kuba-orlik opened this issue Mar 23, 2020 · 3 comments
Labels
bug: regression Something isn't working, but it used to work before external This issue is valid, but needs to be fixed somewhere else (e.g. a library)

Comments

@kuba-orlik
Copy link

Inviting a user bot to a Telegram group does not trigger an invitation on Matrix. The mautrix-telegram logs show this message:

mautrix_1     | Traceback (most recent call last):
mautrix_1     |   File "/usr/lib/python3.8/site-packages/mautrix_telegram/portal/metadata.py", line 244, in create_matrix_room
mautrix_1     |     return await self._create_matrix_room(user, entity, invites)
mautrix_1     |   File "/usr/lib/python3.8/site-packages/mautrix_telegram/portal/metadata.py", line 259, in _create_matrix_room
mautrix_1     |     entity = await self.get_entity(user)
mautrix_1     |   File "/usr/lib/python3.8/site-packages/mautrix_telegram/portal/base.py", line 233, in get_entity
mautrix_1     |     return await user.client.get_entity(self.peer)
mautrix_1     |   File "/usr/lib/python3.8/site-packages/telethon/client/users.py", line 283, in get_entity
mautrix_1     |     chats = (await self(
mautrix_1     |   File "/usr/lib/python3.8/site-packages/telethon/client/users.py", line 53, in __call__
mautrix_1     |     future = self._sender.send(request, ordered=ordered)
mautrix_1     |   File "/usr/lib/python3.8/site-packages/telethon/network/mtprotosender.py", line 172, in send
mautrix_1     |     state = RequestState(request, self._loop)
mautrix_1     |   File "/usr/lib/python3.8/site-packages/telethon/network/requeststate.py", line 17, in __init__
mautrix_1     |     self.data = bytes(request)
mautrix_1     |   File "/usr/lib/python3.8/site-packages/telethon/tl/functions/messages.py", line 1141, in __bytes__
mautrix_1     |     b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.id)),b''.join(struct.pack('<i', x) for x in self.id),
mautrix_1     |   File "/usr/lib/python3.8/site-packages/telethon/tl/functions/messages.py", line 1141, in <genexpr>
mautrix_1     |     b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.id)),b''.join(struct.pack('<i', x) for x in self.id),
mautrix_1     | struct.error: required argument is not an integer
@kuba-orlik
Copy link
Author

When trying to manually bridge a room via chat commands in Riot, I get:

image

@BjWe
Copy link

BjWe commented Apr 9, 2020

I am absolutely not into python,
but I found out (on my server) that
there is no list with id's passed - instead a list of "telethon.tl.types.InputPeerChat".

The id is packed into id[n].chat_id.

I edited /telethon/tl/functions/messages.py and
added on top of
class GetChatsRequest(TLRequest):
def __bytes__(self):

  if self.id[0].__class__.__name__ == 'InputPeerChat':
            return b''.join((
                b'\x87\xa1j<',
                b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.id)),b''.join(struct.pack('<i', x.chat_id) for x in self.id),
            ))

That works for me now.
Not the best solution - but maybe it offers the developer a good hint

@tulir
Copy link
Member

tulir commented Apr 25, 2020

I'm pretty sure this is fixed on newer telethon versions (and thus the master branch of the bridge)

edit: v0.8.0-rc1 is out

@tulir tulir closed this as completed Apr 25, 2020
@tulir tulir added bug: regression Something isn't working, but it used to work before external This issue is valid, but needs to be fixed somewhere else (e.g. a library) labels Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: regression Something isn't working, but it used to work before external This issue is valid, but needs to be fixed somewhere else (e.g. a library)
Development

No branches or pull requests

3 participants