diff --git a/README.md b/README.md index 8cdba23..4304ce5 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,7 @@ For your convenience TLSharp have wrappers for several Telegram API methods. You 1. GetFile 1. UploadFile 1. SendPingAsync +1. GetHistoryAsync **What if you can't find needed method at the list?** diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 732adad..1847f4b 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; -using System.Web; using TeleSharp.TL; using TeleSharp.TL.Account; using TeleSharp.TL.Auth; @@ -15,7 +14,6 @@ using TeleSharp.TL.Upload; using TLSharp.Core.Auth; using TLSharp.Core.MTProto.Crypto; using TLSharp.Core.Network; -using TLSharp.Core.Requests; using TLSharp.Core.Utils; using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization; @@ -335,6 +333,21 @@ namespace TLSharp.Core public async Task SendPingAsync() { await _sender.SendPingAsync(); + } + + public async Task GetHistoryAsync(TLAbsInputPeer peer, int offset, int max_id, int limit) + { + if (!IsUserAuthorized()) + throw new InvalidOperationException("Authorize user first!"); + + var req = new TLRequestGetHistory() + { + peer = peer, + add_offset = offset, + max_id = max_id, + limit = limit + }; + return await SendRequestAsync(req); } ///