More helpers

This commit is contained in:
Wizou 2021-12-22 04:46:01 +01:00
parent a4f6d00bd0
commit 35cd3b682e
3 changed files with 74 additions and 7 deletions

2
.github/dev.yml vendored
View file

@ -2,7 +2,7 @@ pr: none
trigger: trigger:
- master - master
name: 1.8.1-dev.$(Rev:r) name: 1.8.2-dev.$(Rev:r)
pool: pool:
vmImage: ubuntu-latest vmImage: ubuntu-latest

View file

@ -15,9 +15,10 @@ namespace TL
} }
partial class InputPeer { public static InputPeerSelf Self => new(); } partial class InputPeer { public static InputPeerSelf Self => new(); }
partial class InputPeerUser { public static implicit operator InputUser(InputPeerUser user) => new() { user_id = user.user_id, access_hash = user.access_hash }; }
partial class InputPeerChannel { public static implicit operator InputChannel(InputPeerChannel channel) => new() { channel_id = channel.channel_id, access_hash = channel.access_hash }; }
partial class InputUser { public static InputUserSelf Self => new(); } partial class InputUser { public static InputUserSelf Self => new(); }
partial class InputPeerChannel { public static implicit operator InputChannel(InputPeerChannel channel) => new() { channel_id = channel.channel_id, access_hash = channel.access_hash }; }
partial class InputPeerUser { public static implicit operator InputUser(InputPeerUser user) => new() { user_id = user.user_id, access_hash = user.access_hash }; }
partial class InputUser { public static implicit operator InputPeerUser(InputUser user) => new() { user_id = user.user_id, access_hash = user.access_hash }; }
partial class InputFileBase partial class InputFileBase
{ {
@ -64,9 +65,9 @@ namespace TL
public abstract long ID { get; } public abstract long ID { get; }
public abstract bool IsActive { get; } public abstract bool IsActive { get; }
public abstract InputPeer ToInputPeer(); public abstract InputPeer ToInputPeer();
protected abstract InputUserBase ToInputUser(); protected abstract InputUser ToInputUser();
public static implicit operator InputPeer(UserBase user) => user.ToInputPeer(); public static implicit operator InputPeer(UserBase user) => user.ToInputPeer();
public static implicit operator InputUserBase(UserBase user) => user.ToInputUser(); public static implicit operator InputUser(UserBase user) => user.ToInputUser();
} }
partial class UserEmpty partial class UserEmpty
{ {
@ -74,7 +75,7 @@ namespace TL
public override bool IsActive => false; public override bool IsActive => false;
public override string ToString() => null; public override string ToString() => null;
public override InputPeer ToInputPeer() => null; public override InputPeer ToInputPeer() => null;
protected override InputUserBase ToInputUser() => null; protected override InputUser ToInputUser() => null;
} }
partial class User partial class User
{ {
@ -82,7 +83,7 @@ namespace TL
public override bool IsActive => (flags & Flags.deleted) == 0; public override bool IsActive => (flags & Flags.deleted) == 0;
public override string ToString() => username != null ? '@' + username : last_name == null ? first_name : $"{first_name} {last_name}"; 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 }; 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 }; protected override InputUser ToInputUser() => new() { 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> /// <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); public TimeSpan LastSeenAgo => status?.LastSeenAgo ?? TimeSpan.FromDays(150);
} }

View file

