Update Everything

This commit is contained in:
Afshin Arani 2016-09-22 17:01:59 +03:30
parent f083fb9b30
commit 1c2e354967
28 changed files with 250 additions and 16163 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,45 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
class AddChatUserRequest : MTProtoRequest
{
private int _chatID;
private InputUserContactConstructor _user;
private string _title;
public Messages_statedMessageConstructor message;
public AddChatUserRequest(int chatID, InputUserContactConstructor user)
{
_chatID = chatID;
_user = user;
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0x2ee9ee9e);
writer.Write(_chatID);
_user.Write(writer);
writer.Write(1);
}
public override void OnResponse(BinaryReader reader)
{
message = TL.Parse<Messages_statedMessageConstructor>(reader);
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed { get { return true; } }
private readonly bool responded;
public override bool Responded { get { return responded; } }
}
}

View file

@ -1,39 +0,0 @@
using System;
using System.IO;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
public class AuthCheckPhoneRequest : MTProtoRequest
{
private string _phoneNumber;
public bool _phoneRegistered;
private bool _phoneInvited;
public AuthCheckPhoneRequest(string phoneNumber)
{
_phoneNumber = phoneNumber;
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0x6fe51dfb);
Serializers.String.write(writer, _phoneNumber);
}
public override void OnResponse(BinaryReader reader)
{
var dataCode = reader.ReadUInt32(); // #e300cc3b
this._phoneRegistered = reader.ReadUInt32() == 0x997275b5;
this._phoneInvited = reader.ReadUInt32() == 0x997275b5;
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed => true;
public override bool Responded { get; }
}
}

View file

@ -1,46 +1,40 @@
using System;
using System.IO;
using TLSharp.Core.MTProto;
using TeleSharp.TL;
namespace TLSharp.Core.Requests
{
public class AuthSendCodeRequest : MTProtoRequest
{
private readonly string _phoneNumber;
private readonly int _smsType;
private readonly int _apiId;
private readonly string _apiHash;
private readonly string _langCode;
public bool _phoneRegistered;
public string _phoneCodeHash;
public SendCodeArgs args=new SendCodeArgs();
public AuthSendCodeRequest(string phoneNumber, int smsType, int apiId, string apiHash, string langCode)
{
_phoneNumber = phoneNumber;
_smsType = smsType;
_apiId = apiId;
_apiHash = apiHash;
_langCode = langCode;
args.phone_number = phoneNumber;
args.api_id = apiId;
args.api_hash = apiHash;
args.allow_flashcall = false;
args.current_number = true;
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0x768d5f4d);
Serializers.String.write(writer, _phoneNumber);
writer.Write(_smsType);
writer.Write(_apiId);
Serializers.String.write(writer, _apiHash);
Serializers.String.write(writer, _langCode);
writer.Write(0x86AEF0EC);
writer.Write(0);
Serializers.String.write(writer, args.phone_number);
writer.Write(args.api_id.Value);
Serializers.String.write(writer, args.api_hash);
}
public override void OnResponse(BinaryReader reader)
{
var boolTrue = 0x997275b5;
var dataCode = reader.ReadUInt32(); // 0x2215bcbd
_phoneRegistered = reader.ReadUInt32() == boolTrue;
_phoneCodeHash = Serializers.String.read(reader);
var sendCodeTimeout = reader.ReadInt32();
var isPassword = reader.ReadUInt32() == boolTrue;
var s = Deserializer.Deserialize(typeof(SentCode), reader);
_phoneRegistered = ((SentCode)s).phone_registered;
_phoneCodeHash = ((SentCode)s).phone_code_hash;
}
public override void OnException(Exception exception)

View file

@ -1,40 +0,0 @@
using System;
using System.IO;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
public class AuthSendSmsRequest : MTProtoRequest
{
private readonly string _phoneNumber;
private readonly string _phoneCodeHash;
public bool _smsSent;
public AuthSendSmsRequest(string phoneNumber, string phoneCodeHash)
{
_phoneNumber = phoneNumber;
_phoneCodeHash = phoneCodeHash;
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0xda9f3e8);
Serializers.String.write(writer, _phoneNumber);
Serializers.String.write(writer, _phoneCodeHash);
}
public override void OnResponse(BinaryReader reader)
{
var dataCode = reader.ReadUInt32();
_smsSent = reader.ReadUInt32() == 0x997275b5;
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed => true;
public override bool Responded { get; }
}
}

View file

@ -1,37 +1,30 @@
using System;
using System.IO;
using TLSharp.Core.MTProto;
using TeleSharp.TL;
namespace TLSharp.Core.Requests
{
public class AuthSignInRequest : MTProtoRequest
{
private readonly string _phoneNumber;
private readonly string _phoneCodeHash;
private readonly string _code;
private SignInArgs args = new SignInArgs();
public User user;
public int SessionExpires;
public AuthSignInRequest(string phoneNumber, string phoneCodeHash, string code)
{
_phoneNumber = phoneNumber;
_phoneCodeHash = phoneCodeHash;
_code = code;
args.phone_number = phoneNumber;
args.phone_code_hash = phoneCodeHash;
args.phone_code = code;
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0xbcd51581);
Serializers.String.write(writer, _phoneNumber);
Serializers.String.write(writer, _phoneCodeHash);
Serializers.String.write(writer, _code);
Serializer.Serialize(args, typeof(SignInArgs), writer);
}
public override void OnResponse(BinaryReader reader)
{
var dataCode = reader.ReadUInt32(); //0xf6b673a4
var expires = reader.ReadInt32();
user = TL.Parse<User>(reader);
var auth = (Authorization)Deserializer.Deserialize(typeof(Authorization), reader);
user = auth.user;
}
public override void OnException(Exception exception)

View file

@ -1,52 +0,0 @@
using System;
using System.IO;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
public class AuthSignUpRequest : MTProtoRequest
{
private readonly string _phoneNumber;
private readonly string _phoneCodeHash;
private readonly string _code;
private readonly string _firstName;
private readonly string _lastName;
public User user;
public int SessionExpires;
public AuthSignUpRequest(string phoneNumber, string phoneCodeHash, string code, string firstName, string lastName)
{
_phoneNumber = phoneNumber;
_phoneCodeHash = phoneCodeHash;
_code = code;
_firstName = firstName;
_lastName = lastName;
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0x1b067634);
Serializers.String.write(writer, _phoneNumber);
Serializers.String.write(writer, _phoneCodeHash);
Serializers.String.write(writer, _code);
Serializers.String.write(writer, _firstName);
Serializers.String.write(writer, _lastName);
}
public override void OnResponse(BinaryReader reader)
{
var dataCode = reader.ReadUInt32(); //0xf6b673a4
var expires = reader.ReadInt32();
user = TL.Parse<User>(reader);
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed => true;
public override bool Responded { get; }
}
}

View file

@ -1,44 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
class CreateChatRequest : MTProtoRequest
{
private List<InputUserContactConstructor> _id;
private string _title;
public Messages_statedMessageConstructor message;
public CreateChatRequest(List<InputUserContactConstructor> id, string title)
{
_id = id;
_title = title;
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0x419d9aee);
writer.Write(0x1cb5c415); // vector#1cb5c415
writer.Write(_id.Count); // vector length
foreach (var id in _id)
id.Write(writer);
Serializers.String.write(writer, _title);
}
public override void OnResponse(BinaryReader reader)
{
message = TL.Parse<Messages_statedMessageConstructor>(reader);
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed { get { return true; } }
private readonly bool responded;
public override bool Responded { get { return responded; } }
}
}

View file

@ -1,44 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
class DeleteChatUserRequest : MTProtoRequest
{
private int _chatID;
private InputUserContactConstructor _user;
private string _title;
public Messages_statedMessageConstructor message;
public DeleteChatUserRequest(int chatID, InputUserContactConstructor user)
{
_chatID = chatID;
_user = user;
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0xc3c5cd23);
writer.Write(_chatID);
_user.Write(writer);
}
public override void OnResponse(BinaryReader reader)
{
message = TL.Parse<Messages_statedMessageConstructor>(reader);
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed { get { return true; } }
private readonly bool responded;
public override bool Responded { get { return responded; } }
}
}

View file

@ -1,85 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TLSharp.Core.MTProto;
using System.Security.Cryptography;
namespace TLSharp.Core.Requests
{
public class GetContactsRequest : MTProtoRequest
{
private List<int> CurrentContacts { get; set; }
public List<Contact> Contacts;
public List<User> Users;
public GetContactsRequest(IList<int> currentContacts = null)
{
if (currentContacts != null)
{
CurrentContacts = currentContacts.ToList();
CurrentContacts.Sort();
}
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0x22c6aa08);
if (CurrentContacts == null)
Serializers.String.write(writer, "");
else
{
// create CSV of contactids and calculate md5 hash
string hash;
var list = string.Join(",", CurrentContacts);
using (var md5 = MD5.Create())
{
var retVal = md5.ComputeHash(Encoding.UTF8.GetBytes(list));
var sb = new StringBuilder();
foreach (var t in retVal)
{
sb.Append(t.ToString("x2"));
}
hash = sb.ToString();
}
Serializers.String.write(writer, hash);
}
}
public override void OnResponse(BinaryReader reader)
{
var code = reader.ReadUInt32();
// if contactsNotModified then exit
if (code == 0xb74ba9d2) return;
reader.ReadInt32(); // vector code
var contactLen = reader.ReadInt32();
Contacts = new List<Contact>(contactLen);
for (var importedIndex = 0; importedIndex < contactLen; importedIndex++)
{
var importedElement = TL.Parse<Contact>(reader);
this.Contacts.Add(importedElement);
}
reader.ReadInt32(); // vector code
var usersLen = reader.ReadInt32();
Users = new List<User>(usersLen);
for (var usersIndex = 0; usersIndex < usersLen; usersIndex++)
{
var usersElement = TL.Parse<User>(reader);
this.Users.Add(usersElement);
}
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed { get { return true; } }
private readonly bool _responded;
public override bool Responded { get { return _responded; } }
}
}

View file

