TLSharp
TLSharp copied to clipboard
Get DeepLinkInfo
Hi,
I'm trying to use TLSharp to utilize this api method:
help.deepLinkInfo (https://core.telegram.org/constructor/help.deepLinkInfo)
I can't see anything ready for this purpose in the library, so I wrote my classes:
TLDeepLinkInfo
[TLObject(1783556146)]
public class TLDeepLinkInfo : TLAbsDeepLinkInfo
{
public override int Constructor
{
get
{
return 1783556146;
}
}
public int Flags { get; set; }
public bool UpdateApp { get; set; }
public string Message { get; set; }
public TLVector<TLAbsMessageEntity> Entities { get; set; }
public void ComputeFlags()
{
Flags = 0;
Flags = UpdateApp ? (Flags | 1) : (Flags & ~1);
}
public override void DeserializeBody(BinaryReader br)
{
Flags = br.ReadInt32();
UpdateApp = (Flags & 1) != 0;
Message = br.ReadString();
Entities = (TLVector<TLAbsMessageEntity>)ObjectUtils.DeserializeVector<TLAbsMessageEntity>(br);
}
public override void SerializeBody(BinaryWriter bw)
{
bw.Write(Constructor);
ComputeFlags();
bw.Write(Flags);
bw.Write(Message);
ObjectUtils.SerializeObject(Entities, bw);
}
}
TLRequestGetDeepLinkInfo
[TLObject(1072547679)]
public class TLRequestGetDeepLinkInfo :TLMethod
{
public override int Constructor
{
get
{
return 1072547679;
}
}
public string Path { get; set; }
public TLDeepLinkInfo Response { get; set; }
public void ComputeFlags()
{
}
public override void DeserializeBody(BinaryReader br)
{
Path = br.ReadString();
}
public override void SerializeBody(BinaryWriter bw)
{
bw.Write(Constructor);
bw.Write(Path);
}
public override void DeserializeResponse(BinaryReader br)
{
Response = (TLDeepLinkInfo)ObjectUtils.DeserializeObject(br);
}
}
I try to use it this way:
var req = new TLRequestGetDeepLinkInfo()
{
Path = "<telegram_deep_link>"
};
var resp = await client.SendRequestAsync<TLDeepLinkInfo>(req);
But I get exception:
"Constructor Invalid Or Context.Init Not Called"
with InnerException:
"The given key was not present in the dictionary."
Could someone advise me, what am I doing wrong?
Because this class is not available in layer 66
If you want to upgrade current used layer, You'll need to upgrade TLSharp to layer 81.
Layer upgrading is easy, Only you'll need to Change Layer = 66
in ConnectAsync
method here: https://github.com/sochix/TLSharp/blob/master/TLSharp.Core/TelegramClient.cs#L95
I suggest using TgSharp, Because it was fork from TLSharp, And upgraded to layer 108
Thanks! I've switched to TgSharp. Sadly GetDeepLinkInfo is returning DeepLInkInfoEmpty.