private void SendDocument(TLDocument document, string caption) { var media = new TLMessageMediaDocument { Document = document, Caption = caption }; var date = TLUtils.DateToUniversalTimeTLInt(ProtoService.ClientTicksDelta, DateTime.Now); var message = TLUtils.GetMessage(SettingsHelper.UserId, Peer.ToPeer(), TLMessageState.Sending, true, true, date, string.Empty, media, TLLong.Random(), null); if (Reply != null) { message.HasReplyToMsgId = true; message.ReplyToMsgId = Reply.Id; message.Reply = Reply; Reply = null; } var previousMessage = InsertSendingMessage(message, false); CacheService.SyncSendingMessage(message, previousMessage, async (m) => { var input = new TLInputMediaDocument { Caption = caption, Id = new TLInputDocument { Id = document.Id, AccessHash = document.AccessHash, } }; await ProtoService.SendMediaAsync(Peer, input, message); }); }
public void SendSticker(TLDocument22 document) { if (document == null) { return; } var media = new TLMessageMediaDocument { FileId = TLLong.Random(), Document = document }; var message = GetMessage(TLString.Empty, media); var inputMedia = new TLInputMediaDocument { MD5Hash = new byte[] { }, Id = new TLInputDocument { Id = document.Id, AccessHash = document.AccessHash } }; message.InputMedia = inputMedia; BeginOnUIThread(() => { var previousMessage = InsertSendingMessage(message); IsEmptyDialog = Items.Count == 0 && LazyItems.Count == 0; Text = string.Empty; BeginOnThreadPool(() => CacheService.SyncSendingMessage( message, previousMessage, TLUtils.InputPeerToPeer(Peer, StateService.CurrentUserId), m => ShellViewModel.SendMediaInternal(message, MTProtoService, StateService, CacheService))); }); }