@ -1,91 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
public class GetDialogsRequest : MTProtoRequest
{
int _offset;
int _max_id;
int _limit;
public int count;
public List<Dialog> dialogs;
public List<Message> messages;
public List<Chat> chats;
public List<User> users;
public GetDialogsRequest(int offset, int max_id, int limit)
{
_offset = offset;
_max_id = max_id;
_limit = limit;
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0xeccf1df6);
writer.Write(_offset);
writer.Write(_max_id);
writer.Write(_limit);
}
public override void OnResponse(BinaryReader reader)
{
bool dialogsSlice = reader.ReadUInt32() == 0x71e094f3; // else dialogs#15ba6c40
if (dialogsSlice) count = reader.ReadInt32(); // count
// dialogs
var result = reader.ReadUInt32(); // vector#1cb5c415
int dialogs_len = reader.ReadInt32();
dialogs = new List<Dialog>(dialogs_len);
for (int dialogs_index = 0; dialogs_index < dialogs_len; dialogs_index++)
{
Dialog dialog_element;
dialog_element = TL.Parse<Dialog>(reader);
dialogs.Add(dialog_element);
}
// messages
result = reader.ReadUInt32(); // vector#1cb5c415
int messages_len = reader.ReadInt32();
messages = new List<Message>(messages_len);
for (int message_index = 0; message_index < messages_len; message_index++)
{
Message messages_element;
messages_element = TL.Parse<Message>(reader);
messages.Add(messages_element);
}
// chats
result = reader.ReadUInt32(); // vector#1cb5c415
int chats_len = reader.ReadInt32();
chats = new List<Chat>(chats_len);
for (int chat_index = 0; chat_index < chats_len; chat_index++)
{
Chat chats_element;
chats_element = TL.Parse<Chat>(reader);
chats.Add(chats_element);
}
// users
result = reader.ReadUInt32(); // vector#1cb5c415
int users_len = reader.ReadInt32();
users = new List<User>(users_len);
for (int users_index = 0; users_index < users_len; users_index++)
{
User users_element;
users_element = TL.Parse<User>(reader);
users.Add(users_element);
}
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed => true;
public override bool Responded { get; }
}
}

View file

@ -1,49 +0,0 @@
using System;
using System.IO;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
class GetFileRequest : MTProtoRequest
{
InputFileLocation _location;
int _offset;
int _limit;
public storage_FileType type;
public int mtime;
public byte[] bytes;
public GetFileRequest(InputFileLocation location, int offset, int limit)
{
_location = location;
_offset = offset;
_limit = limit;
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0xe3a6cfb5);
_location.Write(writer);
writer.Write(_offset);
writer.Write(_limit);
}
public override void OnResponse(BinaryReader reader)
{
var code = reader.ReadUInt32(); // upload.file#96a18d5
type = TL.Parse<storage_FileType>(reader);
mtime = reader.ReadInt32();
bytes = reader.ReadBytes(_limit);
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed => true;
public override bool Responded { get; }
}
}

View file

@ -1,78 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
class GetHistoryRequest : MTProtoRequest
{
InputPeer _peer;
int _offset;
int _max_id;
int _limit;
public List<Message> messages;
public List<Chat> chats;
public List<User> users;
public GetHistoryRequest(InputPeer peer, int offset, int max_id, int limit)
{
_peer = peer;
_offset = offset;
_max_id = max_id;
_limit = limit;
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0x92a1df2f);
_peer.Write(writer);
writer.Write(_offset);
writer.Write(_max_id);
writer.Write(_limit);
}
public override void OnResponse(BinaryReader reader)
{
bool messagesSlice = reader.ReadUInt32() == 0xb446ae3; // else messages#8c718e87
if (messagesSlice) reader.ReadInt32(); // count
// messages
var result = reader.ReadUInt32(); // vector#1cb5c415
int messages_len = reader.ReadInt32();
messages = new List<Message>(messages_len);
for (var i = 0; i < messages_len; i++)
{
var msgEl = TL.Parse<Message>(reader);
messages.Add(msgEl);
}
// chats
reader.ReadUInt32();
int chats_len = reader.ReadInt32();
chats = new List<Chat>(chats_len);
for (int i = 0; i < chats_len; i++)
chats.Add(TL.Parse<Chat>(reader));
/*
// users
reader.ReadUInt32();
int users_len = reader.ReadInt32();
users = new List<User>(users_len);
for (int i = 0; i < users_len; i++)
users.Add(TL.Parse<User>(reader));
*/
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed => true;
public override bool Responded { get; }
}
}

View file

@ -1,45 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
public class GetNearestDcRequest : MTProtoRequest
{
public string country;
public int this_dc;
public int nearest_dc;
public GetNearestDcRequest() { }
public override void OnSend(BinaryWriter writer)
{
writer.Write(0x1fb33026);
}
public override void OnResponse(BinaryReader reader)
{
var code = reader.ReadUInt32();
country = Serializers.String.read(reader);
this_dc = reader.ReadInt32();
nearest_dc = reader.ReadInt32();
System.Diagnostics.Debug.WriteLine("country: " + country);
System.Diagnostics.Debug.WriteLine("this_dc: " + this_dc);
System.Diagnostics.Debug.WriteLine("nearest: " + nearest_dc);
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed => true;
public override bool Responded { get; }
}
}

View file

@ -1,43 +0,0 @@
using System;
using System.IO;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
public class GetUpdatesDifferenceRequest : MTProtoRequest
{
public readonly int pts;
public readonly int date;
public readonly int qts;
public GetUpdatesDifferenceRequest(int pts, int date, int qts)
{
this.pts = pts;
this.date = date;
this.qts = qts;
}
public updates_Difference updatesDifference { get; private set; }
public override void OnSend(BinaryWriter writer)
{
writer.Write(0xa041495);
writer.Write(pts);
writer.Write(date);
writer.Write(qts);
}
public override void OnResponse(BinaryReader reader)
{
updatesDifference = TL.Parse<updates_Difference>(reader);
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed => true;
public override bool Responded { get; }
}
}

View file

@ -1,29 +0,0 @@
using System;
using System.IO;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
public class GetUpdatesStateRequest : MTProtoRequest
{
public updates_State updates { get; private set; }
public override void OnSend(BinaryWriter writer)
{
writer.Write(0xedd4882a);
}
public override void OnResponse(BinaryReader reader)
{
updates = TL.Parse<updates_State>(reader);
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed => true;
public override bool Responded { get; }
}
}

