Skip to content
This repository has been archived by the owner on Dec 5, 2021. It is now read-only.

Get DeepLinkInfo #1027

Open
tmkczmrk opened this issue May 11, 2021 · 4 comments
Open

Get DeepLinkInfo #1027

tmkczmrk opened this issue May 11, 2021 · 4 comments

Comments

@tmkczmrk
Copy link

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?

@Muaath5
Copy link

Muaath5 commented May 20, 2021

Because this class is not available in layer 66

@Muaath5
Copy link

Muaath5 commented May 20, 2021

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

@Muaath5
Copy link

Muaath5 commented May 20, 2021

I suggest using TgSharp, Because it was fork from TLSharp, And upgraded to layer 108

@tmkczmrk
Copy link
Author

Thanks! I've switched to TgSharp. Sadly GetDeepLinkInfo is returning DeepLInkInfoEmpty.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants