Telethon icon indicating copy to clipboard operation
Telethon copied to clipboard

channels.DeleteHistoryRequest is incompatible with InputChannel

Open therapy opened this issue 1 year ago • 0 comments

Code that causes the issue

channel = self._client(functions.channels.CreateChannelRequest(title='test', about=''))
channel_id = channel.to_dict()["chats"][0]["id"]
channel_hash = channel.to_dict()["chats"][0]["access_hash"]

self._channel = tl.types.InputChannel(channel_id, channel_hash)

self._client.send_message(self._channel, "test") # works fine
self._client(functions.channels.DeleteHistoryRequest(self._channel, max_id=0)) # error

Traceback

Traceback (most recent call last):
  File "*****", line 159, in <module>
    Telegram()
  File "*****", line 51, in __init__
    self._client(functions.channels.DeleteHistoryRequest(self._channel, max_id=0))
  File "C:\Users\*****\AppData\Local\Programs\Python\Python310\lib\site-packages\telethon\sync.py", line 39, in syncified
    return loop.run_until_complete(coro)
  File "C:\Users\*****\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
    return future.result()
  File "C:\Users\*****\AppData\Local\Programs\Python\Python310\lib\site-packages\telethon\client\users.py", line 30, in __call__
    return await self._call(self._sender, request, ordered=ordered)
  File "C:\Users\*****\AppData\Local\Programs\Python\Python310\lib\site-packages\telethon\client\users.py", line 84, in _call
    result = await future
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 DeleteHistoryRequest)

therapy avatar Jul 05 '22 13:07 therapy