我想通过调用getFile
方法下载图片文件,这是我使用Telethon(电报客户端 api)的代码:
def get_file_req(client, volume_id, local_id, secret):
input_file_location = InputFileLocation(volume_id, local_id, secret)
downloaded_file = client(GetFileRequest(input_file_location, 4000, 2000))
return downloaded_file
print(get_file_req(client, 434327164, 120080, 1200912808185991895))
我不知道我应该将哪些参数传递给GetFileRequest
方法。基于此链接,GetFileRequest
给出和作为参数location
,并提到偏移量必须能被 1KB 整除,但没有一个很好的例子来说明我应该将哪些参数传递给这个方法。当我调用此方法时,我收到此错误:offset
limit
Traceback (most recent call last):
File "tclient.py", line 27, in <module>
print(get_file_req(client, 434327164, 120080, 1200912808185991895))
File "tclient.py", line 23, in get_file_req
downloaded_file = client(GetFileRequest(input_file_location, 4000, 2000))
File "C:\Users\Ali\Desktop\projects\telegram bot dev branch\myenv\Lib\site-packages\telethon\telegram_bare_client.py", line 429, in __call__
sender, call_receive, update_state, *requests
File "C:\Users\Ali\Desktop\projects\telegram bot dev branch\myenv\Lib\site-packages\telethon\telegram_bare_client.py", line 517, in _invoke
raise next(x.rpc_error for x in requests if x.rpc_error)
telethon.errors.rpc_error_list.OffsetInvalidError: (OffsetInvalidError(...), 'The given offset was invalid, it must be divisible by 1KB. See https://core.telegram.org/api/files#downloading-files')