public override void DeserializeBody(BinaryReader br)
 {
     file = (TLAbsInputFile)ObjectUtils.DeserializeObject(br);
     thumb = (TLAbsInputFile)ObjectUtils.DeserializeObject(br);
     mime_type = StringUtil.Deserialize(br);
     attributes = (TLVector<TLAbsDocumentAttribute>)ObjectUtils.DeserializeVector<TLAbsDocumentAttribute>(br);
     caption = StringUtil.Deserialize(br);
 }
 public override void DeserializeBody(BinaryReader br)
 {
     flags = br.ReadInt32();
     file = (TLAbsInputFile)ObjectUtils.DeserializeObject(br);
     thumb = (TLAbsInputFile)ObjectUtils.DeserializeObject(br);
     mime_type = StringUtil.Deserialize(br);
     attributes = (TLVector<TLAbsDocumentAttribute>)ObjectUtils.DeserializeVector<TLAbsDocumentAttribute>(br);
     caption = StringUtil.Deserialize(br);
     if ((flags & 1) != 0)
     stickers = (TLVector<TLAbsInputDocument>)ObjectUtils.DeserializeVector<TLAbsInputDocument>(br);
     else
     stickers = null;
 }
Example #3
0
        public async Task SendPhotoToUserAsync(FileToUserDto model)
        {
            TLUser user = await GetUserAsync(model.Login);

            TLAbsInputFile fileResult = await UpLoadFileAsync(model.Path, model.Name);

            await client.SendUploadedPhoto(new TLInputPeerUser()
            {
                UserId = user.Id
            }, fileResult, MessageBuilder(model.SenderName, model.Subject, model.Caption));

            Thread.Sleep(DileyTime);
        }
Example #4
0
 public async Task <TLAbsUpdates> SendUploadedPhoto(TLAbsInputPeer peer, TLAbsInputFile file, string caption)
 {
     return(await SendRequestAsync <TLAbsUpdates>(new TLRequestSendMedia()
     {
         RandomId = Helpers.GenerateRandomLong(),
         Background = false,
         ClearDraft = false,
         Media = new TLInputMediaUploadedPhoto()
         {
             File = file, Caption = caption
         },
         Peer = peer
     }));
 }
Example #5
0
 public async Task <TLAbsUpdates> SendUploadedPhoto(TLAbsInputPeer peer, TLAbsInputFile file, string caption, CancellationToken token = default(CancellationToken))
 {
     return(await SendRequestAsync <TLAbsUpdates>(new TLRequestSendMedia()
     {
         RandomId = Helpers.GenerateRandomLong(),
         Background = false,
         ClearDraft = false,
         Media = new TLInputMediaUploadedPhoto()
         {
             File = file, Caption = caption
         },
         Peer = peer
     }, token).ConfigureAwait(false));
 }
Example #6
0
        public async Task SendLocalVideoAsync(YVideo video, VideoStreamInfo videoStream, string path)
        {
            if (video == null)
            {
                throw new ArgumentNullException("video");
            }

            if (videoStream == null)
            {
                throw new ArgumentNullException("videoStream");
            }

            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }

            FileInfo file = new FileInfo(path);

            if (!file.Exists)
            {
                throw new Exception(string.Format("Файл по адресу {0} не найден",
                                                  path));
            }

            TLAbsInputFile           fileResult = this.UploadLocalFileToTelegram(path, video.Title);
            string                   mimeType   = "video/mp4";
            TLDocumentAttributeVideo attr1      = new TLDocumentAttributeVideo()
            {
                Duration = (int)video.Duration.TotalSeconds + 1,
                H        = videoStream.Resolution.Height,
                W        = videoStream.Resolution.Width,
            };

            TLVector <TLAbsDocumentAttribute> attrs = new TLVector <TLAbsDocumentAttribute>();

            attrs.Add(attr1);

            TLInputPeerUser peer = new TLInputPeerUser()
            {
                UserId = this.CurrentAuthUser.Id
            };
            var sendTask = this.TClient.SendUploadedDocument(
                peer, fileResult, video.Title, mimeType, attrs);

            sendTask.Wait();
        }
Example #7
0
 public async Task <TLAbsUpdates> SendUploadedDocument(
     TLAbsInputPeer peer, TLAbsInputFile file, string caption, string mimeType, TLVector <TLAbsDocumentAttribute> attributes)
 {
     return(await SendRequestAsync <TLAbsUpdates>(new TLRequestSendMedia()
     {
         RandomId = Helpers.GenerateRandomLong(),
         Background = false,
         ClearDraft = false,
         Media = new TLInputMediaUploadedDocument()
         {
             File = file,
             Caption = caption,
             MimeType = mimeType,
             Attributes = attributes
         },
         Peer = peer
     }));
 }
Example #8
0
 public async Task <TLAbsUpdates> SendUploadedDocument(
     TLAbsInputPeer peer, TLAbsInputFile file, string mimeType, TLVector <TLAbsDocumentAttribute> attributes, CancellationToken token = default(CancellationToken))
 {
     return(await SendAuthenticatedRequestAsync <TLAbsUpdates>(new TLRequestSendMedia()
     {
         RandomId = Helpers.GenerateRandomLong(),
         Background = false,
         ClearDraft = false,
         Media = new TLInputMediaUploadedDocument()
         {
             File = file,
             MimeType = mimeType,
             Attributes = attributes
         },
         Peer = peer
     }, token)
            .ConfigureAwait(false));
 }
Example #9
0
        public async Task <TLAbsUpdates> SendUploadedPhoto(TLAbsInputPeer peer, TLAbsInputFile file, string message, CancellationToken token = default(CancellationToken))
        {
            if (String.IsNullOrEmpty(message))
            {
                throw new ArgumentNullException(nameof(message));
            }

            return(await SendAuthenticatedRequestAsync <TLAbsUpdates>(new TLRequestSendMedia()
            {
                RandomId = Helpers.GenerateRandomLong(),
                Background = false,
                ClearDraft = false,
                Message = message,
                Media = new TLInputMediaUploadedPhoto()
                {
                    File = file
                },
                Peer = peer
            }, token)
                   .ConfigureAwait(false));
        }
Example #10
0
        public async Task SendFileToUserAsync(FileToUserDto model)
        {
            TLUser user = await GetUserAsync(model.Login);

            TLAbsInputFile fileResult = await UpLoadFileAsync(model.Path, model.Name);

            await client.SendUploadedDocument(
                new TLInputPeerUser()
            {
                UserId = user.Id
            },
                fileResult,
                MessageBuilder(model.SenderName, model.Subject, model.Caption),
                model.MimeType,
                new TLVector <TLAbsDocumentAttribute>()
            {
                new TLDocumentAttributeFilename
                {
                    FileName = model.Name
                }
            });

            Thread.Sleep(DileyTime);
        }
 public override void DeserializeBody(BinaryReader br)
 {
     file = (TLAbsInputFile)ObjectUtils.DeserializeObject(br);
     caption = StringUtil.Deserialize(br);
 }
Example #12
0
 public override void DeserializeBody(BinaryReader br)
 {
     File = (TLAbsInputFile)ObjectUtils.DeserializeObject(br);
 }
 public override void DeserializeBody(BinaryReader br)
 {
     file = (TLAbsInputFile)ObjectUtils.DeserializeObject(br);
     crop = (TLAbsInputPhotoCrop)ObjectUtils.DeserializeObject(br);
 }