From ce93c766c49a8b552bf48d87c58e559c1e4d5229 Mon Sep 17 00:00:00 2001 From: solarin Date: Mon, 6 Apr 2020 10:49:19 +0400 Subject: [PATCH] ! fixed conflicts + eol --- TLSharp.Core/TLSharp.Core.csproj | 2 +- TLSharp.Core/TelegramClient.cs | 42 ++++++++++++++----- ...pantTypes.cs => ParticipantFilterTypes.cs} | 2 +- 3 files changed, 33 insertions(+), 13 deletions(-) rename TLSharp.Core/Types/{ParticipantTypes.cs => ParticipantFilterTypes.cs} (82%) diff --git a/TLSharp.Core/TLSharp.Core.csproj b/TLSharp.Core/TLSharp.Core.csproj index 5f6d2af..dd2c33c 100644 --- a/TLSharp.Core/TLSharp.Core.csproj +++ b/TLSharp.Core/TLSharp.Core.csproj @@ -73,7 +73,7 @@ - + diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 4ac6947..57df77e 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -435,6 +435,7 @@ namespace TLSharp.Core return ((TLUser)request.Response.User); } + /// /// Gets the full information of a specified chat /// @@ -448,6 +449,7 @@ namespace TLSharp.Core return fchat; } + /// /// Gets the list of chats and channels opened by the authenticated user. /// Throws an exception if the authenticated user is a bot. @@ -458,6 +460,7 @@ namespace TLSharp.Core { return await GetAllChats(null, token); } + /// /// Gets the list of chats and channels opened by the authenticated user except the passed ones. /// Throws an exception if the authenticated user is a bot. @@ -473,6 +476,7 @@ namespace TLSharp.Core var chats = await SendRequestAsync(new TLRequestGetAllChats() { ExceptIds = ichats }, token).ConfigureAwait(false); return chats; } + /// /// Gets the information about a channel /// @@ -484,6 +488,7 @@ namespace TLSharp.Core if (channel == null) return null; return await GetFullChannel(channel.Id, (long)channel.AccessHash, token).ConfigureAwait(false); } + /// /// Gets the information about a channel /// @@ -497,6 +502,7 @@ namespace TLSharp.Core return fchat; } + /// /// Gets the channels having the supplied IDs /// @@ -513,6 +519,7 @@ namespace TLSharp.Core return fchat; } + /// /// Gets the participants of the channel having the supplied type. /// The method will auto-paginate results and return all the participants @@ -524,11 +531,12 @@ namespace TLSharp.Core /// The type of the participants to get. Choose Recents not to filter /// /// - public async Task GetParticipants(TLChannel channel, int stIdx = -1, int pageSize = -1, ParticipantTypes partType = ParticipantTypes.Recents, CancellationToken token = default(CancellationToken)) + public async Task GetParticipants(TLChannel channel, int stIdx = -1, int pageSize = -1, ParticipantFilterTypes partType = ParticipantFilterTypes.Recents, CancellationToken token = default(CancellationToken)) { if (channel == null) return null; return await GetParticipants(channel.Id, (long)channel.AccessHash, stIdx, pageSize, partType, token).ConfigureAwait(false); } + /// /// Gets the participants of the channel having the supplied type. /// The method will auto-paginate results and return all the participants @@ -541,31 +549,31 @@ namespace TLSharp.Core /// The type of the participants to get. Choose Recents not to filter /// /// - public async Task GetParticipants(int channelId, long accessHash, int stIdx = -1, int pageSize = -1, ParticipantTypes partType = ParticipantTypes.Recents, CancellationToken token = default(CancellationToken)) + public async Task GetParticipants(int channelId, long accessHash, int stIdx = -1, int pageSize = -1, ParticipantFilterTypes partType = ParticipantFilterTypes.Recents, CancellationToken token = default(CancellationToken)) { TLAbsChannelParticipantsFilter filter; switch (partType) { - case ParticipantTypes.Admins: + case ParticipantFilterTypes.Admins: filter = new TLChannelParticipantsAdmins(); break; - case ParticipantTypes.Kicked: + case ParticipantFilterTypes.Kicked: filter = new TLChannelParticipantsKicked(); break; - case ParticipantTypes.Bots: + case ParticipantFilterTypes.Bots: filter = new TLChannelParticipantsBots(); break; - case ParticipantTypes.Recents: + case ParticipantFilterTypes.Recents: filter = new TLChannelParticipantsRecent(); break; - case ParticipantTypes.Banned: - case ParticipantTypes.Restricted: - case ParticipantTypes.Contacts: - case ParticipantTypes.Search: + case ParticipantFilterTypes.Banned: + case ParticipantFilterTypes.Restricted: + case ParticipantFilterTypes.Contacts: + case ParticipantFilterTypes.Search: default: throw new NotImplementedException($"{partType} not implemented yet"); } @@ -588,7 +596,7 @@ namespace TLSharp.Core ChannelId = channelId, AccessHash = accessHash }, - Filter = new TLChannelParticipantsRecent(), + Filter = filter, Offset = found, Limit = pageSize }; @@ -604,6 +612,18 @@ namespace TLSharp.Core ret.Count = ret.Participants.Count; return ret; } + + /// + /// Invites the passed users to the specified channel + /// + /// The descriptor of the channel to invite the users to + /// + /// + public async Task InviteToChannel(TLChannel channel, int[] users, CancellationToken token = default(CancellationToken)) + { + return await InviteToChannel(channel.Id, (long)channel.AccessHash, users, token); + } + /// /// Invites the passed users to the specified channel /// diff --git a/TLSharp.Core/Types/ParticipantTypes.cs b/TLSharp.Core/Types/ParticipantFilterTypes.cs similarity index 82% rename from TLSharp.Core/Types/ParticipantTypes.cs rename to TLSharp.Core/Types/ParticipantFilterTypes.cs index 44be381..99eef19 100644 --- a/TLSharp.Core/Types/ParticipantTypes.cs +++ b/TLSharp.Core/Types/ParticipantFilterTypes.cs @@ -1,6 +1,6 @@ namespace TLSharp.Core.Types { - public enum ParticipantTypes + public enum ParticipantFilterTypes { Recents, Restricted,