-
Notifications
You must be signed in to change notification settings - Fork 378
GetFullChat + GetAllChats + MakeAuthBotAsync + Other methods #926
base: master
Are you sure you want to change the base?
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.Utils; | ||
using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization; | ||
using TLRequestUpdateUsername = TeleSharp.TL.Account.TLRequestUpdateUsername; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's fair enough
/// <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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use TLChannel or TLInputChannel as parameter here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I create an overload as for the other methods, ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamesjsc do you mind porting this PR to TgSharp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@knocte ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@knocte What is the different between TLSharp and TgSharp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's gonna be implemented as soon as the new Classes are added to the TL framework
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should i drop them anyways or leave them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are they present in the new layers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, see here: https://core.telegram.org/type/ChannelParticipantsFilter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to something like ParticipantTypesFilter too maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ParticipantTypeFilters
ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you formatted the whole file again by mistake, can you create a separate PR just to format the file please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see the next commit
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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 |