sochix / TLSharp

Telegram client library implemented in C#
1.01k stars 380 forks source link

fileref_upgrade_needed #882

Open daparici opened 4 years ago

daparici commented 4 years ago

Hi,

I'm trying to download a few old files from one Telegram channel. I first send the file download request calling GetFile including TLInputDocumentFileLocation,filepartsize and offset. Telegram servers, with this kind of files, allways respond with floodpreventiongexception and I must wait 5000 milisececonds, then I request the file again using the same data and Telegram responds with a fileref_needs_upgrade.

I tried to refetch the document reference calling a GetHistoryAsync but the Location obtained doesn't change.

Does anybody know how to refresh/upgrade the document reference?

Thanks in advance.

Mubo-412 commented 4 years ago

Does anybody have a solution of that? I am stucking on it.

Thanks.

Xmg92 commented 4 years ago

I also have the same problem...

YitzchakYeret commented 4 years ago

Any updates? I have the same issue with getting image message.

dariooo512 commented 4 years ago

Same issue here. Any news?

daparici commented 4 years ago

Yes. I stoped using TLSharp cause it seems dead. Now I'm using TDSharp based on TDLib and it works like a charm.

Please don't hesitate to ask me if you think I can help you in any other way.

dariooo512 commented 4 years ago

Hi @daparici thanks for your answer!

Well, that's disappointing since I've almost completed my application using TLSharp. I was searching for samples of the usage of TDSharp. Do you know where I can find one? (Simple stuff, like auth and get chats)

I'm asking you this here so maybe someone like me can have a chance to change lib before running into my situation :)

Thanks a lot!

daparici commented 4 years ago

Hi Dario,

Attached you will find an uncompleted sample showing how to auth and get the first 100 subscribed channels. TelegramController.txt

Please let me know if you have any problem.

dariooo512 commented 4 years ago

Awesome! Thanks a lot!

Mubo-412 commented 4 years ago

Hello Everyone, Is there any update about this issue? Sometimes it works for me, other times it doesn't. Is there any explication?

ehsanasgarian commented 4 years ago

I also have the same problem...

skipme commented 4 years ago

to download some files/docs library needs to support file references (update schema required), file location param seems to be deprecated: https://core.telegram.org/constructor/fileLocationToBeDeprecated

knocte commented 4 years ago

(update schema required)

Hey @skipme, can you help us update the schema?

Jycjmf commented 4 years ago

to download some files/docs library needs to support file references (update schema required), file location param seems to be deprecated: https://core.telegram.org/constructor/fileLocationToBeDeprecated

Hey skipme. Could you give me a sample examples? My project is almost completed on TLSharp, so I don't want to change to TDLib. Thank you very much!

dariooo512 commented 4 years ago

I've managed to found This repo where there's an updated version with this problem solved.

The new code to get it working is

if (!(message.Media is TLMessageMediaPhoto media) || !(media.Photo is TLPhoto photo))
{
     continue;
}

var size = photo.Sizes.OfType<TLPhotoSize>().Last();
 var request = new TLInputPhotoFileLocation
 {
     Id = photo.Id,
     FileReference = photo.FileReference,
     AccessHash = photo.AccessHash,
     ThumbSize = size.Type
};
var buffer = await _client.GetFile(request, 1024 * 512);

I've fixed some namespaces and i'm using those dlls in my project now while i wait for the authors to merge the update TgSharp.TL.zip

On this version i'm having issues while managing the ISessionStore, but the rest is working fine.

Jycjmf commented 4 years ago

I've managed to found This repo where there's an updated version with this problem solved.

The new code to get it working is

if (!(message.Media is TLMessageMediaPhoto media) || !(media.Photo is TLPhoto photo))
{
     continue;
}

var size = photo.Sizes.OfType<TLPhotoSize>().Last();
 var request = new TLInputPhotoFileLocation
 {
     Id = photo.Id,
     FileReference = photo.FileReference,
     AccessHash = photo.AccessHash,
     ThumbSize = size.Type
};
var buffer = await _client.GetFile(request, 1024 * 512);

I've fixed some namespaces and i'm using those dlls in my project now while i wait for the authors to merge the update TgSharp.TL.zip

On this version i'm having issues while managing the ISessionStore, but the rest is working fine.

Hey, dariooo512. Thanks very much! By the way, how did you fixed the namespaces? I am fixing it manually, it is really a massive project. Or could you give me the fixed source code, I want to modify something.

Sellec commented 4 years ago

I've managed to found This repo where there's an updated version with this problem solved.

The new code to get it working is

if (!(message.Media is TLMessageMediaPhoto media) || !(media.Photo is TLPhoto photo))
{
     continue;
}

var size = photo.Sizes.OfType<TLPhotoSize>().Last();
 var request = new TLInputPhotoFileLocation
 {
     Id = photo.Id,
     FileReference = photo.FileReference,
     AccessHash = photo.AccessHash,
     ThumbSize = size.Type
};
var buffer = await _client.GetFile(request, 1024 * 512);

