mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
Small improvements
This commit is contained in:
parent
9cc6942088
commit
69700fdad0
|
|
@ -220,17 +220,7 @@ namespace TLSharp.Core
|
|||
await _sender.Recieve(request);
|
||||
}
|
||||
|
||||
public async Task<Tuple<List<Chat>, List<User>>> LoadChatsAndUsers(int offset, int max_id, int limit)
|
||||
{
|
||||
// GetDialogs
|
||||
var request = new GetDialogsRequest(offset, max_id, limit);
|
||||
await _sender.Send(request);
|
||||
await _sender.Recieve(request);
|
||||
|
||||
return new Tuple<List<Chat>, List<User>>(request.chats, request.users);
|
||||
}
|
||||
|
||||
public async Task<List<Message>> GetHistory(int user_id, int offset, int max_id, int limit)
|
||||
public async Task<List<Message>> GetMessagesHistoryForContact(int user_id, int offset, int limit, int max_id = -1)
|
||||
{
|
||||
var request = new GetHistoryRequest(new InputPeerContactConstructor(user_id), offset, max_id, limit);
|
||||
await _sender.Send(request);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace TLSharp.Tests
|
|||
await client.Connect();
|
||||
|
||||
var hash = await client.SendCodeRequest(NumberToAuthenticate);
|
||||
var code = "64443"; // you can change code in debugger
|
||||
var code = "93463"; // you can change code in debugger
|
||||
|
||||
var user = await client.MakeAuth(NumberToAuthenticate, hash, code);
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ namespace TLSharp.Tests
|
|||
|
||||
Assert.IsNotNull(res);
|
||||
|
||||
var hist = await client.GetHistory(res.Value, 0, -1, 5);
|
||||
var hist = await client.GetMessagesHistoryForContact(res.Value, 0, 5);
|
||||
|
||||
Assert.IsNotNull(hist);
|
||||
}
|
||||
|
|
@ -195,12 +195,5 @@ namespace TLSharp.Tests
|
|||
Assert.IsNotNull(authKey.AuthKey.Data);
|
||||
}
|
||||
}
|
||||
|
||||
static byte[] GetBytes(string str)
|
||||
{
|
||||
byte[] bytes = new byte[str.Length * sizeof(char)];
|
||||
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue