TgSharp icon indicating copy to clipboard operation
TgSharp copied to clipboard

Sendmessage error:Flood prevention

Open tz182736 opened this issue 4 years ago • 0 comments

"Flood prevention. Telegram now requires your program to do requests again only after 3600 seconds have passed (TimeToWait property), so if now it's 11/10/2020 3:59:32 AM, wait until 11/10/2020 4:59:32 AM If you think the culprit of this problem may lie in TgSharp's implementation, open a Github issue please."

this error cause on first debug right after authorize and try to send text message

////  CLIENT CONNECT
    var store = new FileSessionStore();
    client = new TelegramClient(apiId, apiHash, dcIpVersion: DataCenterIPVersion.OnlyIPv4, store:null, sessionUserId: "_session");
    await client.ConnectAsync();

/////  CLIENT REQUEST
    userHash = await client.SendCodeRequestAsync(txtUserNumber.Text);

////  CLIENT AUTH
    var user = await client.MakeAuthAsync(txtUserNumber.Text, userHash, txtRequestCode.Text);

//// CLIENT SEND MESSAGE
    //get available contacts
    var result = await client.GetContactsAsync();

    //find recipient in contacts
    var user = result.Users
        .Where(x => x.GetType() == typeof(TLUser))
        .Cast<TLUser>()
        .FirstOrDefault(x => x.Phone == txtNumberToSend.Text);
              
    await client.SendMessageAsync(new TLInputPeerUser() { UserId = user.Id }, txtMessage.Text);

tz182736 avatar Nov 10 '20 01:11 tz182736