mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
- Update layer to 23
- Start implementing get user by userName
This commit is contained in:
parent
e281f281dd
commit
1dce594e43
|
|
@ -10966,6 +10966,7 @@ namespace TLSharp.Core.MTProto
|
|||
public override void Read(BinaryReader reader)
|
||||
{
|
||||
this.date = reader.ReadInt32();
|
||||
var expires = reader.ReadInt32();
|
||||
this.test_mode = reader.ReadUInt32() == 0x997275b5;
|
||||
this.this_dc = reader.ReadInt32();
|
||||
reader.ReadInt32(); // vector code
|
||||
|
|
|
|||
35
TLSharp.Core/Requests/ImportByUserName.cs
Normal file
35
TLSharp.Core/Requests/ImportByUserName.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using TLSharp.Core.MTProto;
|
||||
|
||||
namespace TLSharp.Core.Requests
|
||||
{
|
||||
public class ImportByUserName : MTProtoRequest
|
||||
{
|
||||
private readonly string _userName;
|
||||
public ImportByUserName(string userName)
|
||||
{
|
||||
_userName = userName;
|
||||
}
|
||||
|
||||
public override void OnSend(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(0xf93ccba3);
|
||||
Serializers.String.write(writer, _userName);
|
||||
}
|
||||
|
||||
public override void OnResponse(BinaryReader reader)
|
||||
{
|
||||
var code = reader.ReadUInt32();
|
||||
var peer = TL.Parse<Peer>(reader);
|
||||
}
|
||||
|
||||
public override void OnException(Exception exception)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override bool Confirmed { get; }
|
||||
public override bool Responded { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -16,7 +16,8 @@ namespace TLSharp.Core.Requests
|
|||
|
||||
public override void OnSend(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(0x1c900537); // invokeWithLayer18#1c900537
|
||||
writer.Write(0xda9b0d0d);
|
||||
writer.Write(23);// invokeWithLayer23#1c900537
|
||||
writer.Write(0x69796de9); // initConnection
|
||||
writer.Write(_apiId); // api id
|
||||
Serializers.String.write(writer, "WinPhone Emulator"); // device model
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@
|
|||
<Compile Include="Requests\GetHistoryRequest.cs" />
|
||||
<Compile Include="Requests\GetNearestDcRequest.cs" />
|
||||
<Compile Include="Requests\GetUsersRequest.cs" />
|
||||
<Compile Include="Requests\ImportByUserName.cs" />
|
||||
<Compile Include="Requests\ImportContactRequest.cs" />
|
||||
<Compile Include="Requests\InitConnectionRequest.cs" />
|
||||
<Compile Include="Requests\MTProtoRequest.cs" />
|
||||
|
|
|
|||
|
|
@ -210,6 +210,15 @@ namespace TLSharp.Core
|
|||
return importedUser?.user_id;
|
||||
}
|
||||
|
||||
public async Task<int?> ImportByUserName(string username)
|
||||
{
|
||||
var request = new ImportByUserName(username);
|
||||
await _sender.Send(request);
|
||||
await _sender.Recieve(request);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task SendMessage(int id, string message)
|
||||
{
|
||||
var request = new SendMessageRequest(new InputPeerContactConstructor(id), message);
|
||||
|
|
|
|||
|
|
@ -72,6 +72,21 @@ namespace TLSharp.Tests
|
|||
Assert.IsNotNull(res);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task ImportByUserName()
|
||||
{
|
||||
var store = new FileSessionStore();
|
||||
var client = new TelegramClient(store, "session");
|
||||
|
||||
await client.Connect();
|
||||
|
||||
Assert.IsTrue(client.IsUserAuthorized());
|
||||
|
||||
var res = await client.ImportByUserName(NumberToSendMessage);
|
||||
|
||||
Assert.IsNotNull(res);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task SendMessage()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue