mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2026-01-05 00:00:21 +01:00
Added LastSeenAgo
and other helpers
This commit is contained in:
parent
624f45bd05
commit
8efa248aef
|
|
@ -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 };
|
||||
/// <summary>An estimation of the number of days ago the user was last seen (Online=0, Recently=1, LastWeek=5, LastMonth=20, LongTimeAgo=150)</summary>
|
||||
public TimeSpan LastSeenAgo => status?.LastSeenAgo ?? TimeSpan.FromDays(150);
|
||||
}
|
||||
|
||||
|
||||
/// <remarks>a <c>null</c> value means <a href="https://corefork.telegram.org/constructor/userStatusEmpty">userStatusEmpty</a> = last seen a long time ago, more than a month (this is also always shown to blocked users)</remarks>
|
||||
partial class UserStatus { /// <summary>An estimation of the number of days ago the user was last seen (online=0, recently=1, lastWeek=5, lastMonth=20)<br/><see cref="UserStatus"/> = <c>null</c> means a long time ago, more than a month (this is also always shown to blocked users)</summary>
|
||||
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); }
|
||||
/// <remarks>covers anything between 1 second and 2-3 days</remarks>
|
||||
partial class UserStatusRecently { public override TimeSpan LastSeenAgo => TimeSpan.FromDays(1); }
|
||||
/// <remarks>between 2-3 and seven days</remarks>
|
||||
partial class UserStatusLastWeek { public override TimeSpan LastSeenAgo => TimeSpan.FromDays(5); }
|
||||
/// <remarks>between 6-7 days and a month</remarks>
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -808,30 +808,30 @@ namespace TL
|
|||
|
||||
/// <summary>User online status <para>Derived classes: <see cref="UserStatusOnline"/>, <see cref="UserStatusOffline"/>, <see cref="UserStatusRecently"/>, <see cref="UserStatusLastWeek"/>, <see cref="UserStatusLastMonth"/></para> <para>See <a href="https://corefork.telegram.org/type/UserStatus"/></para></summary>
|
||||
/// <remarks>a <c>null</c> value means <a href="https://corefork.telegram.org/constructor/userStatusEmpty">userStatusEmpty</a></remarks>
|
||||
public abstract class UserStatus : IObject { }
|
||||
public abstract partial class UserStatus : IObject { }
|
||||
/// <summary>Online status of the user. <para>See <a href="https://corefork.telegram.org/constructor/userStatusOnline"/></para></summary>
|
||||
[TLDef(0xEDB93949)]
|
||||
public class UserStatusOnline : UserStatus
|
||||
public partial class UserStatusOnline : UserStatus
|
||||
{
|
||||
/// <summary>Time to expiration of the current online status</summary>
|
||||
public DateTime expires;
|
||||
}
|
||||
/// <summary>The user's offline status. <para>See <a href="https://corefork.telegram.org/constructor/userStatusOffline"/></para></summary>
|
||||
[TLDef(0x008C703F)]
|
||||
public class UserStatusOffline : UserStatus
|
||||
public partial class UserStatusOffline : UserStatus
|
||||
{
|
||||
/// <summary>Time the user was last seen online</summary>
|
||||
public int was_online;
|
||||
}
|
||||
/// <summary>Online status: last seen recently <para>See <a href="https://corefork.telegram.org/constructor/userStatusRecently"/></para></summary>
|
||||
[TLDef(0xE26F42F1)]
|
||||
public class UserStatusRecently : UserStatus { }
|
||||
public partial class UserStatusRecently : UserStatus { }
|
||||
/// <summary>Online status: last seen last week <para>See <a href="https://corefork.telegram.org/constructor/userStatusLastWeek"/></para></summary>
|
||||
[TLDef(0x07BF09FC)]
|
||||
public class UserStatusLastWeek : UserStatus { }
|
||||
public partial class UserStatusLastWeek : UserStatus { }
|
||||
/// <summary>Online status: last seen last month <para>See <a href="https://corefork.telegram.org/constructor/userStatusLastMonth"/></para></summary>
|
||||
[TLDef(0x77EBC742)]
|
||||
public class UserStatusLastMonth : UserStatus { }
|
||||
public partial class UserStatusLastMonth : UserStatus { }
|
||||
|
||||
/// <summary>Object defines a group. <para>Derived classes: <see cref="ChatEmpty"/>, <see cref="Chat"/>, <see cref="ChatForbidden"/>, <see cref="Channel"/>, <see cref="ChannelForbidden"/></para> <para>See <a href="https://corefork.telegram.org/type/Chat"/></para></summary>
|
||||
public abstract partial class ChatBase : IObject
|
||||
|
|
@ -6174,7 +6174,7 @@ namespace TL
|
|||
}
|
||||
/// <summary>Represents a channel <para>See <a href="https://corefork.telegram.org/constructor/inputChannel"/></para></summary>
|
||||
[TLDef(0xF35AEC28)]
|
||||
public class InputChannel : InputChannelBase
|
||||
public partial class InputChannel : InputChannelBase
|
||||
{
|
||||
/// <summary>Channel ID</summary>
|
||||
public long channel_id;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue