mirror of
https://github.com/sochix/TLSharp.git
synced 2026-04-06 15:05:54 +00:00
UserFullConstructor : UserFull no accepts self id.
Added test method to GetUserFull Added info to README.md
This commit is contained in:
parent
2fff2d11c2
commit
6365297aaf
7 changed files with 98 additions and 3 deletions
|
|
@ -7126,10 +7126,15 @@ namespace TLSharp.Core.MTProto
|
|||
|
||||
public override void Read(BinaryReader reader)
|
||||
{
|
||||
this.user = new UserRequestConstructor();
|
||||
uint dataCode = reader.ReadUInt32();
|
||||
if (reader.ReadUInt32() == 0x7007b451)
|
||||
{
|
||||
this.user = new UserSelfConstructor();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.user = new UserRequestConstructor();
|
||||
}
|
||||
this.user.Read(reader);
|
||||
|
||||
this.link = TL.Parse<contacts_Link>(reader);
|
||||
this.profile_photo = TL.Parse<Photo>(reader);
|
||||
this.notify_settings = TL.Parse<PeerNotifySettings>(reader);
|
||||
|
|
|
|||
42
TLSharp.Core/Requests/GetUserFullRequest.cs
Normal file
42
TLSharp.Core/Requests/GetUserFullRequest.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using TLSharp.Core.MTProto;
|
||||
|
||||
namespace TLSharp.Core.Requests
|
||||
{
|
||||
public class GetUserFullRequest : MTProtoRequest
|
||||
{
|
||||
private InputUser _inputUser;
|
||||
public UserFull _userFull;
|
||||
|
||||
public GetUserFullRequest(int id)
|
||||
{
|
||||
_inputUser = new InputUserContactConstructor(id);
|
||||
}
|
||||
|
||||
public override void OnSend(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(0xca30a5b1);
|
||||
_inputUser.Write(writer);
|
||||
}
|
||||
|
||||
public override void OnResponse(BinaryReader reader)
|
||||
{
|
||||
_userFull = new UserFullConstructor();
|
||||
var dataCode = reader.ReadUInt32();
|
||||
_userFull.Read(reader);
|
||||
}
|
||||
|
||||
public override void OnException(Exception exception)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override bool Responded
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public override bool Confirmed => true;
|
||||
}
|
||||
}
|
||||
|
|
@ -71,6 +71,7 @@
|
|||
<Compile Include="Requests\GetFileRequest.cs" />
|
||||
<Compile Include="Requests\GetHistoryRequest.cs" />
|
||||
<Compile Include="Requests\GetNearestDcRequest.cs" />
|
||||
<Compile Include="Requests\GetUserFullRequest.cs" />
|
||||
<Compile Include="Requests\GetUsersRequest.cs" />
|
||||
<Compile Include="Requests\ImportByUserName.cs" />
|
||||
<Compile Include="Requests\ImportContactRequest.cs" />
|
||||
|
|
|
|||
|
|
@ -241,6 +241,15 @@ namespace TLSharp.Core
|
|||
return request.messages;
|
||||
}
|
||||
|
||||
public async Task<UserFull> GetUserFull(int user_id)
|
||||
{
|
||||
var request = new GetUserFullRequest(user_id);
|
||||
await _sender.Send(request);
|
||||
await _sender.Recieve(request);
|
||||
|
||||
return request._userFull;
|
||||
}
|
||||
|
||||
private bool validateNumber(string number)
|
||||
{
|
||||
var regex = new Regex("^\\d{7,20}$");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue