Fixed OffSet paramets for GetUserDialogsAsync & GetHistoryAsync (#831)

Fixes https://github.com/sochix/TLSharp/issues/696

Fixes https://github.com/sochix/TLSharp/issues/597
This commit is contained in:
Marc R Kellerman 2019-01-04 02:16:35 -08:00 committed by Andres G. Aragoneses
parent 47e973823a
commit f2a394ea15

View file

@ -258,11 +258,22 @@ namespace TLSharp.Core
return await SendRequestAsync<Boolean>(req); return await SendRequestAsync<Boolean>(req);
} }
public async Task<TLAbsDialogs> GetUserDialogsAsync() public async Task<TLAbsDialogs> GetUserDialogsAsync(int offsetDate = 0, int offsetId = 0, TLAbsInputPeer offsetPeer = null, int limit = 100)
{ {
var peer = new TLInputPeerSelf(); if (!IsUserAuthorized())
return await SendRequestAsync<TLAbsDialogs>( throw new InvalidOperationException("Authorize user first!");
new TLRequestGetDialogs() { OffsetDate = 0, OffsetPeer = peer, Limit = 100 });
if (offsetPeer == null)
offsetPeer = new TLInputPeerSelf();
var req = new TLRequestGetDialogs()
{
OffsetDate = offsetDate,
OffsetId = offsetId,
OffsetPeer = offsetPeer,
Limit = limit
};
return await SendRequestAsync<TLAbsDialogs>(req);
} }
public async Task<TLAbsUpdates> SendUploadedPhoto(TLAbsInputPeer peer, TLAbsInputFile file, string caption) public async Task<TLAbsUpdates> SendUploadedPhoto(TLAbsInputPeer peer, TLAbsInputFile file, string caption)
@ -313,7 +324,7 @@ namespace TLSharp.Core
await _sender.SendPingAsync(); await _sender.SendPingAsync();
} }
public async Task<TLAbsMessages> GetHistoryAsync(TLAbsInputPeer peer, int offset, int max_id, int limit) public async Task<TLAbsMessages> GetHistoryAsync(TLAbsInputPeer peer, int offsetId = 0, int offsetDate = 0, int addOffset = 0, int limit = 100, int maxId = 0, int minId = 0)
{ {
if (!IsUserAuthorized()) if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!"); throw new InvalidOperationException("Authorize user first!");
@ -321,9 +332,12 @@ namespace TLSharp.Core
var req = new TLRequestGetHistory() var req = new TLRequestGetHistory()
{ {
Peer = peer, Peer = peer,
AddOffset = offset, OffsetId = offsetId,
MaxId = max_id, OffsetDate = offsetDate,
Limit = limit AddOffset = addOffset,
Limit = limit,
MaxId = maxId,
MinId = minId
}; };
return await SendRequestAsync<TLAbsMessages>(req); return await SendRequestAsync<TLAbsMessages>(req);
} }