I've fixed some namespaces and i'm using those dlls in my project now while i wait for the authors to merge the update TgSharp.TL.zip

On this version i'm having issues while managing the ISessionStore, but the rest is working fine.

Im does not see TLInputPhotoFileLocation in linked repo.

dariooo512 commented 4 years ago

Im does not see TLInputPhotoFileLocation in linked repo.

https://github.com/aarani/TgSharp/blob/master/src/TgSharp.TL/TL/TLInputPhotoFileLocation.cs

Sellec commented 4 years ago

Im does not see TLInputPhotoFileLocation in linked repo.

https://github.com/aarani/TgSharp/blob/master/src/TgSharp.TL/TL/TLInputPhotoFileLocation.cs

Its interesting...repo search founds nothing https://github.com/aarani/TgSharp/search?q=TLInputPhotoFileLocation&unscoped_q=TLInputPhotoFileLocation

dariooo512 commented 4 years ago

Hey, dariooo512. Thanks very much! By the way, how did you fixed the namespaces? I am fixing it manually, it is really a massive project. Or could you give me the fixed source code, I want to modify something.

Which IDE are you using? Consider switching to Rider or installing Resharper extension for VS. They come with advanced solution management (fixing namespaces took one click) TgSharp.Core.zip

Sellec commented 4 years ago

Seems like this repo have some serious differences. For example, look into TLChannelDifferenceTooLong - there are no ReadInboxMaxId property.

dariooo512 commented 4 years ago

Yeah, the repo it's an API upgrade from layer 66 to 108 so you probably will encounter breaking changes.

Sellec commented 4 years ago

Repo is dirty, very dirty...

Yeah, the repo it's an API upgrade from layer 66 to 108 so you probably will encounter breaking changes.

The changes are...terrible, not breaking. For example - TgSharp.Core.TelegramClient.SendUploadedPhoto has missing caption argument, but TLInputMediaUploadedPhoto have Caption property. And nuget versions of TgSharp/TlSharp have this argument.

Jycjmf commented 4 years ago

Hey, dariooo512. Thanks very much! By the way, how did you fixed the namespaces? I am fixing it manually, it is really a massive project. Or could you give me the fixed source code, I want to modify something.

Which IDE are you using? Consider switching to Rider or installing Resharper extension for VS. They come with advanced solution management (fixing namespaces took one click) TgSharp.Core.zip

I use VS2019 with Resharper extension, but I only know the basic use of the Resharper. How to fix all the Error with one click? Anyway, my problems is solved with the source code you given. Thanks!

Sellec commented 4 years ago

Yeah, the repo it's an API upgrade from layer 66 to 108 so you probably will encounter breaking changes.

Some strange thing - message entities are not applied to sended messages. I.e. when i use message copying (take message from one channel and resend it to another channel directly with copying text and Entities property), message formatting is not applied. For example, TLMessageEntityBold is not applied. This entity can be in source message (working nice), but it does not work when use it with same length and offset in new message with the same text. Maybe some flags or message properties is missing in my code? This code works with classic TLSharp.

Sellec commented 4 years ago

Yeah, the repo it's an API upgrade from layer 66 to 108 so you probably will encounter breaking changes.

Some strange thing - message entities are not applied to sended messages. I.e. when i use message copying (take message from one channel and resend it to another channel directly with copying text and Entities property), message formatting is not applied. For example, TLMessageEntityBold is not applied. This entity can be in source message (working nice), but it does not work when use it with same length and offset in new message with the same text. Maybe some flags or message properties is missing in my code? This code works with classic TLSharp.

Yes, ComputeFlags method is empty in TLRequestSendMessage. Can it be fixed and recompiled?

atrdev-rgb commented 3 years ago

FloodException client.ConnectAsync: 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.

FILEREF_UPGRADE_NEEDED

atrdev-rgb commented 3 years ago

I've managed to found This repo where there's an updated version with this problem solved.

The new code to get it working is

if (!(message.Media is TLMessageMediaPhoto media) || !(media.Photo is TLPhoto photo))
{
     continue;
}

var size = photo.Sizes.OfType<TLPhotoSize>().Last();
 var request = new TLInputPhotoFileLocation
 {
     Id = photo.Id,
     FileReference = photo.FileReference,
     AccessHash = photo.AccessHash,
     ThumbSize = size.Type
};
var buffer = await _client.GetFile(request, 1024 * 512);

I've fixed some namespaces and i'm using those dlls in my project now while i wait for the authors to merge the update TgSharp.TL.zip

On this version i'm having issues while managing the ISessionStore, but the rest is working fine.

please discard a working example, with your example

ralphwald0 commented 3 years ago

Any update, im stucking with this too, please help

ejazmusavi commented 2 years ago

Yes. I stoped using TLSharp cause it seems dead. Now I'm using TDSharp based on TDLib and it works like a charm.

Please don't hesitate to ask me if you think I can help you in any other way.

Can you please guide me to use TDSharp in webforms