mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
commit
7d436e3954
|
|
@ -148,16 +148,16 @@ Contributing is highly appreciated!
|
|||
|
||||
#### Release 1.0.0
|
||||
|
||||
* Add PHONE_MIGRATE handling
|
||||
* [DONE] Add PHONE_MIGRATE handling
|
||||
* Add Updates handling
|
||||
* Add NuGet package
|
||||
* Add wrappers for media uploading
|
||||
* [WIP] Add wrappers for media uploading
|
||||
* Store user session as JSON
|
||||
|
||||
# FAQ
|
||||
|
||||
#### What API layer is supported?
|
||||
The latest one - 53. Thanks to Afshin Arani
|
||||
The latest one - 57. Thanks to Afshin Arani for his TLGenerator
|
||||
|
||||
#### I get an error MIGRATE_X?
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ namespace TLSharp.Core
|
|||
|
||||
public class Session
|
||||
{
|
||||
private const string defaultConnectionAddress = "91.108.56.165";
|
||||
private const string defaultConnectionAddress = "149.154.175.100";//"149.154.167.50";
|
||||
|
||||
private const int defaultConnectionPort = 443;
|
||||
|
||||
public string SessionUserId { get; set; }
|
||||
|
|
|
|||
|
|
@ -51,16 +51,14 @@ namespace TLSharp.Core
|
|||
|
||||
_sender = new MtProtoSender(_transport, _session);
|
||||
|
||||
if (!reconnect)
|
||||
{
|
||||
var config = new TLRequestGetConfig() ;
|
||||
var request = new TLRequestInitConnection() { api_id = _apiId, app_version = "1.0.0", device_model = "PC", lang_code = "en", query= config, system_version = "Win 10.0" };
|
||||
var invokewithLayer = new TLRequestInvokeWithLayer() { layer = 53, query = request };
|
||||
//set-up layer
|
||||
var config = new TLRequestGetConfig();
|
||||
var request = new TLRequestInitConnection() { api_id = _apiId, app_version = "1.0.0", device_model = "PC", lang_code = "en", query = config, system_version = "Win 10.0" };
|
||||
var invokewithLayer = new TLRequestInvokeWithLayer() { layer = 57, query = request };
|
||||
await _sender.Send(invokewithLayer);
|
||||
await _sender.Receive(invokewithLayer);
|
||||
|
||||
dcOptions = ((TLConfig)invokewithLayer.Response).dc_options.lists;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -159,13 +157,12 @@ namespace TLSharp.Core
|
|||
return (T)result;
|
||||
}
|
||||
|
||||
|
||||
public async Task<TLContacts> GetContactsAsync()
|
||||
{
|
||||
if (!IsUserAuthorized())
|
||||
throw new InvalidOperationException("Authorize user first!");
|
||||
|
||||
var req = new TLRequestGetContacts() {hash = ""};
|
||||
var req = new TLRequestGetContacts() { hash = "" };
|
||||
|
||||
return await SendRequestAsync<TLContacts>(req);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,11 +129,7 @@ namespace TeleSharp.Generator
|
|||
}
|
||||
foreach (var c in schema.methods)
|
||||
{
|
||||
if (c.method.Contains("updateUsername"))
|
||||
{
|
||||
|
||||
}
|
||||
string path = (GetNameSpace(c.method).Replace("TeleSharp.TL", "TL\\").Replace(".", "") + "\\" + GetNameofClass(c.method, false,true) + ".cs").Replace("\\\\", "\\");
|
||||
string path = (GetNameSpace(c.method).Replace("TeleSharp.TL", "TL\\").Replace(".", "") + "\\" + GetNameofClass(c.method, false, true) + ".cs").Replace("\\\\", "\\");
|
||||
FileStream classFile = MakeFile(path);
|
||||
using (StreamWriter writer = new StreamWriter(classFile))
|
||||
{
|
||||
|
|
@ -144,7 +140,7 @@ namespace TeleSharp.Generator
|
|||
string temp = MethodStyle.Replace("/* NAMESPACE */", "TeleSharp." + nspace);
|
||||
temp = temp.Replace("/* PARENT */", "TLMethod");
|
||||
temp = temp.Replace("/*Constructor*/", c.id.ToString());
|
||||
temp = temp.Replace("/* NAME */", GetNameofClass(c.method, false,true));
|
||||
temp = temp.Replace("/* NAME */", GetNameofClass(c.method, false, true));
|
||||
#endregion
|
||||
#region Fields
|
||||
string fields = "";
|
||||
|
|
@ -244,7 +240,7 @@ namespace TeleSharp.Generator
|
|||
else if (type.IndexOf('.') != -1 && type.IndexOf('?') != -1)
|
||||
return "TLRequest" + FormatName(type.Split('?')[1]);
|
||||
else
|
||||
return "TLRequest" + FormatName(type) ;
|
||||
return "TLRequest" + FormatName(type);
|
||||
}
|
||||
}
|
||||
private static bool IsFlagBase(string type)
|
||||
|
|
@ -274,13 +270,12 @@ namespace TeleSharp.Generator
|
|||
{
|
||||
string innerType = type.Split('?')[1];
|
||||
if (innerType == "true") return result;
|
||||
else if ((new string[] {"bool","int", "uint", "long", "double" }).Contains(result)) return result + "?";
|
||||
else if ((new string[] { "bool", "int", "uint", "long", "double" }).Contains(result)) return result + "?";
|
||||
else return result;
|
||||
}
|
||||
}
|
||||
public static string GetTypeName(string type)
|
||||
{
|
||||
if (type.ToLower().Contains("inputcontact")) return "TLInputPhoneContact";
|
||||
switch (type.ToLower())
|
||||
{
|
||||
case "#":
|
||||
|
|
@ -304,10 +299,14 @@ namespace TeleSharp.Generator
|
|||
case "x":
|
||||
return "TLObject";
|
||||
}
|
||||
|
||||
if (type.StartsWith("Vector"))
|
||||
return "TLVector<" + GetTypeName(type.Replace("Vector<", "").Replace(">", "")) + ">";
|
||||
else
|
||||
{
|
||||
|
||||
if (type.ToLower().Contains("inputcontact"))
|
||||
return "TLInputPhoneContact";
|
||||
|
||||
|
||||
if (type.IndexOf('.') != -1 && type.IndexOf('?') == -1)
|
||||
{
|
||||
|
||||
|
|
@ -331,7 +330,7 @@ namespace TeleSharp.Generator
|
|||
{
|
||||
return GetTypeName(type.Split('?')[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static string LookTypeInLists(string src)
|
||||
|
|
@ -401,7 +400,7 @@ namespace TeleSharp.Generator
|
|||
{
|
||||
if (p.type.ToLower().Contains("vector"))
|
||||
{
|
||||
return $"{CheckForKeyword(p.name)} = ({GetTypeName(p.type)})ObjectUtils.DeserializeVector<{GetTypeName(p.type).Replace("TLVector<","").Replace(">","")}>(br);";
|
||||
return $"{CheckForKeyword(p.name)} = ({GetTypeName(p.type)})ObjectUtils.DeserializeVector<{GetTypeName(p.type).Replace("TLVector<", "").Replace(">", "")}>(br);";
|
||||
}
|
||||
else return $"{CheckForKeyword(p.name)} = ({GetTypeName(p.type)})ObjectUtils.DeserializeObject(br);";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace TeleSharp.TL.Contacts
|
|||
|
||||
public override void DeserializeBody(BinaryReader br)
|
||||
{
|
||||
contacts = ObjectUtils.DeserializeVector<TLInputPhoneContact>(br);
|
||||
contacts = (TLVector<TLInputPhoneContact>)ObjectUtils.DeserializeVector<TLInputPhoneContact>(br);
|
||||
replace = BoolUtil.Deserialize(br);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue