Add GetHistoryAsync() to TelegramClient

This commit is contained in:
Starli0n 2017-01-09 18:25:55 +01:00
parent 47d1c10c9d
commit 5e6cf48490
2 changed files with 16 additions and 2 deletions

View file

@ -161,6 +161,7 @@ For your convenience TLSharp have wrappers for several Telegram API methods. You
1. GetFile 1. GetFile
1. UploadFile 1. UploadFile
1. SendPingAsync 1. SendPingAsync
1. GetHistoryAsync
**What if you can't find needed method at the list?** **What if you can't find needed method at the list?**

View file

@ -4,7 +4,6 @@ using System.Linq;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web;
using TeleSharp.TL; using TeleSharp.TL;
using TeleSharp.TL.Account; using TeleSharp.TL.Account;
using TeleSharp.TL.Auth; using TeleSharp.TL.Auth;
@ -15,7 +14,6 @@ using TeleSharp.TL.Upload;
using TLSharp.Core.Auth; using TLSharp.Core.Auth;
using TLSharp.Core.MTProto.Crypto; using TLSharp.Core.MTProto.Crypto;
using TLSharp.Core.Network; using TLSharp.Core.Network;
using TLSharp.Core.Requests;
using TLSharp.Core.Utils; using TLSharp.Core.Utils;
using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization; using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization;
@ -337,6 +335,21 @@ namespace TLSharp.Core
await _sender.SendPingAsync(); await _sender.SendPingAsync();
} }
public async Task<TLAbsMessages> 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<TLAbsMessages>(req);
}
/// <summary> /// <summary>
/// Serch user or chat. API: contacts.search#11f812d8 q:string limit:int = contacts.Found; /// Serch user or chat. API: contacts.search#11f812d8 q:string limit:int = contacts.Found;
/// </summary> /// </summary>