TLSharp icon indicating copy to clipboard operation
TLSharp copied to clipboard

Flood prevention!

Open Vxer-Lee opened this issue 6 years ago • 5 comments

When I get the image ID from the chat record and download it, the server returns this message. What should I do?

Flood prevention. Telegram now requires your program to do requests again only after 5 seconds have passed (TimeToWait property). If you think the culprit of this problem may lie in TLSharp's implementation, open a Github issue please.

image

LocalId:6781 Secret:3101091358733321214 VolumeId:500041600961 Size:56140

Code:

public virtual async Task Telegram_Download_Photo(string name,int LocalId,long Secret,long VolumeId)
{
    var client = NewClient();
    await client.ConnectAsync();
    BinaryWriter bw;
    bw = new BinaryWriter(new FileStream(name, FileMode.Create));
    try
    {
        TLAbsInputFileLocation TLAbsInputFileLocation = new TLInputFileLocation()
        {
            LocalId = LocalId,
            Secret = Secret,
            VolumeId = VolumeId
        };
        TLInputFileLocation TLInputFileLocation = TLAbsInputFileLocation as TLInputFileLocation;
       var buffer = await client.GetFile(TLInputFileLocation, 1024*512);
        bw.Write(buffer.Bytes);
        bw.Close();
    }
    catch (Exception ee)
    {
        bw.Close();
        throw ee;
    }
}

Vxer-Lee avatar Oct 22 '20 05:10 Vxer-Lee

Why do you think this is a bug in TLSharp?

knocte avatar Oct 22 '20 07:10 knocte

You should set Timeout for call API. If you call it continuously without a gap time, you may block from Telegram for many times.

hosseinGanjyar avatar Dec 01 '20 07:12 hosseinGanjyar

You should set Timeout for call API. If you call it continuously without a gap time, you may block from Telegram for many times.

Thanks !

Vxer-Lee avatar Dec 01 '20 09:12 Vxer-Lee

You should set Timeout for call API. If you call it continuously without a gap time, you may block from Telegram for many times.

Can you add example code ?

ctphu avatar Mar 31 '21 05:03 ctphu

You should set Timeout for call API. If you call it continuously without a gap time, you may block from Telegram for many times.

Can you add example code ?

I need code example too!

rocket-builder avatar Apr 05 '21 19:04 rocket-builder