Skip to content
This repository has been archived by the owner on Dec 5, 2021. It is now read-only.

GetFullChat + GetAllChats + MakeAuthBotAsync + Other methods #926

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

GetFullChat + GetAllChats + MakeAuthBotAsync + Other methods #926

wants to merge 15 commits into from

Conversation

solarin
Copy link
Contributor

@solarin 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
@knocte
Copy link
Collaborator

knocte commented Apr 3, 2020

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).

knocte and others added 2 commits April 3, 2020 20:31
There were less places with underscores in field names than
places without them, so we now are consistent with the most
abundant occurrence.
@solarin
Copy link
Contributor Author

solarin commented Apr 3, 2020

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).

ok i think it's ok now

@knocte
Copy link
Collaborator

knocte commented Apr 5, 2020

@aarani can you review this PR?

! Added token to the parameters of async methods
! Typos and comments
@solarin solarin changed the title GetFullChat + GetAllChats + MakeAuthBotAsync GetFullChat + GetAllChats + MakeAuthBotAsync + Other methods Apr 5, 2020
using TLSharp.Core.Utils;
using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization;
using TLRequestUpdateUsername = TeleSharp.TL.Account.TLRequestUpdateUsername;
Copy link
Contributor

@aarani aarani Apr 5, 2020

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's fair enough

TLSharp.Core/TelegramClient.cs Outdated Show resolved Hide resolved
/// <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))
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure nice

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.

Copy link
Collaborator

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?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@knocte ok

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?

Copy link
Collaborator

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");
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

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

TLSharp.Core/TelegramClient.cs Outdated Show resolved Hide resolved
@@ -0,0 +1,16 @@
namespace TLSharp.Core.Types
{
public enum ParticipantTypes
Copy link
Contributor

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?

Copy link
Contributor Author

@solarin solarin Apr 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ParticipantTypeFilters

ok?

Copy link
Contributor

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
Location = location,
Limit = filePartSize,
Offset = offset
}, token)
Copy link
Collaborator

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see the next commit

var fchat = await SendRequestAsync<TLChannelParticipants>(req, token).ConfigureAwait(false);
total = fchat.Count;
found += fchat.Participants.Count;
results.Add(fchat);
Copy link
Contributor Author

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));
Copy link
Collaborator

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?

Copy link

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));

@solarin
Copy link
Contributor Author

solarin commented Apr 6, 2020

@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.

@knocte
Copy link
Collaborator

knocte commented Apr 6, 2020

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants