diff --git a/TLSharp.Core/Requests/AddChatUserRequest b/TLSharp.Core/Requests/AddChatUserRequest new file mode 100644 index 0000000..74b9b84 --- /dev/null +++ b/TLSharp.Core/Requests/AddChatUserRequest @@ -0,0 +1,45 @@ +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(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; } } + } +} diff --git a/TLSharp.Core/Requests/CreateChatRequest b/TLSharp.Core/Requests/CreateChatRequest new file mode 100644 index 0000000..6151b2c --- /dev/null +++ b/TLSharp.Core/Requests/CreateChatRequest @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.IO; +using TLSharp.Core.MTProto; + +namespace TLSharp.Core.Requests +{ + class CreateChatRequest : MTProtoRequest + { + private List _id; + private string _title; + + public Messages_statedMessageConstructor message; + public CreateChatRequest(List 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(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; } } + } +} diff --git a/TLSharp.Core/Requests/DeleteChatUserRequest b/TLSharp.Core/Requests/DeleteChatUserRequest new file mode 100644 index 0000000..dfec7bf --- /dev/null +++ b/TLSharp.Core/Requests/DeleteChatUserRequest @@ -0,0 +1,44 @@ +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(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; } } + } +} diff --git a/TLSharp.Core/Requests/GetContactRequest b/TLSharp.Core/Requests/GetContactRequest new file mode 100644 index 0000000..ba57235 --- /dev/null +++ b/TLSharp.Core/Requests/GetContactRequest @@ -0,0 +1,72 @@ +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 GetContactRequest : MTProtoRequest + { + private List currentContacts { get; set; } + + public List contacts; + public List users; + + public GetContactRequest(List currentContactsID = null) + { + currentContacts = currentContactsID; + } + + public override void OnSend(BinaryWriter writer) + { + writer.Write(0x22c6aa08); + if (currentContacts == null) + Serializers.String.write(writer, ""); + else + { + string hash = ""; + foreach (var currentUserID in currentContacts) + { + var md5 = Utils.Helpers.md5(currentUserID.ToString()); + hash += md5 + ","; + } + hash = hash.Length > 0 ? hash.Remove(hash.LastIndexOf(','), 1) : Utils.Helpers.md5( hash); + Serializers.String.write(writer, hash); + } + } + + public override void OnResponse(BinaryReader reader) + { + var code = reader.ReadUInt32(); + var result = reader.ReadInt32(); // vector code + int contact_len = reader.ReadInt32(); + this.contacts = new List(contact_len); + for (int imported_index = 0; imported_index < contact_len; imported_index++) + { + Contact imported_element; + imported_element = TL.Parse(reader); + this.contacts.Add(imported_element); + } + reader.ReadInt32(); // vector code + int users_len = reader.ReadInt32(); + this.users = new List(users_len); + for (int users_index = 0; users_index < users_len; users_index++) + { + UserContactConstructor users_element; + users_element = TL.Parse(reader); + this.users.Add(users_element); + } + } + + 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; } } + } +} diff --git a/TLSharp.Core/Requests/ImportContactRequest b/TLSharp.Core/Requests/ImportContactRequest new file mode 100644 index 0000000..7fe658a --- /dev/null +++ b/TLSharp.Core/Requests/ImportContactRequest @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.IO; +using TLSharp.Core.MTProto; + +namespace TLSharp.Core.Requests +{ + public class ImportContactRequest : MTProtoRequest + { + private List Contact { get; set; } + private bool Replace { get; set; } + + public List imported; + public List users; + + public ImportContactRequest(List contact, bool shouldReplace = true) + { + Contact = contact; + Replace = shouldReplace; + } + + public override void OnSend(BinaryWriter writer) + { + writer.Write(0xda30b32d); + writer.Write(0x1cb5c415); + writer.Write(Contact.Count); + foreach (var item in Contact) + { + item.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(imported_len); + for (int imported_index = 0; imported_index < imported_len; imported_index++) + { + ImportedContact imported_element; + imported_element = TL.Parse(reader); + this.imported.Add(imported_element); + } + reader.ReadInt32(); // vector code + int users_len = reader.ReadInt32(); + this.users = new List(users_len); + for (int users_index = 0; users_index < users_len; users_index++) + { + User users_element; + users_element = TL.Parse(reader); + this.users.Add(users_element); + } + } + + 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; } } + } +}