added some helpers

This commit is contained in:
Wizou 2023-04-21 16:31:57 +02:00
parent d53dc5f07c
commit 22e64ea3ee
3 changed files with 11 additions and 4 deletions

View file

@ -492,6 +492,13 @@ namespace TL
public static implicit operator InputStickerSetID(StickerSet stickerSet) => new() { id = stickerSet.id, access_hash = stickerSet.access_hash }; public static implicit operator InputStickerSetID(StickerSet stickerSet) => new() { id = stickerSet.id, access_hash = stickerSet.access_hash };
} }
partial class MessageEntity
{
public string Type { get { var name = GetType().Name; return name[(name.IndexOf("MessageEntity") + 13)..]; } }
public int Offset { get => offset; set => offset = value; }
public int Length { get => length; set => length = value; }
}
partial class InputChannel partial class InputChannel
{ {
/// <param name="channel_id">Channel identifier</param> /// <param name="channel_id">Channel identifier</param>

View file

@ -6754,7 +6754,7 @@ namespace TL
} }
/// <summary>Message entities, representing styled text in a message <para>See <a href="https://corefork.telegram.org/type/MessageEntity"/></para> <para>Derived classes: <see cref="MessageEntityUnknown"/>, <see cref="MessageEntityMention"/>, <see cref="MessageEntityHashtag"/>, <see cref="MessageEntityBotCommand"/>, <see cref="MessageEntityUrl"/>, <see cref="MessageEntityEmail"/>, <see cref="MessageEntityBold"/>, <see cref="MessageEntityItalic"/>, <see cref="MessageEntityCode"/>, <see cref="MessageEntityPre"/>, <see cref="MessageEntityTextUrl"/>, <see cref="MessageEntityMentionName"/>, <see cref="InputMessageEntityMentionName"/>, <see cref="MessageEntityPhone"/>, <see cref="MessageEntityCashtag"/>, <see cref="MessageEntityUnderline"/>, <see cref="MessageEntityStrike"/>, <see cref="MessageEntityBlockquote"/>, <see cref="MessageEntityBankCard"/>, <see cref="MessageEntitySpoiler"/>, <see cref="MessageEntityCustomEmoji"/></para></summary> /// <summary>Message entities, representing styled text in a message <para>See <a href="https://corefork.telegram.org/type/MessageEntity"/></para> <para>Derived classes: <see cref="MessageEntityUnknown"/>, <see cref="MessageEntityMention"/>, <see cref="MessageEntityHashtag"/>, <see cref="MessageEntityBotCommand"/>, <see cref="MessageEntityUrl"/>, <see cref="MessageEntityEmail"/>, <see cref="MessageEntityBold"/>, <see cref="MessageEntityItalic"/>, <see cref="MessageEntityCode"/>, <see cref="MessageEntityPre"/>, <see cref="MessageEntityTextUrl"/>, <see cref="MessageEntityMentionName"/>, <see cref="InputMessageEntityMentionName"/>, <see cref="MessageEntityPhone"/>, <see cref="MessageEntityCashtag"/>, <see cref="MessageEntityUnderline"/>, <see cref="MessageEntityStrike"/>, <see cref="MessageEntityBlockquote"/>, <see cref="MessageEntityBankCard"/>, <see cref="MessageEntitySpoiler"/>, <see cref="MessageEntityCustomEmoji"/></para></summary>
public abstract class MessageEntity : IObject public abstract partial class MessageEntity : IObject
{ {
/// <summary>Offset of message entity within message (in <a href="https://corefork.telegram.org/api/entities#entity-length">UTF-16 code units</a>)</summary> /// <summary>Offset of message entity within message (in <a href="https://corefork.telegram.org/api/entities#entity-length">UTF-16 code units</a>)</summary>
public int offset; public int offset;

View file

@ -42,9 +42,9 @@ namespace TL
public Exception Exception; public Exception Exception;
} }
internal static class Serialization public static class Serialization
{ {
internal static void WriteTLObject<T>(this BinaryWriter writer, T obj) where T : IObject public static void WriteTLObject<T>(this BinaryWriter writer, T obj) where T : IObject
{ {
if (obj == null) { writer.WriteTLNull(typeof(T)); return; } if (obj == null) { writer.WriteTLNull(typeof(T)); return; }
var type = obj.GetType(); var type = obj.GetType();
@ -66,7 +66,7 @@ namespace TL
} }
} }
internal static IObject ReadTLObject(this BinaryReader reader, uint ctorNb = 0) public static IObject ReadTLObject(this BinaryReader reader, uint ctorNb = 0)
{ {
if (ctorNb == 0) ctorNb = reader.ReadUInt32(); if (ctorNb == 0) ctorNb = reader.ReadUInt32();
if (ctorNb == Layer.GZipedCtor) if (ctorNb == Layer.GZipedCtor)