public static async Task <bool> SendTypingAsync(this ITelegramClient client, TlAbsInputPeer peer) { var req = new TlRequestSetTyping { Action = new TlSendMessageTypingAction(), Peer = peer }; return(await client.SendRequestAsync <bool>(req)); }
public async Task <TlAbsUpdates> SendMessageAsync(TlAbsInputPeer peer, string message) { if (!this.IsUserAuthorized()) { throw new InvalidOperationException("Authorize user first!"); } return(await SendRequestAsync <TlAbsUpdates>( new TlRequestSendMessage { Peer = peer, Message = message, RandomId = TlHelpers.GenerateRandomLong() })); }
public async Task SendTextMessage(Peer peer, int receiverId, string msg) { TlAbsInputPeer receiver = await GetInputPeer(peer, receiverId); var update = await _client.SendMessageAsync(receiver, msg); Message message = null; if (update is TlUpdateShortSentMessage) { message = _ioc.Resolve <Message>(); message.FillValues("You", msg, (update as TlUpdateShortSentMessage).TimeUnixToWindows(true)); } else { message = GetMessage(update); } OnSendMessage?.Invoke(message); }
public static async Task <TlAbsUpdates> SendUploadedDocument( this ITelegramClient client, TlAbsInputPeer peer, TlAbsInputFile file, string caption, string mimeType, TlVector <TlAbsDocumentAttribute> attributes) { return(await client.SendRequestAsync <TlAbsUpdates>(new TlRequestSendMedia { RandomId = TlHelpers.GenerateRandomLong(), Background = false, ClearDraft = false, Media = new TlInputMediaUploadedDocument { File = file, Caption = caption, MimeType = mimeType, Attributes = attributes }, Peer = peer })); }
public override void DeserializeBody(BinaryReader br) { Peer = (TlAbsInputPeer)ObjectUtils.DeserializeObject(br); }
public static async Task <TlAbsMessages> GetHistoryAsync(this ITelegramClient client, TlAbsInputPeer peer, int offset, int maxId, int limit) { if (!client.IsUserAuthorized()) { throw new InvalidOperationException("Authorize user first!"); } var req = new TlRequestGetHistory { Peer = peer, AddOffset = offset, MaxId = maxId, Limit = limit }; return(await client.SendRequestAsync <TlAbsMessages>(req)); }
public static async Task <TlAbsUpdates> SendUploadedPhoto(this ITelegramClient client, TlAbsInputPeer peer, TlAbsInputFile file, string caption) { return(await client.SendRequestAsync <TlAbsUpdates>(new TlRequestSendMedia { RandomId = TlHelpers.GenerateRandomLong(), Background = false, ClearDraft = false, Media = new TlInputMediaUploadedPhoto { File = file, Caption = caption }, Peer = peer })); }