fix forward mesages

This commit is contained in:
meysam navaei 2017-12-15 15:37:49 +03:30
parent 7a01fa84b4
commit a3b58d6bb0
3 changed files with 467 additions and 363 deletions

View file

@ -319,6 +319,10 @@ namespace TLSharp.Core.Network
{
throw new CloudPasswordNeededException("This Account has Cloud Password !");
}
else if (errorMessage == "MESSAGE_ID_INVALID")
{
throw new InvalidOperationException("The provided message id is invalid " + errorMessage);
}
else
{
throw new InvalidOperationException(errorMessage);
@ -548,7 +552,7 @@ namespace TLSharp.Core.Network
private const string REPORT_MESSAGE =
" See: https://github.com/sochix/TLSharp#i-get-a-xxxmigrationexception-or-a-migrate_x-error";
protected DataCenterMigrationException(string msg, int dc) : base (msg + REPORT_MESSAGE)
protected DataCenterMigrationException(string msg, int dc) : base(msg + REPORT_MESSAGE)
{
DC = dc;
}
@ -557,7 +561,7 @@ namespace TLSharp.Core.Network
internal class PhoneMigrationException : DataCenterMigrationException
{
internal PhoneMigrationException(int dc)
: base ($"Phone number registered to a different DC: {dc}.", dc)
: base($"Phone number registered to a different DC: {dc}.", dc)
{
}
}
@ -565,7 +569,7 @@ namespace TLSharp.Core.Network
internal class FileMigrationException : DataCenterMigrationException
{
internal FileMigrationException(int dc)
: base ($"File located on a different DC: {dc}.", dc)
: base($"File located on a different DC: {dc}.", dc)
{
}
}
@ -577,7 +581,7 @@ namespace TLSharp.Core.Network
{
}
}
internal class NetworkMigrationException : DataCenterMigrationException
{
internal NetworkMigrationException(int dc)

View file

@ -1,90 +1,90 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using TeleSharp.TL;
using TeleSharp.TL.Account;
using TeleSharp.TL.Auth;
using TeleSharp.TL.Contacts;
using TeleSharp.TL.Help;
using TeleSharp.TL.Messages;
using TeleSharp.TL.Upload;
using TLSharp.Core.Auth;
using TLSharp.Core.MTProto.Crypto;
using TLSharp.Core.Network;
using TLSharp.Core.Utils;
using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization;
namespace TLSharp.Core
{
public class TelegramClient : IDisposable
{
private MtProtoSender _sender;
private AuthKey _key;
private TcpTransport _transport;
private string _apiHash = "";
private int _apiId = 0;
private Session _session;
private List<TLDcOption> dcOptions;
private TcpClientConnectionHandler _handler;
public TelegramClient(int apiId, string apiHash,
ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null)
{
if (apiId == default(int))
throw new MissingApiConfigurationException("API_ID");
if (string.IsNullOrEmpty(apiHash))
throw new MissingApiConfigurationException("API_HASH");
if (store == null)
store = new FileSessionStore();
TLContext.Init();
_apiHash = apiHash;
_apiId = apiId;
_handler = handler;
_session = Session.TryLoadOrCreateNew(store, sessionUserId);
_transport = new TcpTransport(_session.ServerAddress, _session.Port, _handler);
}
public async Task<bool> ConnectAsync(bool reconnect = false)
{
if (_session.AuthKey == null || reconnect)
{
var result = await Authenticator.DoAuthentication(_transport);
_session.AuthKey = result.AuthKey;
_session.TimeOffset = result.TimeOffset;
}
_sender = new MtProtoSender(_transport, _session);
//set-up layer
var config = new TLRequestGetConfig();
var request = new TLRequestInitConnection()
{
ApiId = _apiId,
AppVersion = "1.0.0",
DeviceModel = "PC",
LangCode = "en",
Query = config,
SystemVersion = "Win 10.0"
};
var invokewithLayer = new TLRequestInvokeWithLayer() { Layer = 66, Query = request };
await _sender.Send(invokewithLayer);
await _sender.Receive(invokewithLayer);
dcOptions = ((TLConfig)invokewithLayer.Response).DcOptions.ToList();
return true;
}
private async Task ReconnectToDcAsync(int dcId)
{
if (dcOptions == null || !dcOptions.Any())
throw new InvalidOperationException($"Can't reconnect. Establish initial connection first.");
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using TeleSharp.TL;
using TeleSharp.TL.Account;
using TeleSharp.TL.Auth;
using TeleSharp.TL.Contacts;
using TeleSharp.TL.Help;
using TeleSharp.TL.Messages;
using TeleSharp.TL.Upload;
using TLSharp.Core.Auth;
using TLSharp.Core.MTProto.Crypto;
using TLSharp.Core.Network;
using TLSharp.Core.Utils;
using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization;
namespace TLSharp.Core
{
public class TelegramClient : IDisposable
{
private MtProtoSender _sender;
private AuthKey _key;
private TcpTransport _transport;
private string _apiHash = "";
private int _apiId = 0;
private Session _session;
private List<TLDcOption> dcOptions;
private TcpClientConnectionHandler _handler;
public TelegramClient(int apiId, string apiHash,
ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null)
{
if (apiId == default(int))
throw new MissingApiConfigurationException("API_ID");
if (string.IsNullOrEmpty(apiHash))
throw new MissingApiConfigurationException("API_HASH");
if (store == null)
store = new FileSessionStore();
TLContext.Init();
_apiHash = apiHash;
_apiId = apiId;
_handler = handler;
_session = Session.TryLoadOrCreateNew(store, sessionUserId);
_transport = new TcpTransport(_session.ServerAddress, _session.Port, _handler);
}
public async Task<bool> ConnectAsync(bool reconnect = false)
{
if (_session.AuthKey == null || reconnect)
{
var result = await Authenticator.DoAuthentication(_transport);
_session.AuthKey = result.AuthKey;
_session.TimeOffset = result.TimeOffset;
}
_sender = new MtProtoSender(_transport, _session);
//set-up layer
var config = new TLRequestGetConfig();
var request = new TLRequestInitConnection()
{
ApiId = _apiId,
AppVersion = "1.0.0",
DeviceModel = "PC",
LangCode = "en",
Query = config,
SystemVersion = "Win 10.0"
};
var invokewithLayer = new TLRequestInvokeWithLayer() { Layer = 66, Query = request };
await _sender.Send(invokewithLayer);
await _sender.Receive(invokewithLayer);
dcOptions = ((TLConfig)invokewithLayer.Response).DcOptions.ToList();
return true;
}
private async Task ReconnectToDcAsync(int dcId)
{
if (dcOptions == null || !dcOptions.Any())
throw new InvalidOperationException($"Can't reconnect. Establish initial connection first.");
TLExportedAuthorization exported = null;
if (_session.TLUser != null)
@ -92,13 +92,13 @@ namespace TLSharp.Core
TLRequestExportAuthorization exportAuthorization = new TLRequestExportAuthorization() { DcId = dcId };
exported = await SendRequestAsync<TLExportedAuthorization>(exportAuthorization);
}
var dc = dcOptions.First(d => d.Id == dcId);
_transport = new TcpTransport(dc.IpAddress, dc.Port, _handler);
_session.ServerAddress = dc.IpAddress;
_session.Port = dc.Port;
var dc = dcOptions.First(d => d.Id == dcId);
_transport = new TcpTransport(dc.IpAddress, dc.Port, _handler);
_session.ServerAddress = dc.IpAddress;
_session.Port = dc.Port;
await ConnectAsync(true);
if (_session.TLUser != null)
@ -106,149 +106,149 @@ namespace TLSharp.Core
TLRequestImportAuthorization importAuthorization = new TLRequestImportAuthorization() { Id = exported.Id, Bytes = exported.Bytes };
var imported = await SendRequestAsync<TLAuthorization>(importAuthorization);
OnUserAuthenticated(((TLUser)imported.User));
}
}
}
}
private async Task RequestWithDcMigration(TLMethod request)
{
var completed = false;
while (!completed)
{
try
{
await _sender.Send(request);
await _sender.Receive(request);
completed = true;
}
catch (DataCenterMigrationException e)
{
await ReconnectToDcAsync(e.DC);
// prepare the request for another try
request.ConfirmReceived = false;
}
var completed = false;
while (!completed)
{
try
{
await _sender.Send(request);
await _sender.Receive(request);
completed = true;
}
catch (DataCenterMigrationException e)
{
await ReconnectToDcAsync(e.DC);
// prepare the request for another try
request.ConfirmReceived = false;
}
}
}
public bool IsUserAuthorized()
{
return _session.TLUser != null;
}
public async Task<bool> IsPhoneRegisteredAsync(string phoneNumber)
{
if (String.IsNullOrWhiteSpace(phoneNumber))
throw new ArgumentNullException(nameof(phoneNumber));
if (_sender == null)
throw new InvalidOperationException("Not connected!");
var authCheckPhoneRequest = new TLRequestCheckPhone() { PhoneNumber = phoneNumber };
await RequestWithDcMigration(authCheckPhoneRequest);
return authCheckPhoneRequest.Response.PhoneRegistered;
}
public async Task<string> SendCodeRequestAsync(string phoneNumber)
{
if (String.IsNullOrWhiteSpace(phoneNumber))
throw new ArgumentNullException(nameof(phoneNumber));
var request = new TLRequestSendCode() { PhoneNumber = phoneNumber, ApiId = _apiId, ApiHash = _apiHash };
await RequestWithDcMigration(request);
return request.Response.PhoneCodeHash;
}
public async Task<TLUser> MakeAuthAsync(string phoneNumber, string phoneCodeHash, string code)
{
if (String.IsNullOrWhiteSpace(phoneNumber))
throw new ArgumentNullException(nameof(phoneNumber));
if (String.IsNullOrWhiteSpace(phoneCodeHash))
throw new ArgumentNullException(nameof(phoneCodeHash));
if (String.IsNullOrWhiteSpace(code))
}
public bool IsUserAuthorized()
{
return _session.TLUser != null;
}
public async Task<bool> IsPhoneRegisteredAsync(string phoneNumber)
{
if (String.IsNullOrWhiteSpace(phoneNumber))
throw new ArgumentNullException(nameof(phoneNumber));
if (_sender == null)
throw new InvalidOperationException("Not connected!");
var authCheckPhoneRequest = new TLRequestCheckPhone() { PhoneNumber = phoneNumber };
await RequestWithDcMigration(authCheckPhoneRequest);
return authCheckPhoneRequest.Response.PhoneRegistered;
}
public async Task<string> SendCodeRequestAsync(string phoneNumber)
{
if (String.IsNullOrWhiteSpace(phoneNumber))
throw new ArgumentNullException(nameof(phoneNumber));
var request = new TLRequestSendCode() { PhoneNumber = phoneNumber, ApiId = _apiId, ApiHash = _apiHash };
await RequestWithDcMigration(request);
return request.Response.PhoneCodeHash;
}
public async Task<TLUser> MakeAuthAsync(string phoneNumber, string phoneCodeHash, string code)
{
if (String.IsNullOrWhiteSpace(phoneNumber))
throw new ArgumentNullException(nameof(phoneNumber));
if (String.IsNullOrWhiteSpace(phoneCodeHash))
throw new ArgumentNullException(nameof(phoneCodeHash));
if (String.IsNullOrWhiteSpace(code))
throw new ArgumentNullException(nameof(code));
var request = new TLRequestSignIn() { PhoneNumber = phoneNumber, PhoneCodeHash = phoneCodeHash, PhoneCode = code };
await RequestWithDcMigration(request);
OnUserAuthenticated(((TLUser)request.Response.User));
return ((TLUser)request.Response.User);
await RequestWithDcMigration(request);
OnUserAuthenticated(((TLUser)request.Response.User));
return ((TLUser)request.Response.User);
}
public async Task<TLPassword> GetPasswordSetting()
{
var request = new TLRequestGetPassword();
await RequestWithDcMigration(request);
return ((TLPassword)request.Response);
}
public async Task<TLUser> MakeAuthWithPasswordAsync(TLPassword password, string password_str)
{
byte[] password_Bytes = Encoding.UTF8.GetBytes(password_str);
IEnumerable<byte> rv = password.CurrentSalt.Concat(password_Bytes).Concat(password.CurrentSalt);
SHA256Managed hashstring = new SHA256Managed();
var password_hash = hashstring.ComputeHash(rv.ToArray());
var request = new TLRequestCheckPassword() { PasswordHash = password_hash };
await RequestWithDcMigration(request);
OnUserAuthenticated(((TLUser)request.Response.User));
return ((TLUser)request.Response.User);
}
public async Task<TLUser> SignUpAsync(string phoneNumber, string phoneCodeHash, string code, string firstName, string lastName)
{
public async Task<TLPassword> GetPasswordSetting()
{
var request = new TLRequestGetPassword();
await RequestWithDcMigration(request);
return ((TLPassword)request.Response);
}
public async Task<TLUser> MakeAuthWithPasswordAsync(TLPassword password, string password_str)
{
byte[] password_Bytes = Encoding.UTF8.GetBytes(password_str);
IEnumerable<byte> rv = password.CurrentSalt.Concat(password_Bytes).Concat(password.CurrentSalt);
SHA256Managed hashstring = new SHA256Managed();
var password_hash = hashstring.ComputeHash(rv.ToArray());
var request = new TLRequestCheckPassword() { PasswordHash = password_hash };
await RequestWithDcMigration(request);
OnUserAuthenticated(((TLUser)request.Response.User));
return ((TLUser)request.Response.User);
}
public async Task<TLUser> SignUpAsync(string phoneNumber, string phoneCodeHash, string code, string firstName, string lastName)
{
var request = new TLRequestSignUp() { PhoneNumber = phoneNumber, PhoneCode = code, PhoneCodeHash = phoneCodeHash, FirstName = firstName, LastName = lastName };
await RequestWithDcMigration(request);
OnUserAuthenticated(((TLUser)request.Response.User));
return ((TLUser)request.Response.User);
}
public async Task<T> SendRequestAsync<T>(TLMethod methodToExecute)
{
await RequestWithDcMigration(methodToExecute);
var result = methodToExecute.GetType().GetProperty("Response").GetValue(methodToExecute);
return (T)result;
}
public async Task<TLContacts> GetContactsAsync()
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
var req = new TLRequestGetContacts() { Hash = "" };
return await SendRequestAsync<TLContacts>(req);
}
public async Task<TLAbsUpdates> SendMessageAsync(TLAbsInputPeer peer, string message)
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
return await SendRequestAsync<TLAbsUpdates>(
new TLRequestSendMessage()
{
Peer = peer,
Message = message,
RandomId = Helpers.GenerateRandomLong()
});
await RequestWithDcMigration(request);
OnUserAuthenticated(((TLUser)request.Response.User));
return ((TLUser)request.Response.User);
}
public async Task<T> SendRequestAsync<T>(TLMethod methodToExecute)
{
await RequestWithDcMigration(methodToExecute);
var result = methodToExecute.GetType().GetProperty("Response").GetValue(methodToExecute);
return (T)result;
}
public async Task<TLContacts> GetContactsAsync()
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
var req = new TLRequestGetContacts() { Hash = "" };
return await SendRequestAsync<TLContacts>(req);
}
public async Task<TLAbsUpdates> SendMessageAsync(TLAbsInputPeer peer, string message)
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
return await SendRequestAsync<TLAbsUpdates>(
new TLRequestSendMessage()
{
Peer = peer,
Message = message,
RandomId = Helpers.GenerateRandomLong()
});
}
public async Task<TLAbsUpdates> ForwardMessageAsync(TLAbsInputPeer peer, TLAbsInputPeer peerto, int messageId)
@ -272,86 +272,100 @@ namespace TLSharp.Core
aa.WithMyScore = true;
return await SendRequestAsync<TLUpdates>(aa);
}
public async Task<TLAbsUpdates> ForwardMessageAsync(TLAbsInputPeer peerfrom, int messageId)
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
return await SendRequestAsync<TLAbsUpdates>(
new TLRequestForwardMessage()
{
//MessageId = _session.GetNewMessageId(),
Id = messageId,
Peer = peerfrom,
RandomId = Helpers.GenerateRandomLong()
});
}
public async Task<Boolean> SendTypingAsync(TLAbsInputPeer peer)
{
var req = new TLRequestSetTyping()
{
Action = new TLSendMessageTypingAction(),
Peer = peer
};
return await SendRequestAsync<Boolean>(req);
}
public async Task<TLAbsDialogs> GetUserDialogsAsync()
{
var peer = new TLInputPeerSelf();
return await SendRequestAsync<TLAbsDialogs>(
new TLRequestGetDialogs() { OffsetDate = 0, OffsetPeer = peer, Limit = 100 });
}
public async Task<TLAbsUpdates> SendUploadedPhoto(TLAbsInputPeer peer, TLAbsInputFile file, string caption)
{
return await SendRequestAsync<TLAbsUpdates>(new TLRequestSendMedia()
{
RandomId = Helpers.GenerateRandomLong(),
Background = false,
ClearDraft = false,
Media = new TLInputMediaUploadedPhoto() { File = file, Caption = caption },
Peer = peer
});
}
public async Task<TLAbsUpdates> SendUploadedDocument(
TLAbsInputPeer peer, TLAbsInputFile file, string caption, string mimeType, TLVector<TLAbsDocumentAttribute> attributes)
{
return await SendRequestAsync<TLAbsUpdates>(new TLRequestSendMedia()
{
RandomId = Helpers.GenerateRandomLong(),
Background = false,
ClearDraft = false,
Media = new TLInputMediaUploadedDocument()
{
File = file,
}
public async Task<TLAbsUpdates> ForwardMessagesAsync(TLAbsInputPeer peerfrom, TLAbsInputPeer peerto, TLVector<int> messagesId)
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
return await SendRequestAsync<TLAbsUpdates>(
new TLRequestForwardMessages()
{
Id = messagesId,
ToPeer = peerto,
FromPeer = peerfrom,
RandomId = new TLVector<long>() { Helpers.GenerateRandomLong() }
});
}
public async Task<TLAbsUpdates> ForwardMessageAsync(TLAbsInputPeer peer, int messageId)
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
return await SendRequestAsync<TLAbsUpdates>(
new TLRequestForwardMessage()
{
Id = messageId,
Peer = peer,
RandomId = Helpers.GenerateRandomLong()
});
}
public async Task<Boolean> SendTypingAsync(TLAbsInputPeer peer)
{
var req = new TLRequestSetTyping()
{
Action = new TLSendMessageTypingAction(),
Peer = peer
};
return await SendRequestAsync<Boolean>(req);
}
public async Task<TLAbsDialogs> GetUserDialogsAsync()
{
var peer = new TLInputPeerSelf();
return await SendRequestAsync<TLAbsDialogs>(
new TLRequestGetDialogs() { OffsetDate = 0, OffsetPeer = peer, Limit = 100 });
}
public async Task<TLAbsUpdates> SendUploadedPhoto(TLAbsInputPeer peer, TLAbsInputFile file, string caption)
{
return await SendRequestAsync<TLAbsUpdates>(new TLRequestSendMedia()
{
RandomId = Helpers.GenerateRandomLong(),
Background = false,
ClearDraft = false,
Media = new TLInputMediaUploadedPhoto() { File = file, Caption = caption },
Peer = peer
});
}
public async Task<TLAbsUpdates> SendUploadedDocument(
TLAbsInputPeer peer, TLAbsInputFile file, string caption, string mimeType, TLVector<TLAbsDocumentAttribute> attributes)
{
return await SendRequestAsync<TLAbsUpdates>(new TLRequestSendMedia()
{
RandomId = Helpers.GenerateRandomLong(),
Background = false,
ClearDraft = false,
Media = new TLInputMediaUploadedDocument()
{
File = file,
Caption = caption,
MimeType = mimeType,
Attributes = attributes
},
Peer = peer
});
}
public async Task<TLFile> GetFile(TLAbsInputFileLocation location, int filePartSize, int offset = 0)
{
TLFile result = null;
result = await SendRequestAsync<TLFile>(new TLRequestGetFile()
{
Location = location,
Limit = filePartSize,
Offset = offset
});
return result;
}
public async Task SendPingAsync()
{
await _sender.SendPingAsync();
MimeType = mimeType,
Attributes = attributes
},
Peer = peer
});
}
public async Task<TLFile> GetFile(TLAbsInputFileLocation location, int filePartSize, int offset = 0)
{
TLFile result = null;
result = await SendRequestAsync<TLFile>(new TLRequestGetFile()
{
Location = location,
Limit = filePartSize,
Offset = offset
});
return result;
}
public async Task SendPingAsync()
{
await _sender.SendPingAsync();
}
public async Task<TLAbsMessages> GetHistoryAsync(TLAbsInputPeer peer, int offset, int max_id, int limit)
@ -367,31 +381,47 @@ namespace TLSharp.Core
Limit = limit
};
return await SendRequestAsync<TLAbsMessages>(req);
}
/// <summary>
/// Serch user or chat. API: contacts.search#11f812d8 q:string limit:int = contacts.Found;
/// </summary>
/// <param name="q">User or chat name</param>
/// <param name="limit">Max result count</param>
/// <returns></returns>
public async Task<TLFound> SearchUserAsync(string q, int limit = 10)
{
var r = new TeleSharp.TL.Contacts.TLRequestSearch
{
Q = q,
Limit = limit
};
return await SendRequestAsync<TLFound>(r);
}
private void OnUserAuthenticated(TLUser TLUser)
{
_session.TLUser = TLUser;
_session.SessionExpires = int.MaxValue;
_session.Save();
}
public async Task<TLAbsMessages> GetHistoryAsync(TLAbsInputPeer peer, int offset, int max_id, int min_id, int limit)
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
var req = new TLRequestGetHistory()
{
Peer = peer,
AddOffset = offset,
MaxId = max_id,
MinId = min_id,
Limit = limit
};
return await SendRequestAsync<TLAbsMessages>(req);
}
/// <summary>
/// Serch user or chat. API: contacts.search#11f812d8 q:string limit:int = contacts.Found;
/// </summary>
/// <param name="q">User or chat name</param>
/// <param name="limit">Max result count</param>
/// <returns></returns>
public async Task<TLFound> SearchUserAsync(string q, int limit = 10)
{
var r = new TeleSharp.TL.Contacts.TLRequestSearch
{
Q = q,
Limit = limit
};
return await SendRequestAsync<TLFound>(r);
}
private void OnUserAuthenticated(TLUser TLUser)
{
_session.TLUser = TLUser;
_session.SessionExpires = int.MaxValue;
_session.Save();
}
public bool IsConnected
@ -404,32 +434,32 @@ namespace TLSharp.Core
}
}
public void Dispose()
{
if (_transport != null)
{
_transport.Dispose();
_transport = null;
}
}
}
public class MissingApiConfigurationException : Exception
{
public const string InfoUrl = "https://github.com/sochix/TLSharp#quick-configuration";
internal MissingApiConfigurationException(string invalidParamName) :
base($"Your {invalidParamName} setting is missing. Adjust the configuration first, see {InfoUrl}")
{
}
}
public class InvalidPhoneCodeException : Exception
{
internal InvalidPhoneCodeException(string msg) : base(msg) { }
}
public class CloudPasswordNeededException : Exception
{
internal CloudPasswordNeededException(string msg) : base(msg) { }
}
}
public void Dispose()
{
if (_transport != null)
{
_transport.Dispose();
_transport = null;
}
}
}
public class MissingApiConfigurationException : Exception
{
public const string InfoUrl = "https://github.com/sochix/TLSharp#quick-configuration";
internal MissingApiConfigurationException(string invalidParamName) :
base($"Your {invalidParamName} setting is missing. Adjust the configuration first, see {InfoUrl}")
{
}
}
public class InvalidPhoneCodeException : Exception
{
internal InvalidPhoneCodeException(string msg) : base(msg) { }
}
public class CloudPasswordNeededException : Exception
{
internal CloudPasswordNeededException(string msg) : base(msg) { }
}
}