@ -1040,10 +1040,28 @@ namespace TL
public abstract long ID { get; } public abstract long ID { get; }
/// <summary>About string for this chat</summary> /// <summary>About string for this chat</summary>
public abstract string About { get; } public abstract string About { get; }
/// <summary>Chat photo</summary>
public abstract PhotoBase ChatPhoto { get; }
/// <summary>Notification settings</summary> /// <summary>Notification settings</summary>
public abstract PeerNotifySettings NotifySettings { get; } public abstract PeerNotifySettings NotifySettings { get; }
/// <summary>Chat invite</summary>
public abstract ExportedChatInvite ExportedInvite { get; }
/// <summary>Info about bots that are in this chat</summary>
public abstract BotInfo[] BotInfo { get; }
/// <summary>Message ID of the last <a href="https://corefork.telegram.org/api/pin">pinned message</a></summary>
public abstract int PinnedMsg { get; }
/// <summary><a href="https://corefork.telegram.org/api/folders#peer-folders">Peer folder ID, for more info click here</a></summary> /// <summary><a href="https://corefork.telegram.org/api/folders#peer-folders">Peer folder ID, for more info click here</a></summary>
public abstract int Folder { get; } public abstract int Folder { get; }
/// <summary>Group call information</summary>
public abstract InputGroupCall Call { get; }
/// <summary>Time-To-Live of messages sent by the current user to this chat</summary>
public abstract int TtlPeriod { get; }
/// <summary>When using <a href="https://corefork.telegram.org/method/phone.getGroupCallJoinAs">phone.getGroupCallJoinAs</a> to get a list of peers that can be used to join a group call, this field indicates the peer that should be selected by default.</summary>
public abstract Peer GroupcallDefaultJoinAs { get; }
/// <summary>Emoji representing a specific chat theme</summary>
public abstract string ThemeEmoticon { get; }
public abstract int RequestsPending { get; }
public abstract long[] RecentRequesters { get; }
} }
/// <summary>Detailed chat info <para>See <a href="https://corefork.telegram.org/constructor/chatFull"/></para></summary> /// <summary>Detailed chat info <para>See <a href="https://corefork.telegram.org/constructor/chatFull"/></para></summary>
[TLDef(0x46A6FFB4)] [TLDef(0x46A6FFB4)]
@ -1112,10 +1130,28 @@ namespace TL
public override long ID => id; public override long ID => id;
/// <summary>About string for this chat</summary> /// <summary>About string for this chat</summary>
public override string About => about; public override string About => about;
/// <summary>Chat photo</summary>
public override PhotoBase ChatPhoto => chat_photo;
/// <summary>Notification settings</summary> /// <summary>Notification settings</summary>
public override PeerNotifySettings NotifySettings => notify_settings; public override PeerNotifySettings NotifySettings => notify_settings;
/// <summary>Chat invite</summary>
public override ExportedChatInvite ExportedInvite => exported_invite;
/// <summary>Info about bots that are in this chat</summary>
public override BotInfo[] BotInfo => bot_info;
/// <summary>Message ID of the last <a href="https://corefork.telegram.org/api/pin">pinned message</a></summary>
public override int PinnedMsg => pinned_msg_id;
/// <summary><a href="https://corefork.telegram.org/api/folders#peer-folders">Peer folder ID, for more info click here</a></summary> /// <summary><a href="https://corefork.telegram.org/api/folders#peer-folders">Peer folder ID, for more info click here</a></summary>
public override int Folder => folder_id; public override int Folder => folder_id;
/// <summary>Group call information</summary>
public override InputGroupCall Call => call;
/// <summary>Time-To-Live of messages sent by the current user to this chat</summary>
public override int TtlPeriod => ttl_period;
/// <summary>When using <a href="https://corefork.telegram.org/method/phone.getGroupCallJoinAs">phone.getGroupCallJoinAs</a> to get a list of peers that can be used to join a group call, this field indicates the peer that should be selected by default.</summary>
public override Peer GroupcallDefaultJoinAs => groupcall_default_join_as;
/// <summary>Emoji representing a specific chat theme</summary>
public override string ThemeEmoticon => theme_emoticon;
public override int RequestsPending => requests_pending;
public override long[] RecentRequesters => recent_requesters;
} }
/// <summary>Full info about a <a href="https://corefork.telegram.org/api/channel">channel/supergroup</a> <para>See <a href="https://corefork.telegram.org/constructor/channelFull"/></para></summary> /// <summary>Full info about a <a href="https://corefork.telegram.org/api/channel">channel/supergroup</a> <para>See <a href="https://corefork.telegram.org/constructor/channelFull"/></para></summary>
[TLDef(0x56662E2E)] [TLDef(0x56662E2E)]
@ -1257,10 +1293,28 @@ namespace TL
public override long ID => id; public override long ID => id;
/// <summary>Info about the channel</summary> /// <summary>Info about the channel</summary>
public override string About => about; public override string About => about;
/// <summary>Channel picture</summary>
public override PhotoBase ChatPhoto => chat_photo;
/// <summary>Notification settings</summary> /// <summary>Notification settings</summary>
public override PeerNotifySettings NotifySettings => notify_settings; public override PeerNotifySettings NotifySettings => notify_settings;
/// <summary>Invite link</summary>
public override ExportedChatInvite ExportedInvite => exported_invite;
/// <summary>Info about bots in the channel/supergrup</summary>
public override BotInfo[] BotInfo => bot_info;
/// <summary>Message ID of the last <a href="https://corefork.telegram.org/api/pin">pinned message</a></summary>
public override int PinnedMsg => pinned_msg_id;
/// <summary><a href="https://corefork.telegram.org/api/folders#peer-folders">Peer folder ID, for more info click here</a></summary> /// <summary><a href="https://corefork.telegram.org/api/folders#peer-folders">Peer folder ID, for more info click here</a></summary>
public override int Folder => folder_id; public override int Folder => folder_id;
/// <summary>Livestream or group call information</summary>
public override InputGroupCall Call => call;
/// <summary>Time-To-Live of messages in this channel or supergroup</summary>
public override int TtlPeriod => ttl_period;
/// <summary>When using <a href="https://corefork.telegram.org/method/phone.getGroupCallJoinAs">phone.getGroupCallJoinAs</a> to get a list of peers that can be used to join a group call, this field indicates the peer that should be selected by default.</summary>
public override Peer GroupcallDefaultJoinAs => groupcall_default_join_as;
/// <summary>Emoji representing a specific chat theme</summary>
public override string ThemeEmoticon => theme_emoticon;
public override int RequestsPending => requests_pending;
public override long[] RecentRequesters => recent_requesters;
} }
/// <summary>Details of a group member. <para>Derived classes: <see cref="ChatParticipant"/>, <see cref="ChatParticipantCreator"/>, <see cref="ChatParticipantAdmin"/></para> <para>See <a href="https://corefork.telegram.org/type/ChatParticipant"/></para></summary> /// <summary>Details of a group member. <para>Derived classes: <see cref="ChatParticipant"/>, <see cref="ChatParticipantCreator"/>, <see cref="ChatParticipantAdmin"/></para> <para>See <a href="https://corefork.telegram.org/type/ChatParticipant"/></para></summary>
@ -6989,6 +7043,10 @@ namespace TL
public abstract string ID { get; } public abstract string ID { get; }
/// <summary>Result type (see <a href="https://corefork.telegram.org/bots/api#inlinequeryresult">bot API docs</a>)</summary> /// <summary>Result type (see <a href="https://corefork.telegram.org/bots/api#inlinequeryresult">bot API docs</a>)</summary>
public abstract string Type { get; } public abstract string Type { get; }
/// <summary>Result title</summary>
public abstract string Title { get; }
/// <summary>Result description</summary>
public abstract string Description { get; }
/// <summary>Message to send</summary> /// <summary>Message to send</summary>
public abstract BotInlineMessage SendMessage { get; } public abstract BotInlineMessage SendMessage { get; }
} }
@ -7033,6 +7091,10 @@ namespace TL
public override string ID => id; public override string ID => id;
/// <summary>Result type (see <a href="https://corefork.telegram.org/bots/api#inlinequeryresult">bot API docs</a>)</summary> /// <summary>Result type (see <a href="https://corefork.telegram.org/bots/api#inlinequeryresult">bot API docs</a>)</summary>
public override string Type => type; public override string Type => type;
/// <summary>Result title</summary>
public override string Title => title;
/// <summary>Result description</summary>
public override string Description => description;
/// <summary>Message to send</summary> /// <summary>Message to send</summary>
public override BotInlineMessage SendMessage => send_message; public override BotInlineMessage SendMessage => send_message;
} }
@ -7073,6 +7135,10 @@ namespace TL
public override string ID => id; public override string ID => id;
/// <summary>Result type (see <a href="https://corefork.telegram.org/bots/api#inlinequeryresult">bot API docs</a>)</summary> /// <summary>Result type (see <a href="https://corefork.telegram.org/bots/api#inlinequeryresult">bot API docs</a>)</summary>
public override string Type => type; public override string Type => type;
/// <summary>Result title</summary>
public override string Title => title;
/// <summary>Description</summary>
public override string Description => description;
/// <summary>Depending on the <c>type</c> and on the <see cref="BotInlineMessage"/>, contains the caption of the media or the content of the message to be sent <strong>instead</strong> of the media</summary> /// <summary>Depending on the <c>type</c> and on the <see cref="BotInlineMessage"/>, contains the caption of the media or the content of the message to be sent <strong>instead</strong> of the media</summary>
public override BotInlineMessage SendMessage => send_message; public override BotInlineMessage SendMessage => send_message;
} }