Skip to content

Commit

Permalink
Some more implicit Input conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
wiz0u committed Oct 9, 2023
1 parent 2b7868e commit fb8d1c2
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/dev.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pr: none
trigger: [ master ]

name: 3.5.7-dev.$(Rev:r)
name: 3.5.8-dev.$(Rev:r)

pool:
vmImage: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions src/Client.Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ public async Task<UpdatesBase> DeleteChat(InputPeer peer)
}

/// <summary>If you want to get all messages from a chat, use method Messages_GetHistory</summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1822")]
public Task<Messages_MessagesBase> GetMessages(InputPeer peer)
=> throw new WTException("If you want to get all messages from a chat, use method Messages_GetHistory");

Expand Down
9 changes: 9 additions & 0 deletions src/TL.Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,13 @@ partial class GeoPoint
public static implicit operator InputGeoPoint(GeoPoint geo) => new() { lat = geo.lat, lon = geo.lon, accuracy_radius = geo.accuracy_radius, flags = (InputGeoPoint.Flags)geo.flags };
}

partial class InputNotifyPeerBase
{
public static implicit operator InputNotifyPeerBase(InputPeer peer) => new InputNotifyPeer { peer = peer };
public static implicit operator InputNotifyPeerBase(ChatBase chat) => new InputNotifyPeer { peer = chat };
public static implicit operator InputNotifyPeerBase(UserBase user) => new InputNotifyPeer { peer = user };
}

partial class WallPaperBase { public static implicit operator InputWallPaperBase(WallPaperBase wp) => wp.ToInputWallPaper();
protected abstract InputWallPaperBase ToInputWallPaper(); }
partial class WallPaper { protected override InputWallPaperBase ToInputWallPaper() => new InputWallPaper { id = id, access_hash = access_hash }; }
Expand Down Expand Up @@ -620,6 +627,8 @@ partial class InputMessage
partial class InputDialogPeerBase
{
public static implicit operator InputDialogPeerBase(InputPeer peer) => new InputDialogPeer { peer = peer };
public static implicit operator InputDialogPeerBase(ChatBase chat) => new InputDialogPeer { peer = chat };
public static implicit operator InputDialogPeerBase(UserBase user) => new InputDialogPeer { peer = user };
}

partial class SecureFile
Expand Down
42 changes: 31 additions & 11 deletions src/TL.Schema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2677,7 +2677,7 @@ public class Auth_ExportedAuthorization : IObject
}

/// <summary>Object defines the set of users and/or groups that generate notifications. <para>See <a href="https://corefork.telegram.org/type/InputNotifyPeer"/></para> <para>Derived classes: <see cref="InputNotifyPeer"/>, <see cref="InputNotifyUsers"/>, <see cref="InputNotifyChats"/>, <see cref="InputNotifyBroadcasts"/>, <see cref="InputNotifyForumTopic"/></para></summary>
public abstract class InputNotifyPeerBase : IObject { }
public abstract partial class InputNotifyPeerBase : IObject { }
/// <summary>Notifications generated by a certain user or group. <para>See <a href="https://corefork.telegram.org/constructor/inputNotifyPeer"/></para></summary>
[TLDef(0xB8BC5B0C)]
public class InputNotifyPeer : InputNotifyPeerBase
Expand Down Expand Up @@ -4687,10 +4687,11 @@ public class UpdateStoryID : Update
public int id;
public long random_id;
}
/// <summary><para>See <a href="https://corefork.telegram.org/constructor/updateStoriesStealthMode"/></para></summary>
/// <summary>Indicates that <a href="https://corefork.telegram.org/api/stories#stealth-mode">stories stealth mode</a> was activated. <para>See <a href="https://corefork.telegram.org/constructor/updateStoriesStealthMode"/></para></summary>
[TLDef(0x2C084DC1)]
public class UpdateStoriesStealthMode : Update
{
/// <summary>Information about the current <a href="https://corefork.telegram.org/api/stories#stealth-mode">stealth mode</a> session.</summary>
public StoriesStealthMode stealth_mode;
}
/// <summary><para>See <a href="https://corefork.telegram.org/constructor/updateSentStoryReaction"/></para></summary>
Expand Down Expand Up @@ -11713,8 +11714,11 @@ public class ChatAdminRights : IObject
other = 0x1000,
/// <summary>If set, allows the admin to create, delete or modify <a href="https://corefork.telegram.org/api/forum#forum-topics">forum topics »</a>.</summary>
manage_topics = 0x2000,
/// <summary>If set, allows the admin to post <a href="https://corefork.telegram.org/api/stories#channel-stories">stories</a> as the <a href="https://corefork.telegram.org/api/channel">channel</a>.</summary>
post_stories = 0x4000,
/// <summary>If set, allows the admin to edit <a href="https://corefork.telegram.org/api/stories#channel-stories">stories</a> posted by the other admins of the <a href="https://corefork.telegram.org/api/channel">channel</a>.</summary>
edit_stories = 0x8000,
/// <summary>If set, allows the admin to delete <a href="https://corefork.telegram.org/api/stories#channel-stories">stories</a> posted by the other admins of the <a href="https://corefork.telegram.org/api/channel">channel</a>.</summary>
delete_stories = 0x10000,
}
}
Expand Down Expand Up @@ -12190,7 +12194,7 @@ public abstract class Auth_LoginTokenBase : IObject { }
[TLDef(0x629F1980)]
public class Auth_LoginToken : Auth_LoginTokenBase
{
/// <summary>Expiry date of QR code</summary>
/// <summary>Expiration date of QR code</summary>
public DateTime expires;
/// <summary>Token to render in QR code</summary>
public byte[] token;
Expand Down Expand Up @@ -14572,7 +14576,7 @@ public class ExportedContactToken : IObject
{
/// <summary>The <a href="https://corefork.telegram.org/api/links#temporary-profile-links">temporary profile link</a>.</summary>
public string url;
/// <summary>Its expiry date</summary>
/// <summary>Its expiration date</summary>
public DateTime expires;
}

Expand Down Expand Up @@ -15293,13 +15297,15 @@ public class ExportedStoryLink : IObject
public string link;
}

/// <summary><para>See <a href="https://corefork.telegram.org/constructor/storiesStealthMode"/></para></summary>
/// <summary>Information about the current <a href="https://corefork.telegram.org/api/stories#stealth-mode">stealth mode</a> session. <para>See <a href="https://corefork.telegram.org/constructor/storiesStealthMode"/></para></summary>
[TLDef(0x712E27FD)]
public class StoriesStealthMode : IObject
{
/// <summary>Extra bits of information, use <c>flags.HasFlag(...)</c> to test for those</summary>
public Flags flags;
/// <summary>The date up to which stealth mode will be active.</summary>
[IfFlag(0)] public DateTime active_until_date;
/// <summary>The date starting from which the user will be allowed to re-enable stealth mode again.</summary>
[IfFlag(1)] public DateTime cooldown_until_date;

[Flags] public enum Flags : uint
Expand Down Expand Up @@ -15395,16 +15401,21 @@ public class Stories_PeerStories : IObject, IPeerResolver
public IPeerInfo UserOrChat(Peer peer) => peer?.UserOrChat(users, chats);
}

/// <summary><para>See <a href="https://corefork.telegram.org/constructor/stories.boostsStatus"/></para></summary>
/// <summary>The current <a href="https://corefork.telegram.org/api/stories#boosts">boost status »</a> of a channel. <para>See <a href="https://corefork.telegram.org/constructor/stories.boostsStatus"/></para></summary>
[TLDef(0xE5C1AA5C)]
public class Stories_BoostsStatus : IObject
{
/// <summary>Extra bits of information, use <c>flags.HasFlag(...)</c> to test for those</summary>
public Flags flags;
/// <summary>The current boost level of the channel.</summary>
public int level;
/// <summary>The number of boosts acquired so far in the current level.</summary>
public int current_level_boosts;
/// <summary>Total number of boosts acquired so far.</summary>
public int boosts;
/// <summary>Total number of boosts needed to reach the next level; if absent, the next level isn't available.</summary>
[IfFlag(0)] public int next_level_boosts;
/// <summary>Only returned to channel admins: contains the approximated number of Premium users subscribed to the channel, related to the total number of subscribers.</summary>
[IfFlag(1)] public StatsPercentValue premium_audience;
public string boost_url;

Expand All @@ -15414,40 +15425,49 @@ public class Stories_BoostsStatus : IObject
has_next_level_boosts = 0x1,
/// <summary>Field <see cref="premium_audience"/> has a value</summary>
has_premium_audience = 0x2,
/// <summary>Whether we're currently boosting this channel.</summary>
my_boost = 0x4,
}
}

/// <summary><para>See <a href="https://corefork.telegram.org/type/stories.CanApplyBoostResult"/></para> <para>Derived classes: <see cref="Stories_CanApplyBoostOk"/>, <see cref="Stories_CanApplyBoostReplace"/></para></summary>
/// <summary>Whether the specified channel can be <a href="https://corefork.telegram.org/api/stories#boosts">boosted, see here for more info »</a>. <para>See <a href="https://corefork.telegram.org/type/stories.CanApplyBoostResult"/></para> <para>Derived classes: <see cref="Stories_CanApplyBoostOk"/>, <see cref="Stories_CanApplyBoostReplace"/></para></summary>
public abstract class Stories_CanApplyBoostResult : IObject { }
/// <summary><para>See <a href="https://corefork.telegram.org/constructor/stories.canApplyBoostOk"/></para></summary>
/// <summary>We're not boosting any channel, and we can freely boost the specified channel. <para>See <a href="https://corefork.telegram.org/constructor/stories.canApplyBoostOk"/></para></summary>
[TLDef(0xC3173587)]
public class Stories_CanApplyBoostOk : Stories_CanApplyBoostResult { }
/// <summary><para>See <a href="https://corefork.telegram.org/constructor/stories.canApplyBoostReplace"/></para></summary>
/// <summary>We're boosting another channel, but we can freely boost the specified channel. <para>See <a href="https://corefork.telegram.org/constructor/stories.canApplyBoostReplace"/></para></summary>
[TLDef(0x712C4655)]
public class Stories_CanApplyBoostReplace : Stories_CanApplyBoostResult
{
/// <summary>The channel we're currently boosting.</summary>
public Peer current_boost;
/// <summary>Channel information.</summary>
public Dictionary<long, ChatBase> chats;
}

/// <summary><para>See <a href="https://corefork.telegram.org/constructor/booster"/></para></summary>
/// <summary>Info about a <a href="https://corefork.telegram.org/api/stories#boosts">boost</a> made by a specific user. <para>See <a href="https://corefork.telegram.org/constructor/booster"/></para></summary>
[TLDef(0x0E9E6380)]
public class Booster : IObject
{
/// <summary>ID of the user that made the boost.</summary>
public long user_id;
/// <summary>Default expiration date of the boost.</summary>
public DateTime expires;
}

/// <summary><para>See <a href="https://corefork.telegram.org/constructor/stories.boostersList"/></para></summary>
/// <summary>Info about the users currently <a href="https://corefork.telegram.org/api/stories#boosts">boosting</a> the channel. <para>See <a href="https://corefork.telegram.org/constructor/stories.boostersList"/></para></summary>
[TLDef(0xF3DD3D1D)]
public class Stories_BoostersList : IObject
{
/// <summary>Extra bits of information, use <c>flags.HasFlag(...)</c> to test for those</summary>
public Flags flags;
/// <summary>Total number of boosters.</summary>
public int count;
/// <summary>Info about the automatic expiration date of every user's boost.</summary>
public Booster[] boosters;
/// <summary>Next offset for <a href="https://corefork.telegram.org/api/offsets">pagination</a>.</summary>
[IfFlag(0)] public string next_offset;
/// <summary>Info about the users mentioned in the <c>boosters</c> field.</summary>
public Dictionary<long, User> users;

[Flags] public enum Flags : uint
Expand Down
Loading

0 comments on commit fb8d1c2

Please sign in to comment.