View file

@ -7,6 +7,76 @@ using System.Threading.Tasks;
using TeleSharp.TL;
namespace TeleSharp.TL.Messages
{
//[TLObject(0x708e0195)]
//public class TLRequestForwardMessages : TLMethod
//{
// // Methods
// public void ComputeFlags()
// {
// this.flags = 0;
// this.flags = this.silent ? (this.flags | 0x20) : (this.flags & -33);
// this.flags = this.background ? (this.flags | 0x40) : (this.flags & -65);
// this.flags = this.with_my_score ? (this.flags | 0x100) : (this.flags & -257);
// }
// public override void DeserializeBody(BinaryReader br)
// {
// this.flags = br.ReadInt32();
// this.silent = (this.flags & 0x20) > 0;
// this.background = (this.flags & 0x40) > 0;
// this.with_my_score = (this.flags & 0x100) > 0;
// this.from_peer = (TLAbsInputPeer)ObjectUtils.DeserializeObject(br);
// this.id = ObjectUtils.DeserializeVector<int>(br);
// this.random_id = ObjectUtils.DeserializeVector<long>(br);
// this.to_peer = (TLAbsInputPeer)ObjectUtils.DeserializeObject(br);
// }
// public override void DeserializeResponse(BinaryReader br)
// {
// this.Response = (TLAbsUpdates)ObjectUtils.DeserializeObject(br);
// }
// public override void SerializeBody(BinaryWriter bw)
// {
// bw.Write(this.Constructor);
// this.ComputeFlags();
// bw.Write(this.flags);
// ObjectUtils.SerializeObject(this.from_peer, bw);
// ObjectUtils.SerializeObject(this.id, bw);
// ObjectUtils.SerializeObject(this.random_id, bw);
// ObjectUtils.SerializeObject(this.to_peer, bw);
// }
// // Properties
// public bool background { get; set; }
// public override int Constructor
// {
// get
// {
// return 0x708e0195;
// }
// }
// public int flags { get; set; }
// public TLAbsInputPeer from_peer { get; set; }
// public TLVector<int> id { get; set; }
// public TLVector<long> random_id { get; set; }
// public TLAbsUpdates Response { get; set; }
// public bool silent { get; set; }
// public TLAbsInputPeer to_peer { get; set; }
// public bool with_my_score { get; set; }
//}
[TLObject(1888354709)]
public class TLRequestForwardMessages : TLMethod
{