Revert "+ overload for method InviteToChannel"

This reverts commit 45be5f51d3.
This commit is contained in:
solarin 2020-04-06 10:45:40 +04:00
parent 45be5f51d3
commit 9623f9d5ac
3 changed files with 52 additions and 62 deletions

View file

@ -73,7 +73,7 @@
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Network\Requests\AckRequest.cs" /> <Compile Include="Network\Requests\AckRequest.cs" />
<Compile Include="Network\Requests\PingRequest.cs" /> <Compile Include="Network\Requests\PingRequest.cs" />
<Compile Include="Types\ParticipantFilterTypes.cs" /> <Compile Include="Types\ParticipantTypes.cs" />
<Compile Include="Utils\UploadHelper.cs" /> <Compile Include="Utils\UploadHelper.cs" />
<Compile Include="Session.cs" /> <Compile Include="Session.cs" />
<Compile Include="TelegramClient.cs" /> <Compile Include="TelegramClient.cs" />

View file

@ -61,7 +61,7 @@ namespace TLSharp.Core
this.handler = handler; this.handler = handler;
session = Session.TryLoadOrCreateNew(store, sessionUserId); session = Session.TryLoadOrCreateNew(store, sessionUserId);
transport = new TcpTransport(session.DataCenter.Address, session.DataCenter.Port, this.handler); transport = new TcpTransport (session.DataCenter.Address, session.DataCenter.Port, this.handler);
} }
public async Task ConnectAsync(bool reconnect = false, CancellationToken token = default(CancellationToken)) public async Task ConnectAsync(bool reconnect = false, CancellationToken token = default(CancellationToken))
@ -110,7 +110,7 @@ namespace TLSharp.Core
} }
var dc = dcOptions.First(d => d.Id == dcId); var dc = dcOptions.First(d => d.Id == dcId);
var dataCenter = new DataCenter(dcId, dc.IpAddress, dc.Port); var dataCenter = new DataCenter (dcId, dc.IpAddress, dc.Port);
transport = new TcpTransport(dc.IpAddress, dc.Port, handler); transport = new TcpTransport(dc.IpAddress, dc.Port, handler);
session.DataCenter = dataCenter; session.DataCenter = dataCenter;
@ -131,7 +131,7 @@ namespace TLSharp.Core
throw new InvalidOperationException("Not connected!"); throw new InvalidOperationException("Not connected!");
var completed = false; var completed = false;
while (!completed) while(!completed)
{ {
try try
{ {
@ -139,7 +139,7 @@ namespace TLSharp.Core
await sender.Receive(request, token).ConfigureAwait(false); await sender.Receive(request, token).ConfigureAwait(false);
completed = true; completed = true;
} }
catch (DataCenterMigrationException e) catch(DataCenterMigrationException e)
{ {
if (session.DataCenter.DataCenterId.HasValue && if (session.DataCenter.DataCenterId.HasValue &&
session.DataCenter.DataCenterId.Value == e.DC) session.DataCenter.DataCenterId.Value == e.DC)
@ -251,7 +251,7 @@ namespace TLSharp.Core
return (T)result; return (T)result;
} }
internal async Task<T> SendAuthenticatedRequestAsync<T>(TLMethod methodToExecute, CancellationToken token = default(CancellationToken)) internal async Task<T> SendAuthenticatedRequestAsync<T> (TLMethod methodToExecute, CancellationToken token = default(CancellationToken))
{ {
if (!IsUserAuthorized()) if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!"); throw new InvalidOperationException("Authorize user first!");
@ -278,7 +278,7 @@ namespace TLSharp.Core
public async Task<TLImportedContacts> ImportContactsAsync(IReadOnlyList<TLInputPhoneContact> contacts, CancellationToken token = default(CancellationToken)) public async Task<TLImportedContacts> ImportContactsAsync(IReadOnlyList<TLInputPhoneContact> contacts, CancellationToken token = default(CancellationToken))
{ {
var req = new TLRequestImportContacts { Contacts = new TLVector<TLInputPhoneContact>(contacts) }; var req = new TLRequestImportContacts { Contacts = new TLVector<TLInputPhoneContact>(contacts)};
return await SendAuthenticatedRequestAsync<TLImportedContacts>(req, token) return await SendAuthenticatedRequestAsync<TLImportedContacts>(req, token)
.ConfigureAwait(false); .ConfigureAwait(false);
@ -286,7 +286,7 @@ namespace TLSharp.Core
public async Task<bool> DeleteContactsAsync(IReadOnlyList<TLAbsInputUser> users, CancellationToken token = default(CancellationToken)) public async Task<bool> DeleteContactsAsync(IReadOnlyList<TLAbsInputUser> users, CancellationToken token = default(CancellationToken))
{ {
var req = new TLRequestDeleteContacts { Id = new TLVector<TLAbsInputUser>(users) }; var req = new TLRequestDeleteContacts {Id = new TLVector<TLAbsInputUser>(users)};
return await SendAuthenticatedRequestAsync<bool>(req, token) return await SendAuthenticatedRequestAsync<bool>(req, token)
.ConfigureAwait(false); .ConfigureAwait(false);
@ -294,7 +294,7 @@ namespace TLSharp.Core
public async Task<TLLink> DeleteContactAsync(TLAbsInputUser user, CancellationToken token = default(CancellationToken)) public async Task<TLLink> DeleteContactAsync(TLAbsInputUser user, CancellationToken token = default(CancellationToken))
{ {
var req = new TLRequestDeleteContact { Id = user }; var req = new TLRequestDeleteContact {Id = user};
return await SendAuthenticatedRequestAsync<TLLink>(req, token) return await SendAuthenticatedRequestAsync<TLLink>(req, token)
.ConfigureAwait(false); .ConfigureAwait(false);
@ -524,7 +524,7 @@ namespace TLSharp.Core
/// <param name="partType">The type of the participants to get. Choose Recents not to filter</param> /// <param name="partType">The type of the participants to get. Choose Recents not to filter</param>
/// <param name="token"></param> /// <param name="token"></param>
/// <returns></returns> /// <returns></returns>
public async Task<TLChannelParticipants> GetParticipants(TLChannel channel, int stIdx = -1, int pageSize = -1, ParticipantFilterTypes partType = ParticipantFilterTypes.Recents, CancellationToken token = default(CancellationToken)) public async Task<TLChannelParticipants> GetParticipants(TLChannel channel, int stIdx = -1, int pageSize = -1, ParticipantTypes partType = ParticipantTypes.Recents, CancellationToken token = default(CancellationToken))
{ {
if (channel == null) return null; if (channel == null) return null;
return await GetParticipants(channel.Id, (long)channel.AccessHash, stIdx, pageSize, partType, token).ConfigureAwait(false); return await GetParticipants(channel.Id, (long)channel.AccessHash, stIdx, pageSize, partType, token).ConfigureAwait(false);
@ -541,31 +541,31 @@ namespace TLSharp.Core
/// <param name="partType">The type of the participants to get. Choose Recents not to filter</param> /// <param name="partType">The type of the participants to get. Choose Recents not to filter</param>
/// <param name="token"></param> /// <param name="token"></param>
/// <returns></returns> /// <returns></returns>
public async Task<TLChannelParticipants> GetParticipants(int channelId, long accessHash, int stIdx = -1, int pageSize = -1, ParticipantFilterTypes partType = ParticipantFilterTypes.Recents, CancellationToken token = default(CancellationToken)) public async Task<TLChannelParticipants> GetParticipants(int channelId, long accessHash, int stIdx = -1, int pageSize = -1, ParticipantTypes partType = ParticipantTypes.Recents, CancellationToken token = default(CancellationToken))
{ {
TLAbsChannelParticipantsFilter filter; TLAbsChannelParticipantsFilter filter;
switch (partType) switch (partType)
{ {
case ParticipantFilterTypes.Admins: case ParticipantTypes.Admins:
filter = new TLChannelParticipantsAdmins(); filter = new TLChannelParticipantsAdmins();
break; break;
case ParticipantFilterTypes.Kicked: case ParticipantTypes.Kicked:
filter = new TLChannelParticipantsKicked(); filter = new TLChannelParticipantsKicked();
break; break;
case ParticipantFilterTypes.Bots: case ParticipantTypes.Bots:
filter = new TLChannelParticipantsBots(); filter = new TLChannelParticipantsBots();
break; break;
case ParticipantFilterTypes.Recents: case ParticipantTypes.Recents:
filter = new TLChannelParticipantsRecent(); filter = new TLChannelParticipantsRecent();
break; break;
case ParticipantFilterTypes.Banned: case ParticipantTypes.Banned:
case ParticipantFilterTypes.Restricted: case ParticipantTypes.Restricted:
case ParticipantFilterTypes.Contacts: case ParticipantTypes.Contacts:
case ParticipantFilterTypes.Search: case ParticipantTypes.Search:
default: default:
throw new NotImplementedException($"{partType} not implemented yet"); throw new NotImplementedException($"{partType} not implemented yet");
} }
@ -588,7 +588,7 @@ namespace TLSharp.Core
ChannelId = channelId, ChannelId = channelId,
AccessHash = accessHash AccessHash = accessHash
}, },
Filter = filter, Filter = new TLChannelParticipantsRecent(),
Offset = found, Offset = found,
Limit = pageSize Limit = pageSize
}; };
@ -607,16 +607,6 @@ namespace TLSharp.Core
/// <summary> /// <summary>
/// Invites the passed users to the specified channel /// Invites the passed users to the specified channel
/// </summary> /// </summary>
/// <param name="channel">The descriptor of the channel to invite the users to</param>
/// <param name="users"></param>
/// <returns></returns>
public async Task<TLUpdates> InviteToChannel(TLChannel channel, int[] users, CancellationToken token = default(CancellationToken))
{
return await InviteToChannel(channel.Id, (long)channel.AccessHash, users, token);
}
/// <summary>
/// Invites the passed users to the specified channel
/// </summary>
/// <param name="channelId">The id of the channel to invite the users to</param> /// <param name="channelId">The id of the channel to invite the users to</param>
/// <param name="accessHash">The access hash of the channel to invite the users to</param> /// <param name="accessHash">The access hash of the channel to invite the users to</param>
/// <param name="users"></param> /// <param name="users"></param>

View file

@ -1,6 +1,6 @@
namespace TLSharp.Core.Types namespace TLSharp.Core.Types
{ {
public enum ParticipantFilterTypes public enum ParticipantTypes
{ {
Recents, Recents,
Restricted, Restricted,