I get a Channel Invalid error using telethon

Viewed 735

I am trying to get Users from my Telegram Group to my other Telegram Group and using this code:

group_entity = InputPeerChannel(group.id, group.access_hash)
client(InviteToChannelRequest(channel=group_entity, users=[user_to_add]))

A few weeks before this code worked perfectly fine but now I get this error: telethon.errors.rpcerrorlist.ChannelInvalidError: Invalid channel object. Make sure to pass the right types, for instance making sure that the request is designed for channels or otherwise look for a different one more suited (caused by InviteToChannelRequest) What am I doing wrong?

1 Answers

you must do like this:

group_entity = await client.get_entity(InputPeerChannel(group.id, group.access_hash))
Related