GetFullChat + GetAllChats + MakeAuthBotAsync + Other methods#926
GetFullChat + GetAllChats + MakeAuthBotAsync + Other methods#926solarin wants to merge 15 commits intosochix:masterfrom solarin:getchats-authbot
Conversation
solarin
commented
Apr 3, 2020
- GetFullChat to get the info of a chat
- GetAllChats to get all available user's chats
- MakeAuthBotAsync to authenticate a bot instead of a user
added the csproj
+ GetAllChats to get all available user's chats + MakeAuthBotAsync to authenticate a bot instead of a user
+ GetAllChats to get all available user's chats + MakeAuthBotAsync to authenticate a bot instead of a user
|
You need to remove the DataCenterIPVersion stuff from here, otherwise the PRs are not separate (if I merge the other one, there will be conflicts here). |
There were less places with underscores in field names than places without them, so we now are consistent with the most abundant occurrence.
ok i think it's ok now |
|
@aarani can you review this PR? |
! Added token to the parameters of async methods ! Typos and comments
| using TLSharp.Core.Types; | ||
| using TLSharp.Core.Utils; | ||
| using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization; | ||
| using TLRequestUpdateUsername = TeleSharp.TL.Account.TLRequestUpdateUsername; |
There was a problem hiding this comment.
what's the reason behind this? just use it directly inside the code. there is hundreds of request used in this file. no need to add alias for just one use
There was a problem hiding this comment.
actually TLRequestUpdateUsername is ambigous with as it's already present in TL.Channels. i can double check and report exactly where.
There was a problem hiding this comment.
'TLRequestUpdateUsername' is an ambiguous reference between 'TeleSharp.TL.Account.TLRequestUpdateUsername' and 'TeleSharp.TL.Channels.TLRequestUpdateUsername'
'TLAuthorization' is an ambiguous reference between 'TeleSharp.TL.Auth.TLAuthorization' and 'TeleSharp.TL.TLAuthorization' TLSharp.Core
| /// <param name="accessHash">The access hash of the channel to invite the users to</param> | ||
| /// <param name="users"></param> | ||
| /// <returns></returns> | ||
| public async Task<TLUpdates> InviteToChannel(int channelId, long accessHash, int[] users, CancellationToken token = default(CancellationToken)) |
There was a problem hiding this comment.
maybe use TLChannel or TLInputChannel as parameter here?
There was a problem hiding this comment.
I create an overload as for the other methods, ok?
There was a problem hiding this comment.
This function is not working, always return UserId_Invalid exception
You have to assign both UserId and Hash to TLInputUser.
There was a problem hiding this comment.
@jamesjsc do you mind porting this PR to TgSharp?
There was a problem hiding this comment.
@knocte What is the different between TLSharp and TgSharp?
There was a problem hiding this comment.
TL Layer update, Tg is the future, TL will just receive bug fixes, no new features.
| case ParticipantTypes.Contacts: | ||
| case ParticipantTypes.Search: | ||
| default: | ||
| throw new NotImplementedException($"{partType} not implemented yet"); |
There was a problem hiding this comment.
If it's not gonna be implemented please remove them from your enum as the only purpose of enum is for this filter
There was a problem hiding this comment.
it's gonna be implemented as soon as the new Classes are added to the TL framework
There was a problem hiding this comment.
should i drop them anyways or leave them?
There was a problem hiding this comment.
are they present in the new layers?
There was a problem hiding this comment.
yes, see here: https://core.telegram.org/type/ChannelParticipantsFilter
There was a problem hiding this comment.
I vote, then, for only merging this PR after we have updated the layer
| @@ -0,0 +1,16 @@ | |||
| namespace TLSharp.Core.Types | |||
| { | |||
| public enum ParticipantTypes | |||
There was a problem hiding this comment.
Change this to something like ParticipantTypesFilter too maybe?
There was a problem hiding this comment.
ParticipantTypeFilters
ok?
! filter wasn't actually used ! renamed the ParticipantTypes -> ParticipantFilterTypes
TLSharp.Core/TelegramClient.cs
Outdated
| Location = location, | ||
| Limit = filePartSize, | ||
| Offset = offset | ||
| }, token) |
There was a problem hiding this comment.
you formatted the whole file again by mistake, can you create a separate PR just to format the file please?
This reverts commit 45be5f5.
+ eol
TLSharp.Core/TelegramClient.cs
Outdated
| var fchat = await SendRequestAsync<TLChannelParticipants>(req, token).ConfigureAwait(false); | ||
| total = fchat.Count; | ||
| found += fchat.Participants.Count; | ||
| results.Add(fchat); |
There was a problem hiding this comment.
i must remove this results. it is useless.
| { | ||
| var ichats = new TeleSharp.TL.TLVector<int>(); // we can't pass a null argument to the TLRequestGetChats | ||
| if (exceptdIds != null) | ||
| Array.ForEach(exceptdIds, x => ichats.Add(x)); |
There was a problem hiding this comment.
I'm not a fan of Array.ForEach because it hardcodes "Array"; isn't there an IEnumerable-esque way of doing this?
There was a problem hiding this comment.
// there is a handy constructor
var ichats = exceptdIds!=null ? new TeleSharp.TL.TLVector(exceptdIds) : new TeleSharp.TL.TLVector();
// if (exceptdIds != null)
// Array.ForEach(exceptdIds, x => ichats.Add(x));
|
@knocte as for the Array.ForEach, the only replacement i am aware of is to do a classic for(int i...). i wouldn't use any other list in this case as they would introduce a worse overhead than the Array.ForEach. |
Let's use a normal foreach then. More reasoning here: https://docs.microsoft.com/en-gb/archive/blogs/ericlippert/foreach-vs-foreach |