mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
Fixes
This commit is contained in:
parent
a14dfdc1fe
commit
2ffa954246
|
|
@ -13,6 +13,8 @@ using TeleSharp.TL;
|
||||||
using MD5 = System.Security.Cryptography.MD5;
|
using MD5 = System.Security.Cryptography.MD5;
|
||||||
using TeleSharp.TL.Help;
|
using TeleSharp.TL.Help;
|
||||||
using TeleSharp.TL.Auth;
|
using TeleSharp.TL.Auth;
|
||||||
|
using TeleSharp.TL.Contacts;
|
||||||
|
using TeleSharp.TL.Messages;
|
||||||
|
|
||||||
namespace TLSharp.Core
|
namespace TLSharp.Core
|
||||||
{
|
{
|
||||||
|
|
@ -153,8 +155,56 @@ namespace TLSharp.Core
|
||||||
{
|
{
|
||||||
await _sender.Send(methodtoExceute);
|
await _sender.Send(methodtoExceute);
|
||||||
await _sender.Receive(methodtoExceute);
|
await _sender.Receive(methodtoExceute);
|
||||||
return (T)Convert.ChangeType(typeof(TLMethod).GetProperty("Response").GetValue(methodtoExceute),typeof(T));
|
|
||||||
|
var result = methodtoExceute.GetType().GetProperty("Response").GetValue(methodtoExceute);
|
||||||
|
|
||||||
|
return (T)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<TLContacts> GetContacts()
|
||||||
|
{
|
||||||
|
if (!IsUserAuthorized())
|
||||||
|
throw new InvalidOperationException("Authorize user first!");
|
||||||
|
|
||||||
|
var req = new TLRequestGetContacts() {hash = ""};
|
||||||
|
|
||||||
|
return await SendRequest<TLContacts>(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<TLAbsUpdates> SendMessage(TLAbsInputPeer peer, string message)
|
||||||
|
{
|
||||||
|
if (!IsUserAuthorized())
|
||||||
|
throw new InvalidOperationException("Authorize user first!");
|
||||||
|
|
||||||
|
long uniqueId = Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds);
|
||||||
|
|
||||||
|
return await SendRequest<TLAbsUpdates>(
|
||||||
|
new TLRequestSendMessage()
|
||||||
|
{
|
||||||
|
peer = peer,
|
||||||
|
message = message,
|
||||||
|
random_id = uniqueId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Boolean> SendTyping(TLAbsInputPeer peer)
|
||||||
|
{
|
||||||
|
var req = new TLRequestSetTyping()
|
||||||
|
{
|
||||||
|
action = new TLSendMessageTypingAction(),
|
||||||
|
peer = peer
|
||||||
|
};
|
||||||
|
return await SendRequest<Boolean>(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<TLDialogs> GetUserDialogs()
|
||||||
|
{
|
||||||
|
var peer = new TLInputPeerSelf();
|
||||||
|
return await SendRequest<TLDialogs>(
|
||||||
|
new TLRequestGetDialogs() { offset_date = 0, offset_peer = peer, limit = 100 });
|
||||||
|
}
|
||||||
|
|
||||||
private void OnUserAuthenticated(TLUser TLUser)
|
private void OnUserAuthenticated(TLUser TLUser)
|
||||||
{
|
{
|
||||||
_session.TLUser = TLUser;
|
_session.TLUser = TLUser;
|
||||||
|
|
|
||||||
|
|
@ -18,35 +18,35 @@ namespace TeleSharp.TL.Auth
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int flags { get; set; }
|
public int flags {get;set;}
|
||||||
public bool allow_flashcall { get; set; }
|
public bool allow_flashcall {get;set;}
|
||||||
public string phone_number { get; set; }
|
public string phone_number {get;set;}
|
||||||
public bool? current_number { get; set; }
|
public bool? current_number {get;set;}
|
||||||
public int api_id { get; set; }
|
public int api_id {get;set;}
|
||||||
public string api_hash { get; set; }
|
public string api_hash {get;set;}
|
||||||
public Auth.TLSentCode Response { get; set; }
|
public Auth.TLSentCode Response{ get; set;}
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
flags = 0;
|
flags = 0;
|
||||||
flags = allow_flashcall ? (flags | 1) : (flags & ~1);
|
flags = allow_flashcall ? (flags | 1) : (flags & ~1);
|
||||||
flags = current_number != null ? (flags | 1) : (flags & ~1);
|
flags = current_number != null ? (flags | 1) : (flags & ~1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
flags = br.ReadInt32();
|
flags = br.ReadInt32();
|
||||||
allow_flashcall = (flags & 1) != 0;
|
allow_flashcall = (flags & 1) != 0;
|
||||||
phone_number = StringUtil.Deserialize(br);
|
phone_number = StringUtil.Deserialize(br);
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
current_number = BoolUtil.Deserialize(br);
|
current_number = BoolUtil.Deserialize(br);
|
||||||
else
|
else
|
||||||
current_number = null;
|
current_number = null;
|
||||||
|
|
||||||
api_id = br.ReadInt32();
|
api_id = br.ReadInt32();
|
||||||
api_hash = StringUtil.Deserialize(br);
|
api_hash = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,13 +54,13 @@ namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ComputeFlags();
|
ComputeFlags();
|
||||||
bw.Write(flags);
|
bw.Write(flags);
|
||||||
|
|
||||||
StringUtil.Serialize(phone_number, bw);
|
StringUtil.Serialize(phone_number,bw);
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
BoolUtil.Serialize(current_number.Value, bw);
|
BoolUtil.Serialize(current_number.Value,bw);
|
||||||
bw.Write(api_id);
|
bw.Write(api_id);
|
||||||
StringUtil.Serialize(api_hash, bw);
|
StringUtil.Serialize(api_hash,bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ namespace TeleSharp.TL.Contacts
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
contacts = (TLVector<TLInputPhoneContact>)ObjectUtils.DeserializeVector<TLInputPhoneContact>(br);
|
contacts = ObjectUtils.DeserializeVector<TLInputPhoneContact>(br);
|
||||||
replace = BoolUtil.Deserialize(br);
|
replace = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
13
TeleSharp.TL/TL/TLAbsBool.cs
Normal file
13
TeleSharp.TL/TL/TLAbsBool.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TeleSharp.TL;
|
||||||
|
namespace TeleSharp.TL
|
||||||
|
{
|
||||||
|
public abstract class TLAbsBool : TLObject
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
39
TeleSharp.TL/TL/TLBoolFalse.cs
Normal file
39
TeleSharp.TL/TL/TLBoolFalse.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TeleSharp.TL;
|
||||||
|
namespace TeleSharp.TL
|
||||||
|
{
|
||||||
|
[TLObject(-1132882121)]
|
||||||
|
public class TLBoolFalse : TLAbsBool
|
||||||
|
{
|
||||||
|
public override int Constructor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return -1132882121;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void ComputeFlags()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DeserializeBody(BinaryReader br)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
|
{
|
||||||
|
bw.Write(Constructor);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
39
TeleSharp.TL/TL/TLBoolTrue.cs
Normal file
39
TeleSharp.TL/TL/TLBoolTrue.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TeleSharp.TL;
|
||||||
|
namespace TeleSharp.TL
|
||||||
|
{
|
||||||
|
[TLObject(-1720552011)]
|
||||||
|
public class TLBoolTrue : TLAbsBool
|
||||||
|
{
|
||||||
|
public override int Constructor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return -1720552011;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void ComputeFlags()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DeserializeBody(BinaryReader br)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
|
{
|
||||||
|
bw.Write(Constructor);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
39
TeleSharp.TL/TL/TLTrue.cs
Normal file
39
TeleSharp.TL/TL/TLTrue.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TeleSharp.TL;
|
||||||
|
namespace TeleSharp.TL
|
||||||
|
{
|
||||||
|
[TLObject(1072550713)]
|
||||||
|
public class TLTrue : TLObject
|
||||||
|
{
|
||||||
|
public override int Constructor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 1072550713;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void ComputeFlags()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DeserializeBody(BinaryReader br)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
|
{
|
||||||
|
bw.Write(Constructor);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -53,7 +53,11 @@ namespace TeleSharp.TL
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
bw.Write(Constructor);
|
||||||
|
foreach (var item in lists.Cast<TLObject>())
|
||||||
|
{
|
||||||
|
item.SerializeBody(bw);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -301,6 +301,7 @@
|
||||||
<Compile Include="TL\Storage\TLFilePng.cs" />
|
<Compile Include="TL\Storage\TLFilePng.cs" />
|
||||||
<Compile Include="TL\Storage\TLFileUnknown.cs" />
|
<Compile Include="TL\Storage\TLFileUnknown.cs" />
|
||||||
<Compile Include="TL\Storage\TLFileWebp.cs" />
|
<Compile Include="TL\Storage\TLFileWebp.cs" />
|
||||||
|
<Compile Include="TL\TLAbsBool.cs" />
|
||||||
<Compile Include="TL\TLAbsBotInlineMessage.cs" />
|
<Compile Include="TL\TLAbsBotInlineMessage.cs" />
|
||||||
<Compile Include="TL\TLAbsBotInlineResult.cs" />
|
<Compile Include="TL\TLAbsBotInlineResult.cs" />
|
||||||
<Compile Include="TL\TLAbsChannelMessagesFilter.cs" />
|
<Compile Include="TL\TLAbsChannelMessagesFilter.cs" />
|
||||||
|
|
@ -370,6 +371,8 @@
|
||||||
<Compile Include="TL\TLAbsWebPage.cs" />
|
<Compile Include="TL\TLAbsWebPage.cs" />
|
||||||
<Compile Include="TL\TLAccountDaysTTL.cs" />
|
<Compile Include="TL\TLAccountDaysTTL.cs" />
|
||||||
<Compile Include="TL\TLAuthorization.cs" />
|
<Compile Include="TL\TLAuthorization.cs" />
|
||||||
|
<Compile Include="TL\TLBoolFalse.cs" />
|
||||||
|
<Compile Include="TL\TLBoolTrue.cs" />
|
||||||
<Compile Include="TL\TLBotCommand.cs" />
|
<Compile Include="TL\TLBotCommand.cs" />
|
||||||
<Compile Include="TL\TLBotInfo.cs" />
|
<Compile Include="TL\TLBotInfo.cs" />
|
||||||
<Compile Include="TL\TLBotInlineMediaResult.cs" />
|
<Compile Include="TL\TLBotInlineMediaResult.cs" />
|
||||||
|
|
@ -639,6 +642,7 @@
|
||||||
<Compile Include="TL\TLTopPeerCategoryCorrespondents.cs" />
|
<Compile Include="TL\TLTopPeerCategoryCorrespondents.cs" />
|
||||||
<Compile Include="TL\TLTopPeerCategoryGroups.cs" />
|
<Compile Include="TL\TLTopPeerCategoryGroups.cs" />
|
||||||
<Compile Include="TL\TLTopPeerCategoryPeers.cs" />
|
<Compile Include="TL\TLTopPeerCategoryPeers.cs" />
|
||||||
|
<Compile Include="TL\TLTrue.cs" />
|
||||||
<Compile Include="TL\TLUpdateBotCallbackQuery.cs" />
|
<Compile Include="TL\TLUpdateBotCallbackQuery.cs" />
|
||||||
<Compile Include="TL\TLUpdateBotInlineQuery.cs" />
|
<Compile Include="TL\TLUpdateBotInlineQuery.cs" />
|
||||||
<Compile Include="TL\TLUpdateBotInlineSend.cs" />
|
<Compile Include="TL\TLUpdateBotInlineSend.cs" />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue