TLSharp icon indicating copy to clipboard operation
TLSharp copied to clipboard

Get current user

Open TooLazyy opened this issue 6 years ago • 4 comments

Hi. TelegramClient has a method IsUserAuthorized(). Is there any way to get currently authorized user if IsUserAuthorized() returns true?

TooLazyy avatar Jan 19 '18 14:01 TooLazyy

I'm looking for the same thing.

ferferga avatar Feb 15 '18 15:02 ferferga

I have same question too.

VahedCivil avatar Mar 26 '18 20:03 VahedCivil

The current user can be obtained from the TLUser property of the client's Session property.

var client = new TelegramClient(...);
await client.ConnectAsync();

if (client.IsUserAuthorized())
{
    var me = client.Session.TLUser;
    Console.WriteLine("Hello, {0}!", me.FirstName);
}

MiffOttah avatar Jan 08 '20 00:01 MiffOttah

Thanks, @MiffOttah . It works

vuminhit avatar Sep 07 '20 09:09 vuminhit