public override TLObject FromStream(Stream input)
        {
            StickerSet = GetObject <TLStickerSetBase>(input);
            Cover      = GetObject <TLDocumentBase>(input);

            return(this);
        }
Beispiel #2
0
        public override TLObject FromStream(Stream input)
        {
            Url      = GetObject <TLString>(input);
            Photo    = GetObject <TLPhotoBase>(input);
            Document = GetObject <TLDocumentBase>(input);

            return(this);
        }
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            StickerSet = GetObject <TLStickerSetBase>(bytes, ref position);
            Cover      = GetObject <TLDocumentBase>(bytes, ref position);

            return(this);
        }
Beispiel #4
0
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            Url      = GetObject <TLString>(bytes, ref position);
            Photo    = GetObject <TLPhotoBase>(bytes, ref position);
            Document = GetObject <TLDocumentBase>(bytes, ref position);

            return(this);
        }
Beispiel #5
0
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            Flags     = GetObject <TLInt>(bytes, ref position);
            Id        = GetObject <TLInt>(bytes, ref position);
            Version   = GetObject <TLString>(bytes, ref position);
            Text      = GetObject <TLString>(bytes, ref position);
            Entities  = GetObject <TLVector <TLMessageEntityBase> >(bytes, ref position);
            _document = GetObject <TLDocumentBase>(Flags, (int)AppUpdateFlags.Document, null, bytes, ref position);
            _url      = GetObject <TLString>(Flags, (int)AppUpdateFlags.Url, null, bytes, ref position);

            return(this);
        }
Beispiel #6
0
        public static bool DocumentEquals(TLDocumentBase document1, TLDocumentBase document2)
        {
            var doc1 = document1 as TLDocument;
            var doc2 = document2 as TLDocument;

            if (doc1 == null || doc2 == null)
            {
                return(false);
            }

            return(doc1.Id.Value == doc2.Id.Value &&
                   doc1.DCId.Value == doc2.DCId.Value &&
                   doc1.AccessHash.Value == doc2.AccessHash.Value);
        }
        public static bool IsSticker(TLDocumentBase documentBase)
        {
            var document = documentBase as TLDocument;

            if (document != null && document.Size > 0 && document.Size < 262144)
            {
                var attribute = document.Attributes.OfType <TLDocumentAttributeSticker>().FirstOrDefault();
                if (attribute != null && string.Equals(document.MimeType.ToString(), "image/webp", StringComparison.OrdinalIgnoreCase))
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #8
0
        public override TLObject FromStream(Stream input)
        {
            Flags       = GetObject <TLInt>(input);
            Id          = GetObject <TLLong>(input);
            AccessHash  = GetObject <TLLong>(input);
            ShortName   = GetObject <TLString>(input);
            Title       = GetObject <TLString>(input);
            Description = GetObject <TLString>(input);

            Photo    = GetObject <TLPhotoBase>(input);
            Document = GetObject <TLDocumentBase>(Flags, (int)GameFlags.Document, null, input);

            return(this);
        }
Beispiel #9
0
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            Flags       = GetObject <TLInt>(bytes, ref position);
            Id          = GetObject <TLLong>(bytes, ref position);
            AccessHash  = GetObject <TLLong>(bytes, ref position);
            ShortName   = GetObject <TLString>(bytes, ref position);
            Title       = GetObject <TLString>(bytes, ref position);
            Description = GetObject <TLString>(bytes, ref position);
            Photo       = GetObject <TLPhotoBase>(bytes, ref position);
            Document    = GetObject <TLDocumentBase>(Flags, (int)GameFlags.Document, null, bytes, ref position);

            return(this);
        }
Beispiel #10
0
        public void RemoveSticker(TLDocumentBase document)
        {
            for (var i = 0; i < Documents.Count; i++)
            {
                if (Documents[i].Index == document.Index)
                {
                    Documents.RemoveAt(i);
                    break;
                }
            }

            Hash = TLUtils.GetFavedStickersHash(Documents);

            var document54 = document as TLDocument54;

            if (document54 != null)
            {
                var emoticon = document54.Emoticon;
                if (!string.IsNullOrEmpty(emoticon))
                {
                    for (var i = 0; i < Packs.Count; i++)
                    {
                        if (Packs[i].Emoticon.ToString() == emoticon)
                        {
                            for (int j = 0; j < Packs[i].Documents.Count; j++)
                            {
                                if (Packs[i].Documents[j].Value == document54.Index)
                                {
                                    Packs[i].Documents.RemoveAt(j);
                                    break;
                                }
                            }

                            if (Packs[i].Documents.Count == 0)
                            {
                                Packs.RemoveAt(i);
                                break;
                            }
                        }
                    }
                }
            }
        }
Beispiel #11
0
        public void AddSticker(TLDocumentBase document)
        {
            Documents.Insert(0, document);
            Hash = TLUtils.GetFavedStickersHash(Documents);

            var document54 = document as TLDocument54;

            if (document54 != null)
            {
                var emoticon = document54.Emoticon;
                if (!string.IsNullOrEmpty(emoticon))
                {
                    var added = false;
                    for (var i = 0; i < Packs.Count; i++)
                    {
                        if (Packs[i].Emoticon.ToString() == emoticon)
                        {
                            var item = Packs[i].Documents.FirstOrDefault(x => x.Value == document54.Index);
                            if (item == null)
                            {
                                Packs[i].Documents.Insert(0, document54.Id);
                                added = true;
                                break;
                            }
                        }
                    }
                    if (!added)
                    {
                        Packs.Insert(0, new TLStickerPack {
                            Emoticon = new TLString(emoticon), Documents = new TLVector <TLLong> {
                                document54.Id
                            }
                        });
                    }
                }
            }
        }
        public static bool IsVoice(TLDocumentBase documentBase)
        {
            var document = documentBase as TLDocument;

            return(document != null && IsVoice(document, document.Size));
        }
        public static bool IsRoundVideo(TLDocumentBase documentBase)
        {
            var document = documentBase as TLDocument;

            return(document != null && IsRoundVideo(document, document.Size));
        }
        public static bool IsGif(TLDocumentBase documentBase)
        {
            var document = documentBase as TLDocument;

            return(document != null && IsGif(document));
        }