View file

@ -1,42 +0,0 @@
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;
}
}

View file

@ -1,48 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
class GetUsersRequest : MTProtoRequest
{
List<InputUser> _id;
public List<User> users;
public GetUsersRequest(List<InputUser> id)
{
_id = id;
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0xd91a548);
writer.Write(0x1cb5c415); // vector#1cb5c415
writer.Write(_id.Count); // vector length
foreach (var id in _id)
id.Write(writer);
}
public override void OnResponse(BinaryReader reader)
{
var code = reader.ReadUInt32(); // vector#1cb5c415
int users_len = reader.ReadInt32(); // vector length
if (users_len != 0)
{
users = new List<User>(users_len);
for (int i = 0; i < users_len; i++)
users.Add(TL.Parse<User>(reader));
}
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed => true;
public override bool Responded { get; }
}
}

View file

@ -1,36 +0,0 @@
using System;
using System.IO;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
public class ImportByUserName : MTProtoRequest
{
private readonly string _userName;
public int id { get; private set; }
public ImportByUserName(string userName)
{
_userName = userName;
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0xBF0131C);
Serializers.String.write(writer, _userName);
}
public override void OnResponse(BinaryReader reader)
{
var code = reader.ReadUInt32();
id = reader.ReadInt32();
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed => true;
public override bool Responded { get; }
}
}

View file

@ -1,62 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
public class ImportContactRequest : MTProtoRequest
{
private InputContact Contact { get; set; }
private bool Replace { get; set; }
public List<ImportedContact> imported;
public List<User> users;
public ImportContactRequest(InputContact contact, bool shouldReplace = true)
{
Contact = contact;
Replace = shouldReplace;
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0xda30b32d);
writer.Write(0x1cb5c415);
writer.Write(1);
Contact.Write(writer);
writer.Write(Replace ? 0x997275b5 : 0xbc799737);
}
public override void OnResponse(BinaryReader reader)
{
var code = reader.ReadUInt32();
var result = reader.ReadInt32(); // vector code
int imported_len = reader.ReadInt32();
this.imported = new List<ImportedContact>(imported_len);
for (int imported_index = 0; imported_index < imported_len; imported_index++)
{
ImportedContact imported_element;
imported_element = TL.Parse<ImportedContact>(reader);
this.imported.Add(imported_element);
}
reader.ReadInt32(); // vector code
int users_len = reader.ReadInt32();
this.users = new List<User>(users_len);
for (int users_index = 0; users_index < users_len; users_index++)
{
User users_element;
users_element = TL.Parse<User>(reader);
this.users.Add(users_element);
}
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed => true;
public override bool Responded { get; }
}
}

View file

@ -1,40 +1,42 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using TeleSharp.TL;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
public class InitConnectionRequest : MTProtoRequest
{
private int _apiId;
public ConfigConstructor ConfigConstructor { get; set; }
public InvokeWithLayerArgs invokeWithLayer { get; set; }
public InitConnectionArgs initConn { get; set; }
public GetConfigArgs getConfig { get; set; }
public TeleSharp.TL.Config Configs { get; set; }
public InitConnectionRequest(int apiId)
{
_apiId = apiId;
invokeWithLayer = new InvokeWithLayerArgs();
initConn = new InitConnectionArgs();
invokeWithLayer.layer = 53;
initConn.api_id = apiId;
initConn.app_version = "1.0-SNAPSHOT";
initConn.lang_code = "en";
initConn.system_version = "WinPhone 8.0";
initConn.device_model = "WinPhone Emulator";
initConn.query = new GetConfigArgs();
invokeWithLayer.query = initConn;
}
public override void OnSend(BinaryWriter writer)
{
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
Serializers.String.write(writer, "WinPhone 8.0"); // system version
Serializers.String.write(writer, "1.0-SNAPSHOT"); // app version
Serializers.String.write(writer, "en"); // lang code
writer.Write(0xc4f9186b); // help.getConfig
Serializer.Serialize(invokeWithLayer, invokeWithLayer.GetType(), writer);
}
public override void OnResponse(BinaryReader reader)
{
uint code = reader.ReadUInt32();
ConfigConstructor config = new ConfigConstructor();
config.Read(reader);
ConfigConstructor = config;
Configs = (TeleSharp.TL.Config)Deserializer.Deserialize(typeof(TeleSharp.TL.Config), reader);
}
public override void OnException(Exception exception)

View file

@ -1,48 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TLSharp.Core.MTProto;
using TLSharp.Core.Utils;
namespace TLSharp.Core.Requests
{
//messages.sendMedia#a3c85d76 peer:InputPeer media:InputMedia random_id:long = messages.StatedMessage;
public class Message_SendMediaRequest : MTProtoRequest
{
InputPeer inputPeer;
InputMedia inputMedia;
public messages_StatedMessage StatedMessage { get; set; }
public Message_SendMediaRequest(InputPeer inputPeer, InputMedia inputMedia)
{
this.inputPeer = inputPeer;
this.inputMedia = inputMedia;
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0xa3c85d76);
inputPeer.Write(writer);
inputMedia.Write(writer);
long random_id = Helpers.GenerateRandomLong();
writer.Write(random_id);
}
public override void OnResponse(BinaryReader reader)
{
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed => true;
public override bool Responded { get; }
}
}

View file

@ -1,46 +0,0 @@
using System;
using System.IO;
using TLSharp.Core.MTProto;
using TLSharp.Core.Utils;
namespace TLSharp.Core.Requests
{
public class SendMessageRequest : MTProtoRequest
{
private InputPeer _peer;
private string _message;
public SendMessageRequest(InputPeer peer, string message)
{
_peer = peer;
_message = message;
}
public override void OnSend(BinaryWriter writer)
{
long random_id = Helpers.GenerateRandomLong();
writer.Write(0x4cde0aab);
_peer.Write(writer);
Serializers.String.write(writer, _message);
writer.Write(random_id);
}
public override void OnResponse(BinaryReader reader)
{
var code = reader.ReadUInt32();
var id = reader.ReadInt32();
var date = reader.ReadInt32();
var pts = reader.ReadInt32();
var seq = reader.ReadInt32();
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed => true;
public override bool Responded { get; }
}
}

View file

@ -1,53 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
//upload.saveFilePart#b304a621 file_id:long file_part:int bytes:bytes = Bool;
public class Upload_SaveFilePartRequest : MTProtoRequest
{
long file_id;
int file_part;
byte[] bytes;
public bool Done { get; set; }
public Upload_SaveFilePartRequest(long file_id, int file_part, byte[] bytes)
{
this.file_id = file_id;
this.file_part = file_part;
this.bytes = bytes;
}
public override void OnResponse(BinaryReader reader)
{
var code = reader.ReadUInt32();
if (code != 0xbc799737 && code != 0x997275b5)
throw new InvalidOperationException($"Expected Tl Bool type");
Done = code == 0x997275b5 ? true : false;
}
public override void OnSend(BinaryWriter writer)
{
writer.Write(0xb304a621);
writer.Write(file_id);
writer.Write(file_part);
Serializers.Bytes.write(writer, bytes);
}
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
public override bool Confirmed => true;
public override bool Responded { get; }
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.IO;
using TeleSharp.TL;
using TLSharp.Core.MTProto;
using TLSharp.Core.MTProto.Crypto;
@ -25,7 +26,7 @@ namespace TLSharp.Core
public Session Load(string sessionUserId)
{
var sessionFileName = $"{sessionUserId}.dat";
if (!File.Exists(sessionFileName))
if (!System.IO.File.Exists(sessionFileName))
return null;
using (var stream = new FileStream(sessionFileName, FileMode.Open))
@ -66,7 +67,7 @@ namespace TLSharp.Core
public int TimeOffset { get; set; }
public long LastMessageId { get; set; }
public int SessionExpires { get; set; }
public User User { get; set; }
public TeleSharp.TL.User User { get; set; }
private Random random;
private ISessionStore _store;
@ -94,7 +95,7 @@ namespace TLSharp.Core
{
writer.Write(1);
writer.Write(SessionExpires);
User.Write(writer);
Serializer.Serialize(User, typeof(TeleSharp.TL.User), writer);
}
else
{
@ -126,7 +127,7 @@ namespace TLSharp.Core
if (isAuthExsist)
{
sessionExpires = reader.ReadInt32();
user = TL.Parse<User>(reader);
user = (User)Deserializer.Deserialize(typeof(User), reader);
}
var authData = Serializers.Bytes.read(reader);

View file

@ -30,6 +30,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BigMath, Version=0.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\BigMath.0.5.0\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\BigMath.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Ionic.ZLib, Version=2.0.0.14, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MarkerMetro.Unity.Ionic.Zlib.2.0.0.14\lib\net35\Ionic.ZLib.dll</HintPath>
<Private>True</Private>
@ -42,6 +46,10 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="TeleSharp.TL, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\TeleSharp.TL.1.0.0-CI00000\lib\net452\TeleSharp.TL.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Auth\Authenticator.cs" />
@ -57,43 +65,23 @@
<Compile Include="MTProto\Crypto\RSA.cs" />
<Compile Include="MTProto\Crypto\Salt.cs" />
<Compile Include="MTProto\Serializers.cs" />
<Compile Include="MTProto\TL.cs" />
<Compile Include="Network\MtProtoPlainSender.cs" />
<Compile Include="Network\MtProtoSender.cs" />
<Compile Include="Network\TcpMessage.cs" />
<Compile Include="Network\TcpTransport.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Requests\AckRequest.cs" />
<Compile Include="Requests\AuthCheckPhoneRequest.cs" />
<Compile Include="Requests\AuthSendCodeRequest.cs" />
<Compile Include="Requests\AuthSendSmsRequest.cs" />
<Compile Include="Requests\DownloadFileRequest.cs" />
<Compile Include="Requests\AuthSignInRequest.cs" />
<Compile Include="Requests\AuthSignUpRequest.cs" />
<Compile Include="Requests\GetUpdatesDifferenceRequest.cs" />
<Compile Include="Requests\GetContactsRequest.cs" />
<Compile Include="Requests\GetDialogsRequest.cs" />
<Compile Include="Requests\GetFileRequest.cs" />
<Compile Include="Requests\GetHistoryRequest.cs" />
<Compile Include="Requests\GetNearestDcRequest.cs" />
<Compile Include="Requests\GetUpdatesStateRequest.cs" />
<Compile Include="Requests\GetUserFullRequest.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" />
<Compile Include="Requests\SendMessageRequest.cs" />
<Compile Include="Requests\Message_SendMediaRequest.cs" />
<Compile Include="Requests\Upload_SaveFilePartRequest.cs" />
<Compile Include="Session.cs" />
<Compile Include="TelegramClient.cs" />
<Compile Include="Utils\Helpers.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<Compile Include="Requests\CreateChatRequest.cs" />
<Compile Include="Requests\AddChatUserRequest.cs" />
<Compile Include="Requests\DeleteChatUserRequest.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using TeleSharp.TL;
using TLSharp.Core.Auth;
using TLSharp.Core.MTProto;
using TLSharp.Core.MTProto.Crypto;
@ -21,7 +22,7 @@ namespace TLSharp.Core
private string _apiHash = "";
private int _apiId = 0;
private Session _session;
private List<DcOption> dcOptions;
private List<TeleSharp.TL.DcOption> dcOptions;
public enum sms_type { numeric_code_via_sms = 0, numeric_code_via_telegram = 5 }
@ -57,7 +58,7 @@ namespace TLSharp.Core
await _sender.Send(request);
await _sender.Receive(request);
dcOptions = request.ConfigConstructor.dc_options;
dcOptions = (request.Configs).dc_options;
}
return true;
@ -68,11 +69,11 @@ namespace TLSharp.Core
if (dcOptions == null || !dcOptions.Any())
throw new InvalidOperationException($"Can't reconnect. Establish initial connection first.");
var dc = dcOptions.Cast<DcOptionConstructor>().First(d => d.id == dcId);
var dc = dcOptions.Cast<DcOption>().First(d => d.id == dcId);
_transport = new TcpTransport(dc.ip_address, dc.port);
_transport = new TcpTransport(dc.ip_address, dc.port.Value);
_session.ServerAddress = dc.ip_address;
_session.Port = dc.port;
_session.Port = dc.port.Value;
await Connect(true);
}
@ -82,17 +83,6 @@ namespace TLSharp.Core
return _session.User != null;
}
public async Task<bool> IsPhoneRegistered(string phoneNumber)
{
if (_sender == null)
throw new InvalidOperationException("Not connected!");
var authCheckPhoneRequest = new AuthCheckPhoneRequest(phoneNumber);
await _sender.Send(authCheckPhoneRequest);
await _sender.Receive(authCheckPhoneRequest);
return authCheckPhoneRequest._phoneRegistered;
}
public async Task<string> SendCodeRequest(string phoneNumber, sms_type tokenDestination = sms_type.numeric_code_via_telegram)
{
@ -126,7 +116,7 @@ namespace TLSharp.Core
return request._phoneCodeHash;
}
public async Task<User> MakeAuth(string phoneNumber, string phoneCodeHash, string code)
public async Task<TeleSharp.TL.User> MakeAuth(string phoneNumber, string phoneCodeHash, string code)
{
var request = new AuthSignInRequest(phoneNumber, phoneCodeHash, code);
await _sender.Send(request);
@ -137,18 +127,18 @@ namespace TLSharp.Core
return request.user;
}
public async Task<User> SignUp(string phoneNumber, string phoneCodeHash, string code, string firstName, string lastName)
{
var request = new AuthSignUpRequest(phoneNumber, phoneCodeHash, code, firstName, lastName);
await _sender.Send(request);
await _sender.Receive(request);
//public async Task<User> SignUp(string phoneNumber, string phoneCodeHash, string code, string firstName, string lastName)
//{
// var request = new AuthSignUpRequest(phoneNumber, phoneCodeHash, code, firstName, lastName);
// await _sender.Send(request);
// await _sender.Receive(request);
OnUserAuthenticated(request.user, request.SessionExpires);
// OnUserAuthenticated(request.user, request.SessionExpires);
return request.user;
}
// return request.user;
//}
private void OnUserAuthenticated(User user, int sessionExpiration)
private void OnUserAuthenticated(TeleSharp.TL.User user, int sessionExpiration)
{
_session.User = user;
_session.SessionExpires = sessionExpiration;
@ -156,228 +146,228 @@ namespace TLSharp.Core
_session.Save();
}
public async Task<InputFile> UploadFile(string name, byte[] data)
{
var partSize = 65536;
//public async Task<InputFile> UploadFile(string name, byte[] data)
//{
// var partSize = 65536;
var file_id = DateTime.Now.Ticks;
// var file_id = DateTime.Now.Ticks;
var partedData = new Dictionary<int, byte[]>();
var parts = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(data.Length) / Convert.ToDouble(partSize)));
var remainBytes = data.Length;
for (int i = 0; i < parts; i++)
{
partedData.Add(i, data
.Skip(i * partSize)
.Take(remainBytes < partSize ? remainBytes : partSize)
.ToArray());
// var partedData = new Dictionary<int, byte[]>();
// var parts = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(data.Length) / Convert.ToDouble(partSize)));
// var remainBytes = data.Length;
// for (int i = 0; i < parts; i++)
// {
// partedData.Add(i, data
// .Skip(i * partSize)
// .Take(remainBytes < partSize ? remainBytes : partSize)
// .ToArray());
remainBytes -= partSize;
}
// remainBytes -= partSize;
// }
for (int i = 0; i < parts; i++)
{
var saveFilePartRequest = new Upload_SaveFilePartRequest(file_id, i, partedData[i]);
await _sender.Send(saveFilePartRequest);
await _sender.Receive(saveFilePartRequest);
// for (int i = 0; i < parts; i++)
// {
// var saveFilePartRequest = new Upload_SaveFilePartRequest(file_id, i, partedData[i]);
// await _sender.Send(saveFilePartRequest);
// await _sender.Receive(saveFilePartRequest);
if (saveFilePartRequest.Done == false)
throw new InvalidOperationException($"File part {i} does not uploaded");
}
// if (saveFilePartRequest.Done == false)
// throw new InvalidOperationException($"File part {i} does not uploaded");
// }
string md5_checksum;
using (var md5 = MD5.Create())
{
var hash = md5.ComputeHash(data);
var hashResult = new StringBuilder(hash.Length * 2);
// string md5_checksum;
// using (var md5 = MD5.Create())
// {
// var hash = md5.ComputeHash(data);
// var hashResult = new StringBuilder(hash.Length * 2);
for (int i = 0; i < hash.Length; i++)
hashResult.Append(hash[i].ToString("x2"));
// for (int i = 0; i < hash.Length; i++)
// hashResult.Append(hash[i].ToString("x2"));
md5_checksum = hashResult.ToString();
}
// md5_checksum = hashResult.ToString();
// }
var inputFile = new InputFileConstructor(file_id, parts, name, md5_checksum);
// var inputFile = new InputFileConstructor(file_id, parts, name, md5_checksum);
return inputFile;
}
// return inputFile;
//}
public async Task<bool> SendMediaMessage(int contactId, InputFile file)
{
var request = new Message_SendMediaRequest(
new InputPeerContactConstructor(contactId),
new InputMediaUploadedPhotoConstructor(file));
//public async Task<bool> SendMediaMessage(int contactId, InputFile file)
//{
// var request = new Message_SendMediaRequest(
// new InputPeerContactConstructor(contactId),
// new InputMediaUploadedPhotoConstructor(file));
await _sender.Send(request);
await _sender.Receive(request);
// await _sender.Send(request);
// await _sender.Receive(request);
return true;
}
// return true;
//}
public async Task<int?> ImportContactByPhoneNumber(string phoneNumber)
{
if (!validateNumber(phoneNumber))
throw new InvalidOperationException("Invalid phone number. It should be only digit string, from 5 to 20 digits.");
//public async Task<int?> ImportContactByPhoneNumber(string phoneNumber)
//{
// if (!validateNumber(phoneNumber))
// throw new InvalidOperationException("Invalid phone number. It should be only digit string, from 5 to 20 digits.");
var request = new ImportContactRequest(new InputPhoneContactConstructor(0, phoneNumber, "My Test Name", String.Empty));
await _sender.Send(request);
await _sender.Receive(request);
// var request = new ImportContactRequest(new InputPhoneContactConstructor(0, phoneNumber, "My Test Name", String.Empty));
// await _sender.Send(request);
// await _sender.Receive(request);
var importedUser = (ImportedContactConstructor)request.imported.FirstOrDefault();
// var importedUser = (ImportedContactConstructor)request.imported.FirstOrDefault();
return importedUser?.user_id;
}
// return importedUser?.user_id;
//}
public async Task<int?> ImportByUserName(string username)
{
if (string.IsNullOrEmpty(username))
throw new InvalidOperationException("Username can't be null");
//public async Task<int?> ImportByUserName(string username)
//{
// if (string.IsNullOrEmpty(username))
// throw new InvalidOperationException("Username can't be null");
var request = new ImportByUserName(username);
await _sender.Send(request);
await _sender.Receive(request);
// var request = new ImportByUserName(username);
// await _sender.Send(request);
// await _sender.Receive(request);
return request.id;
}
// return request.id;
//}
public async Task SendMessage(int id, string message)
{
var request = new SendMessageRequest(new InputPeerContactConstructor(id), message);
//public async Task SendMessage(int id, string message)
//{
// var request = new SendMessageRequest(new InputPeerContactConstructor(id), message);
await _sender.Send(request);
await _sender.Receive(request);
}
// await _sender.Send(request);
// await _sender.Receive(request);
//}
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);
await _sender.Receive(request);
//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);
// await _sender.Receive(request);
return request.messages;
}
// return request.messages;
//}
public async Task<Tuple<storage_FileType, byte[]>> GetFile(long volume_id, int local_id, long secret, int offset, int limit)
{
var request = new GetFileRequest(new InputFileLocationConstructor(volume_id, local_id, secret), offset, limit);
await _sender.Send(request);
await _sender.Receive(request);
//public async Task<Tuple<storage_FileType, byte[]>> GetFile(long volume_id, int local_id, long secret, int offset, int limit)
//{
// var request = new GetFileRequest(new InputFileLocationConstructor(volume_id, local_id, secret), offset, limit);
// await _sender.Send(request);
// await _sender.Receive(request);
return Tuple.Create(request.type, request.bytes);
}
// return Tuple.Create(request.type, request.bytes);
//}
public async Task<MessageDialogs> GetDialogs(int offset, int limit, int max_id = 0)
{
var request = new GetDialogsRequest(offset, max_id, limit);
await _sender.Send(request);
await _sender.Receive(request);
//public async Task<MessageDialogs> GetDialogs(int offset, int limit, int max_id = 0)
//{
// var request = new GetDialogsRequest(offset, max_id, limit);
// await _sender.Send(request);
// await _sender.Receive(request);
return new MessageDialogs
{
Dialogs = request.dialogs,
Messages = request.messages,
Chats = request.chats,
Users = request.users,
};
}
// return new MessageDialogs
// {
// Dialogs = request.dialogs,
// Messages = request.messages,
// Chats = request.chats,
// Users = request.users,
// };
//}
public async Task<UserFull> GetUserFull(int user_id)
{
var request = new GetUserFullRequest(user_id);
await _sender.Send(request);
await _sender.Receive(request);
//public async Task<UserFull> GetUserFull(int user_id)
//{
// var request = new GetUserFullRequest(user_id);
// await _sender.Send(request);
// await _sender.Receive(request);
return request._userFull;
}
// return request._userFull;
//}
private bool validateNumber(string number)
{
var regex = new Regex("^\\d{7,20}$");
//private bool validateNumber(string number)
//{
// var regex = new Regex("^\\d{7,20}$");
return regex.IsMatch(number);
}
// return regex.IsMatch(number);
//}
public async Task<ContactsContacts> GetContacts(IList<int> contactIds = null)
{
var request = new GetContactsRequest(contactIds);
await _sender.Send(request);
await _sender.Receive(request);
//public async Task<ContactsContacts> GetContacts(IList<int> contactIds = null)
//{
// var request = new GetContactsRequest(contactIds);
// await _sender.Send(request);
// await _sender.Receive(request);
return new ContactsContacts
{
Contacts = request.Contacts,
Users = request.Users,
};
}
// return new ContactsContacts
// {
// Contacts = request.Contacts,
// Users = request.Users,
// };
//}
public async Task<Messages_statedMessageConstructor> CreateChat(string title, List<string> userPhonesToInvite)
{
var userIdsToInvite = new List<int>();
foreach (var userPhone in userPhonesToInvite)
{
var uid = await ImportContactByPhoneNumber(userPhone);
if (!uid.HasValue)
throw new InvalidOperationException($"Failed to retrieve contact {userPhone}");
//public async Task<Messages_statedMessageConstructor> CreateChat(string title, List<string> userPhonesToInvite)
//{
// var userIdsToInvite = new List<int>();
// foreach (var userPhone in userPhonesToInvite)
// {
// var uid = await ImportContactByPhoneNumber(userPhone);
// if (!uid.HasValue)
// throw new InvalidOperationException($"Failed to retrieve contact {userPhone}");
userIdsToInvite.Add(uid.Value);
}
// userIdsToInvite.Add(uid.Value);
// }
return await CreateChat(title, userIdsToInvite);
}
// return await CreateChat(title, userIdsToInvite);
//}
public async Task<Messages_statedMessageConstructor> CreateChat(string title, List<int> userIdsToInvite)
{
var request = new CreateChatRequest(userIdsToInvite.Select(uid => new InputUserContactConstructor(uid)).ToList(), title);
//public async Task<Messages_statedMessageConstructor> CreateChat(string title, List<int> userIdsToInvite)
//{
// var request = new CreateChatRequest(userIdsToInvite.Select(uid => new InputUserContactConstructor(uid)).ToList(), title);
await _sender.Send(request);
await _sender.Receive(request);
// await _sender.Send(request);
// await _sender.Receive(request);
return request.message;
}
// return request.message;
//}
public async Task<Messages_statedMessageConstructor> AddChatUser(int chatId, int userId)
{
var request = new AddChatUserRequest(chatId, new InputUserContactConstructor(userId));
//public async Task<Messages_statedMessageConstructor> AddChatUser(int chatId, int userId)
//{
// var request = new AddChatUserRequest(chatId, new InputUserContactConstructor(userId));
await _sender.Send(request);
await _sender.Receive(request);
// await _sender.Send(request);
// await _sender.Receive(request);
return request.message;
}
// return request.message;
//}
public async Task<Messages_statedMessageConstructor> DeleteChatUser(int chatId, int userId)
{
var request = new DeleteChatUserRequest(chatId, new InputUserContactConstructor(userId));
//public async Task<Messages_statedMessageConstructor> DeleteChatUser(int chatId, int userId)
//{
// var request = new DeleteChatUserRequest(chatId, new InputUserContactConstructor(userId));
await _sender.Send(request);
await _sender.Receive(request);
// await _sender.Send(request);
// await _sender.Receive(request);
return request.message;
}
// return request.message;
//}
public async Task<Messages_statedMessageConstructor> LeaveChat(int chatId)
{
return await DeleteChatUser(chatId, ((UserSelfConstructor) _session.User).id);
}
//public async Task<Messages_statedMessageConstructor> LeaveChat(int chatId)
//{
// return await DeleteChatUser(chatId, ((UserSelfConstructor) _session.User).id);
//}
public async Task<updates_State> GetUpdatesState()
{
var request = new GetUpdatesStateRequest();
//public async Task<updates_State> GetUpdatesState()
//{
// var request = new GetUpdatesStateRequest();
await _sender.Send(request);
await _sender.Receive(request);
// await _sender.Send(request);
// await _sender.Receive(request);
return request.updates;
}
// return request.updates;
//}
public async Task<updates_Difference> GetUpdatesDifference(int lastPts, int lastDate, int lastQts)
{
var request = new GetUpdatesDifferenceRequest(lastPts, lastDate, lastQts);
//public async Task<updates_Difference> GetUpdatesDifference(int lastPts, int lastDate, int lastQts)
//{
// var request = new GetUpdatesDifferenceRequest(lastPts, lastDate, lastQts);
await _sender.Send(request);
await _sender.Receive(request);
// await _sender.Send(request);
// await _sender.Receive(request);
return request.updatesDifference;
}
// return request.updatesDifference;
//}
}
}

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BigMath" version="0.5.0" targetFramework="net452" />
<package id="DotNetZip" version="1.9.3" targetFramework="net451" />
<package id="MarkerMetro.Unity.Ionic.Zlib" version="2.0.0.14" targetFramework="net452" />
<package id="TeleSharp.TL" version="1.0.0-CI00000" targetFramework="net452" />
</packages>