diff --git a/src/TL.Helpers.cs b/src/TL.Helpers.cs
index d9425fa..e6443a5 100644
--- a/src/TL.Helpers.cs
+++ b/src/TL.Helpers.cs
@@ -83,8 +83,23 @@ namespace TL
public override string ToString() => username != null ? '@' + username : last_name == null ? first_name : $"{first_name} {last_name}";
public override InputPeer ToInputPeer() => new InputPeerUser { user_id = id, access_hash = access_hash };
protected override InputUserBase ToInputUser() => new InputUser { user_id = id, access_hash = 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)
+ public TimeSpan LastSeenAgo => status?.LastSeenAgo ?? TimeSpan.FromDays(150);
}
+
+ /// a null value means userStatusEmpty = last seen a long time ago, more than a month (this is also always shown to blocked users)
+ partial class UserStatus { /// An estimation of the number of days ago the user was last seen (online=0, recently=1, lastWeek=5, lastMonth=20)
= null means a long time ago, more than a month (this is also always shown to blocked users)
+ public abstract TimeSpan LastSeenAgo { get; } }
+ partial class UserStatusOnline { public override TimeSpan LastSeenAgo => TimeSpan.Zero; }
+ partial class UserStatusOffline { public override TimeSpan LastSeenAgo => DateTime.UtcNow - new DateTime((was_online + 62135596800L) * 10000000, DateTimeKind.Utc); }
+ /// covers anything between 1 second and 2-3 days
+ partial class UserStatusRecently { public override TimeSpan LastSeenAgo => TimeSpan.FromDays(1); }
+ /// between 2-3 and seven days
+ partial class UserStatusLastWeek { public override TimeSpan LastSeenAgo => TimeSpan.FromDays(5); }
+ /// between 6-7 days and a month
+ partial class UserStatusLastMonth { public override TimeSpan LastSeenAgo => TimeSpan.FromDays(20); }
+
partial class ChatBase : IPeerInfo
{
public abstract bool IsActive { get; }
@@ -280,6 +295,8 @@ namespace TL
public static implicit operator InputStickerSetID(StickerSet stickerSet) => new() { id = stickerSet.id, access_hash = stickerSet.access_hash };
}
+ partial class InputChannel { public static implicit operator InputPeerChannel(InputChannel channel) => new() { channel_id = channel.channel_id, access_hash = channel.access_hash }; }
+
partial class Contacts_ResolvedPeer
{
public static implicit operator InputPeer(Contacts_ResolvedPeer resolved) => resolved.UserOrChat.ToInputPeer();
diff --git a/src/TL.Schema.cs b/src/TL.Schema.cs
index 6a94edc..7909656 100644
--- a/src/TL.Schema.cs
+++ b/src/TL.Schema.cs
@@ -808,30 +808,30 @@ namespace TL
/// User online status Derived classes: , , , , See
/// a null value means userStatusEmpty
- public abstract class UserStatus : IObject { }
+ public abstract partial class UserStatus : IObject { }
/// Online status of the user. See
[TLDef(0xEDB93949)]
- public class UserStatusOnline : UserStatus
+ public partial class UserStatusOnline : UserStatus
{
/// Time to expiration of the current online status
public DateTime expires;
}
/// The user's offline status. See
[TLDef(0x008C703F)]
- public class UserStatusOffline : UserStatus
+ public partial class UserStatusOffline : UserStatus
{
/// Time the user was last seen online
public int was_online;
}
/// Online status: last seen recently See
[TLDef(0xE26F42F1)]
- public class UserStatusRecently : UserStatus { }
+ public partial class UserStatusRecently : UserStatus { }
/// Online status: last seen last week See
[TLDef(0x07BF09FC)]
- public class UserStatusLastWeek : UserStatus { }
+ public partial class UserStatusLastWeek : UserStatus { }
/// Online status: last seen last month See
[TLDef(0x77EBC742)]
- public class UserStatusLastMonth : UserStatus { }
+ public partial class UserStatusLastMonth : UserStatus { }
/// Object defines a group. Derived classes: , , , , See
public abstract partial class ChatBase : IObject
@@ -6174,7 +6174,7 @@ namespace TL
}
/// Represents a channel See
[TLDef(0xF35AEC28)]
- public class InputChannel : InputChannelBase
+ public partial class InputChannel : InputChannelBase
{
/// Channel ID
public long channel_id;
diff --git a/src/TL.cs b/src/TL.cs
index 26f1fcd..3aa9357 100644
--- a/src/TL.cs
+++ b/src/TL.cs
@@ -359,7 +359,7 @@ namespace TL
{
public readonly int Code;
public RpcException(int code, string message) : base(message) => Code = code;
- public override string ToString() => $"RpcException: {Code} {Message}";
+ public override string ToString() { var str = base.ToString(); return str.Insert(str.IndexOf(':') + 1, " " + Code); }
}
public class ReactorError : IObject