diff --git a/README.md b/README.md index edd746b..1456e40 100644 --- a/README.md +++ b/README.md @@ -166,7 +166,7 @@ See [Examples/Program_ListenUpdates.cs](https://github.com/wiz0u/WTelegramClient An invalid API request can result in a `RpcException` being raised, reflecting the [error code and status text](https://revgram.github.io/errors.html) of the problem. -The other configuration items that you can override include: **session_pathname, email, email_verification_code, session_key, server_address, device_model, system_version, app_version, system_lang_code, lang_pack, lang_code, user_id, bot_token** +The other configuration items that you can override include: **session_pathname, email, email_verification_code, session_key, server_address, device_model, system_version, app_version, system_lang_code, lang_pack, lang_code, firebase, user_id, bot_token** Optional API parameters have a default value of `null` when unset. Passing `null` for a required string/array is the same as *empty* (0-length). Required API parameters/fields can sometimes be set to 0 or `null` when unused (check API documentation or experiment). diff --git a/src/TL.Helpers.cs b/src/TL.Helpers.cs index 62b48e2..1acaff5 100644 --- a/src/TL.Helpers.cs +++ b/src/TL.Helpers.cs @@ -161,7 +161,7 @@ namespace TL public override bool IsActive => (flags & Flags.deleted) == 0; public bool IsBot => (flags & Flags.bot) != 0; public string MainUsername => username ?? usernames?.FirstOrDefault(u => u.flags.HasFlag(Username.Flags.active))?.username; - public override string ToString() => username != null ? '@' + username : last_name == null ? first_name : $"{first_name} {last_name}"; + public override string ToString() => MainUsername is string uname ? '@' + uname : last_name == null ? first_name : $"{first_name} {last_name}"; public override InputPeer ToInputPeer() => new InputPeerUser(id, access_hash); protected override InputUser ToInputUser() => new(id, access_hash); /// An estimation of the number of days ago the user was last seen (Online=0, Recently=1, LastWeek=5, LastMonth=20, LongTimeAgo=150) @@ -221,8 +221,7 @@ namespace TL public override bool IsBanned(ChatBannedRights.Flags flags = 0) => ((banned_rights?.flags ?? 0) & flags) != 0 || ((default_banned_rights?.flags ?? 0) & flags) != 0; public override InputPeer ToInputPeer() => new InputPeerChannel(id, access_hash); public static implicit operator InputChannel(Channel channel) => new(channel.id, channel.access_hash); - public override string ToString() => - (flags.HasFlag(Flags.broadcast) ? "Channel " : "Group ") + (username != null ? '@' + username : $"\"{title}\""); + public override string ToString() => (flags.HasFlag(Flags.broadcast) ? "Channel " : "Group ") + (MainUsername is string uname ? '@' + uname : $"\"{title}\""); public bool IsChannel => (flags & Flags.broadcast) != 0; public bool IsGroup => (flags & Flags.broadcast) == 0; }