mirror of
https://github.com/sochix/TLSharp.git
synced 2026-01-08 01:39:58 +01:00
commit
f56ffc7c6f
45
TLSharp.Core/Requests/AddChatUserRequest
Normal file
45
TLSharp.Core/Requests/AddChatUserRequest
Normal file
|
|
@ -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<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; } }
|
||||||
|
}
|
||||||
|
}
|
||||||
44
TLSharp.Core/Requests/CreateChatRequest
Normal file
44
TLSharp.Core/Requests/CreateChatRequest
Normal file
|
|
@ -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<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; } }
|
||||||
|
}
|
||||||
|
}
|
||||||
44
TLSharp.Core/Requests/DeleteChatUserRequest
Normal file
44
TLSharp.Core/Requests/DeleteChatUserRequest
Normal file
|
|
@ -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<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; } }
|
||||||
|
}
|
||||||
|
}
|
||||||
72
TLSharp.Core/Requests/GetContactRequest
Normal file
72
TLSharp.Core/Requests/GetContactRequest
Normal file
|
|
@ -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<int> currentContacts { get; set; }
|
||||||
|
|
||||||
|
public List<Contact> contacts;
|
||||||
|
public List<UserContactConstructor> users;
|
||||||
|
|
||||||
|
public GetContactRequest(List<int> 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>(contact_len);
|
||||||
|
for (int imported_index = 0; imported_index < contact_len; imported_index++)
|
||||||
|
{
|
||||||
|
Contact imported_element;
|
||||||
|
imported_element = TL.Parse<Contact>(reader);
|
||||||
|
this.contacts.Add(imported_element);
|
||||||
|
}
|
||||||
|
reader.ReadInt32(); // vector code
|
||||||
|
int users_len = reader.ReadInt32();
|
||||||
|
this.users = new List<UserContactConstructor>(users_len);
|
||||||
|
for (int users_index = 0; users_index < users_len; users_index++)
|
||||||
|
{
|
||||||
|
UserContactConstructor users_element;
|
||||||
|
users_element = TL.Parse<UserContactConstructor>(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; } }
|
||||||
|
}
|
||||||
|
}
|
||||||
66
TLSharp.Core/Requests/ImportContactRequest
Normal file
66
TLSharp.Core/Requests/ImportContactRequest
Normal file
|
|
@ -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<InputContact> Contact { get; set; }
|
||||||
|
private bool Replace { get; set; }
|
||||||
|
|
||||||
|
public List<ImportedContact> imported;
|
||||||
|
public List<User> users;
|
||||||
|
|
||||||
|
public ImportContactRequest(List<InputContact> 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<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 { get { return true; } }
|
||||||
|
private readonly bool responded;
|
||||||
|
public override bool Responded { get { return responded; } }
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue