2021-09-25 02:13:06 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Globalization;
|
2021-09-23 09:29:19 +02:00
|
|
|
|
using System.Linq;
|
2021-08-19 06:56:55 +02:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Web;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TL
|
2021-08-10 03:12:33 +02:00
|
|
|
|
{
|
2021-08-25 12:53:36 +02:00
|
|
|
|
partial class InputPeer { public static InputPeerSelf Self => new(); }
|
2021-08-16 05:56:39 +02:00
|
|
|
|
partial class InputUser { public static InputUserSelf Self => new(); }
|
2021-08-10 03:12:33 +02:00
|
|
|
|
|
|
|
|
|
|
partial class ChatBase
|
|
|
|
|
|
{
|
2021-09-17 03:58:52 +02:00
|
|
|
|
public abstract long ID { get; }
|
2021-08-10 03:12:33 +02:00
|
|
|
|
public abstract string Title { get; }
|
2021-08-14 15:15:41 +02:00
|
|
|
|
/// <summary>returns true if you're banned of any of these rights</summary>
|
2021-08-14 08:55:30 +02:00
|
|
|
|
public abstract bool IsBanned(ChatBannedRights.Flags flags = 0);
|
2021-08-10 03:12:33 +02:00
|
|
|
|
protected abstract InputPeer ToInputPeer();
|
|
|
|
|
|
public static implicit operator InputPeer(ChatBase chat) => chat.ToInputPeer();
|
|
|
|
|
|
}
|
|
|
|
|
|
partial class ChatEmpty
|
|
|
|
|
|
{
|
2021-09-17 03:58:52 +02:00
|
|
|
|
public override long ID => id;
|
2021-08-10 03:12:33 +02:00
|
|
|
|
public override string Title => null;
|
2021-08-14 08:55:30 +02:00
|
|
|
|
public override bool IsBanned(ChatBannedRights.Flags flags = 0) => true;
|
2021-09-30 03:40:08 +02:00
|
|
|
|
protected override InputPeer ToInputPeer() => null;
|
2021-10-01 02:22:26 +02:00
|
|
|
|
public override string ToString() => $"ChatEmpty {id}";
|
2021-08-10 03:12:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
partial class Chat
|
|
|
|
|
|
{
|
2021-09-17 03:58:52 +02:00
|
|
|
|
public override long ID => id;
|
2021-08-10 03:12:33 +02:00
|
|
|
|
public override string Title => title;
|
2021-08-14 08:55:30 +02:00
|
|
|
|
public override bool IsBanned(ChatBannedRights.Flags flags = 0) => ((default_banned_rights?.flags ?? 0) & flags) != 0;
|
2021-08-10 03:12:33 +02:00
|
|
|
|
protected override InputPeer ToInputPeer() => new InputPeerChat { chat_id = id };
|
2021-10-01 02:22:26 +02:00
|
|
|
|
public override string ToString() => $"Chat \"{title}\"";
|
2021-08-10 03:12:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
partial class ChatForbidden
|
|
|
|
|
|
{
|
2021-09-17 03:58:52 +02:00
|
|
|
|
public override long ID => id;
|
2021-08-10 03:12:33 +02:00
|
|
|
|
public override string Title => title;
|
2021-08-14 08:55:30 +02:00
|
|
|
|
public override bool IsBanned(ChatBannedRights.Flags flags = 0) => true;
|
2021-08-10 03:12:33 +02:00
|
|
|
|
protected override InputPeer ToInputPeer() => new InputPeerChat { chat_id = id };
|
2021-10-01 02:22:26 +02:00
|
|
|
|
public override string ToString() => $"ChatForbidden {id} \"{title}\"";
|
2021-08-10 03:12:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
partial class Channel
|
|
|
|
|
|
{
|
2021-09-17 03:58:52 +02:00
|
|
|
|
public override long ID => id;
|
2021-08-10 03:12:33 +02:00
|
|
|
|
public override string Title => title;
|
2021-08-14 08:55:30 +02:00
|
|
|
|
public override bool IsBanned(ChatBannedRights.Flags flags = 0) => ((banned_rights?.flags ?? 0) & flags) != 0 || ((default_banned_rights?.flags ?? 0) & flags) != 0;
|
2021-08-10 03:12:33 +02:00
|
|
|
|
protected override InputPeer ToInputPeer() => new InputPeerChannel { channel_id = id, access_hash = access_hash };
|
|
|
|
|
|
public static implicit operator InputChannel(Channel channel) => new() { channel_id = channel.id, access_hash = channel.access_hash };
|
2021-10-01 02:22:26 +02:00
|
|
|
|
public override string ToString() =>
|
|
|
|
|
|
(flags.HasFlag(Flags.broadcast) ? "Channel " : "Group ") + (username != null ? '@' + username : $"\"{title}\"");
|
2021-08-10 03:12:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
partial class ChannelForbidden
|
|
|
|
|
|
{
|
2021-09-17 03:58:52 +02:00
|
|
|
|
public override long ID => id;
|
2021-08-10 03:12:33 +02:00
|
|
|
|
public override string Title => title;
|
2021-08-14 08:55:30 +02:00
|
|
|
|
public override bool IsBanned(ChatBannedRights.Flags flags = 0) => true;
|
2021-08-10 03:12:33 +02:00
|
|
|
|
protected override InputPeer ToInputPeer() => new InputPeerChannel { channel_id = id, access_hash = access_hash };
|
2021-10-01 02:22:26 +02:00
|
|
|
|
public override string ToString() => $"ChannelForbidden {id} \"{title}\"";
|
2021-08-10 03:12:33 +02:00
|
|
|
|
}
|
2021-08-16 05:56:39 +02:00
|
|
|
|
|
2021-08-10 03:12:33 +02:00
|
|
|
|
partial class UserBase
|
|
|
|
|
|
{
|
2021-09-17 03:58:52 +02:00
|
|
|
|
public abstract long ID { get; }
|
2021-08-10 03:12:33 +02:00
|
|
|
|
protected abstract InputPeer ToInputPeer();
|
|
|
|
|
|
protected abstract InputUserBase ToInputUser();
|
|
|
|
|
|
public static implicit operator InputPeer(UserBase user) => user.ToInputPeer();
|
|
|
|
|
|
public static implicit operator InputUserBase(UserBase user) => user.ToInputUser();
|
|
|
|
|
|
}
|
|
|
|
|
|
partial class UserEmpty
|
|
|
|
|
|
{
|
2021-09-17 03:58:52 +02:00
|
|
|
|
public override long ID => id;
|
2021-10-17 03:16:51 +02:00
|
|
|
|
public override string ToString() => null;
|
2021-09-30 03:40:08 +02:00
|
|
|
|
protected override InputPeer ToInputPeer() => null;
|
|
|
|
|
|
protected override InputUserBase ToInputUser() => null;
|
2021-08-10 03:12:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
partial class User
|
|
|
|
|
|
{
|
2021-09-17 03:58:52 +02:00
|
|
|
|
public override long ID => id;
|
2021-10-17 03:16:51 +02:00
|
|
|
|
public override string ToString() => username != null ? '@' + username : last_name == null ? first_name : $"{first_name} {last_name}";
|
2021-08-10 03:12:33 +02:00
|
|
|
|
protected 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 };
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-09-25 02:13:06 +02:00
|
|
|
|
partial class MessageBase
|
|
|
|
|
|
{
|
2021-10-16 02:01:49 +02:00
|
|
|
|
public abstract int ID { get; }
|
2021-09-25 02:13:06 +02:00
|
|
|
|
public abstract Peer Peer { get; }
|
|
|
|
|
|
public abstract DateTime Date { get; }
|
|
|
|
|
|
}
|
|
|
|
|
|
partial class MessageEmpty
|
|
|
|
|
|
{
|
2021-10-16 02:01:49 +02:00
|
|
|
|
public override int ID => id;
|
2021-09-25 02:13:06 +02:00
|
|
|
|
public override Peer Peer => peer_id;
|
|
|
|
|
|
public override DateTime Date => default;
|
|
|
|
|
|
}
|
|
|
|
|
|
public partial class Message
|
|
|
|
|
|
{
|
2021-10-16 02:01:49 +02:00
|
|
|
|
public override int ID => id;
|
2021-09-25 02:13:06 +02:00
|
|
|
|
public override Peer Peer => peer_id;
|
|
|
|
|
|
public override DateTime Date => date;
|
|
|
|
|
|
}
|
|
|
|
|
|
public partial class MessageService
|
|
|
|
|
|
{
|
2021-10-16 02:01:49 +02:00
|
|
|
|
public override int ID => id;
|
2021-09-25 02:13:06 +02:00
|
|
|
|
public override Peer Peer => peer_id;
|
|
|
|
|
|
public override DateTime Date => date;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-10 03:12:33 +02:00
|
|
|
|
partial class PhotoBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public abstract long ID { get; }
|
2021-09-30 03:40:08 +02:00
|
|
|
|
protected abstract InputPhoto ToInputPhoto();
|
|
|
|
|
|
public static implicit operator InputPhoto(PhotoBase photo) => photo.ToInputPhoto();
|
2021-08-10 03:12:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
partial class PhotoEmpty
|
|
|
|
|
|
{
|
|
|
|
|
|
public override long ID => id;
|
2021-09-30 03:40:08 +02:00
|
|
|
|
protected override InputPhoto ToInputPhoto() => null;
|
2021-08-10 03:12:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
partial class Photo
|
|
|
|
|
|
{
|
|
|
|
|
|
public override long ID => id;
|
2021-09-23 09:29:19 +02:00
|
|
|
|
|
2021-09-30 03:40:08 +02:00
|
|
|
|
protected override InputPhoto ToInputPhoto() => new() { id = id, access_hash = access_hash, file_reference = file_reference };
|
2021-09-23 09:29:19 +02:00
|
|
|
|
public InputPhotoFileLocation ToFileLocation() => ToFileLocation(LargestPhotoSize);
|
2021-08-10 03:12:33 +02:00
|
|
|
|
public InputPhotoFileLocation ToFileLocation(PhotoSizeBase photoSize) => new() { id = id, access_hash = access_hash, file_reference = file_reference, thumb_size = photoSize.Type };
|
2021-09-23 09:29:19 +02:00
|
|
|
|
public PhotoSizeBase LargestPhotoSize => sizes.Aggregate((agg, next) => (long)next.Width * next.Height > (long)agg.Width * agg.Height ? next : agg);
|
2021-08-10 03:12:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-09-23 09:29:19 +02:00
|
|
|
|
partial class PhotoSizeBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public abstract string Type { get; }
|
|
|
|
|
|
public abstract int Width { get; }
|
|
|
|
|
|
public abstract int Height { get; }
|
|
|
|
|
|
public abstract int FileSize { get; }
|
|
|
|
|
|
}
|
|
|
|
|
|
partial class PhotoSizeEmpty
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string Type => type;
|
|
|
|
|
|
public override int Width => 0;
|
|
|
|
|
|
public override int Height => 0;
|
|
|
|
|
|
public override int FileSize => 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
partial class PhotoSize
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string Type => type;
|
|
|
|
|
|
public override int Width => w;
|
|
|
|
|
|
public override int Height => h;
|
|
|
|
|
|
public override int FileSize => size;
|
|
|
|
|
|
}
|
|
|
|
|
|
partial class PhotoCachedSize
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string Type => type;
|
|
|
|
|
|
public override int Width => w;
|
|
|
|
|
|
public override int Height => h;
|
|
|
|
|
|
public override int FileSize => bytes.Length;
|
|
|
|
|
|
}
|
|
|
|
|
|
partial class PhotoStrippedSize
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string Type => type;
|
|
|
|
|
|
public override int Width => bytes[2];
|
|
|
|
|
|
public override int Height => bytes[1];
|
|
|
|
|
|
public override int FileSize => bytes.Length;
|
|
|
|
|
|
}
|
|
|
|
|
|
partial class PhotoSizeProgressive
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string Type => type;
|
|
|
|
|
|
public override int Width => w;
|
|
|
|
|
|
public override int Height => h;
|
|
|
|
|
|
public override int FileSize => sizes.Last();
|
|
|
|
|
|
}
|
|
|
|
|
|
partial class PhotoPathSize
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string Type => type;
|
|
|
|
|
|
public override int Width => -1;
|
|
|
|
|
|
public override int Height => -1;
|
|
|
|
|
|
public override int FileSize => bytes.Length;
|
|
|
|
|
|
}
|
2021-08-20 14:45:39 +02:00
|
|
|
|
namespace Layer23
|
|
|
|
|
|
{
|
2021-09-23 09:29:19 +02:00
|
|
|
|
partial class PhotoSize
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string Type => type;
|
|
|
|
|
|
public override int Width => w;
|
|
|
|
|
|
public override int Height => h;
|
|
|
|
|
|
public override int FileSize => size;
|
|
|
|
|
|
}
|
|
|
|
|
|
partial class PhotoCachedSize
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string Type => type;
|
|
|
|
|
|
public override int Width => w;
|
|
|
|
|
|
public override int Height => h;
|
|
|
|
|
|
public override int FileSize => bytes.Length;
|
|
|
|
|
|
}
|
2021-08-20 14:45:39 +02:00
|
|
|
|
}
|
2021-08-10 03:12:33 +02:00
|
|
|
|
|
|
|
|
|
|
partial class DocumentBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public abstract long ID { get; }
|
2021-09-30 03:40:08 +02:00
|
|
|
|
protected abstract InputDocument ToInputDocument();
|
|
|
|
|
|
public static implicit operator InputDocument(DocumentBase document) => document.ToInputDocument();
|
2021-08-10 03:12:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
partial class DocumentEmpty
|
|
|
|
|
|
{
|
|
|
|
|
|
public override long ID => id;
|
2021-09-30 03:40:08 +02:00
|
|
|
|
protected override InputDocument ToInputDocument() => null;
|
2021-08-10 03:12:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
partial class Document
|
|
|
|
|
|
{
|
|
|
|
|
|
public override long ID => id;
|
2021-09-30 03:40:08 +02:00
|
|
|
|
protected override InputDocument ToInputDocument() => new() { id = id, access_hash = access_hash, file_reference = file_reference };
|
2021-09-23 09:29:19 +02:00
|
|
|
|
public InputDocumentFileLocation ToFileLocation(PhotoSizeBase thumbSize = null) => new() { id = id, access_hash = access_hash, file_reference = file_reference, thumb_size = thumbSize?.Type };
|
2021-08-10 03:12:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
partial class EncryptedFile
|
|
|
|
|
|
{
|
2021-09-30 03:40:08 +02:00
|
|
|
|
public static implicit operator InputEncryptedFile(EncryptedFile file) => file == null ? null : new InputEncryptedFile { id = file.id, access_hash = file.access_hash };
|
2021-08-10 03:12:33 +02:00
|
|
|
|
public InputEncryptedFileLocation ToFileLocation() => new() { id = id, access_hash = access_hash };
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
partial class SecureFile
|
|
|
|
|
|
{
|
|
|
|
|
|
public static implicit operator InputSecureFile(SecureFile file) => new() { id = file.id, access_hash = file.access_hash };
|
|
|
|
|
|
public InputSecureFileLocation ToFileLocation() => new() { id = id, access_hash = access_hash };
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
partial class InputFileBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public abstract InputEncryptedFileBase ToInputEncryptedFile(int key_fingerprint);
|
|
|
|
|
|
public abstract InputSecureFileBase ToInputSecureFile(byte[] file_hash, byte[] secret);
|
|
|
|
|
|
}
|
|
|
|
|
|
partial class InputFile
|
|
|
|
|
|
{
|
|
|
|
|
|
public override InputEncryptedFileBase ToInputEncryptedFile(int key_fingerprint) => new InputEncryptedFileUploaded { id = id, parts = parts, md5_checksum = md5_checksum, key_fingerprint = key_fingerprint };
|
|
|
|
|
|
public override InputSecureFileBase ToInputSecureFile(byte[] file_hash, byte[] secret) => new InputSecureFileUploaded { id = id, parts = parts, md5_checksum = md5_checksum, file_hash = file_hash, secret = secret };
|
|
|
|
|
|
}
|
|
|
|
|
|
partial class InputFileBig
|
|
|
|
|
|
{
|
|
|
|
|
|
public override InputEncryptedFileBase ToInputEncryptedFile(int key_fingerprint) => new InputEncryptedFileBigUploaded { id = id, parts = parts, key_fingerprint = key_fingerprint };
|
|
|
|
|
|
public override InputSecureFileBase ToInputSecureFile(byte[] file_hash, byte[] secret) => new InputSecureFileUploaded { id = id, parts = parts, file_hash = file_hash, secret = secret };
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
partial class StickerSet
|
|
|
|
|
|
{
|
|
|
|
|
|
public static implicit operator InputStickerSetID(StickerSet stickerSet) => new() { id = stickerSet.id, access_hash = stickerSet.access_hash };
|
|
|
|
|
|
}
|
2021-08-16 05:56:39 +02:00
|
|
|
|
|
2021-09-17 03:58:52 +02:00
|
|
|
|
partial class Peer { public abstract long ID { get; } }
|
2021-09-27 03:20:58 +02:00
|
|
|
|
partial class PeerUser { public override long ID => user_id; public override string ToString() => "user " + user_id; }
|
|
|
|
|
|
partial class PeerChat { public override long ID => chat_id; public override string ToString() => "chat " + chat_id; }
|
|
|
|
|
|
partial class PeerChannel { public override long ID => channel_id; public override string ToString() => "channel " + channel_id; }
|
2021-08-19 06:56:55 +02:00
|
|
|
|
|
|
|
|
|
|
partial class JsonObjectValue { public override string ToString() => $"{HttpUtility.JavaScriptStringEncode(key, true)}:{value}"; }
|
|
|
|
|
|
partial class JsonNull { public override string ToString() => "null"; }
|
|
|
|
|
|
partial class JsonBool { public override string ToString() => value ? "true" : "false"; }
|
|
|
|
|
|
partial class JsonNumber { public override string ToString() => value.ToString(CultureInfo.InvariantCulture); }
|
|
|
|
|
|
partial class JsonString { public override string ToString() => HttpUtility.JavaScriptStringEncode(value, true); }
|
|
|
|
|
|
partial class JsonArray
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
|
{
|
|
|
|
|
|
var sb = new StringBuilder().Append('[');
|
|
|
|
|
|
for (int i = 0; i < value.Length; i++)
|
|
|
|
|
|
sb.Append(i == 0 ? "" : ",").Append(value[i]);
|
|
|
|
|
|
return sb.Append(']').ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
partial class JsonObject
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
|
{
|
|
|
|
|
|
var sb = new StringBuilder().Append('{');
|
|
|
|
|
|
for (int i = 0; i < value.Length; i++)
|
|
|
|
|
|
sb.Append(i == 0 ? "" : ",").Append(value[i]);
|
|
|
|
|
|
return sb.Append('}').ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-10-01 05:46:51 +02:00
|
|
|
|
|
|
|
|
|
|
partial class SendMessageAction
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
|
{
|
|
|
|
|
|
var type = GetType().Name[11..^6];
|
|
|
|
|
|
for (int i = 1; i < type.Length; i++)
|
|
|
|
|
|
if (char.IsUpper(type[i]))
|
|
|
|
|
|
return type.ToLowerInvariant().Insert(i, "ing ");
|
|
|
|
|
|
return type.ToLowerInvariant();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
partial class SpeakingInGroupCallAction { public override string ToString() => "speaking in group call"; }
|
|
|
|
|
|
partial class SendMessageTypingAction { public override string ToString() => "typing"; }
|
|
|
|
|
|
partial class SendMessageCancelAction { public override string ToString() => "stopping"; }
|
|
|
|
|
|
partial class SendMessageGeoLocationAction { public override string ToString() => "selecting a location"; }
|
|
|
|
|
|
partial class SendMessageGamePlayAction { public override string ToString() => "playing a game"; }
|
|
|
|
|
|
partial class SendMessageHistoryImportAction{ public override string ToString() => "importing history"; }
|
|
|
|
|
|
|
2021-08-10 03:12:33 +02:00
|
|
|
|
}
|