From 1a3cde42417f441b72d6680314d44be33fe05223 Mon Sep 17 00:00:00 2001
From: Wizou <11647984+wiz0u@users.noreply.github.com>
Date: Wed, 26 Oct 2022 14:26:22 +0200
Subject: [PATCH] Replaced *Default & *None structures with null
---
FAQ.md | 19 ++++++++++---------
src/TL.Helpers.cs | 2 +-
src/TL.Schema.cs | 44 +++++++++++++++----------------------------
src/TL.SchemaFuncs.cs | 11 +++++++----
src/TL.Table.cs | 18 ++++++++++++------
5 files changed, 45 insertions(+), 49 deletions(-)
diff --git a/FAQ.md b/FAQ.md
index 0b4d1c5..6e4e747 100644
--- a/FAQ.md
+++ b/FAQ.md
@@ -139,8 +139,8 @@ Here are some advices from [another similar library](https://github.com/gotd/td/
Some additional advices from me:
5. Avoid repetitive polling or repetitive sequence of actions/requests: Save the initial results of your queries, and update those results when you're informed of a change through `OnUpdate` events.
-6. If a phone number is brand new, it will be closely monitored by Telegram for abuse, and it can even already be considered a bad user due to bad behavior from the previous owner of that phone number (which may happens often with VoIP or other easy-to-buy-online numbers, so expect fast ban)
-7. Don't buy fake users/session accounts from Internet and don't extract api_id/hash/authkey/sessions from official clients, this is [specifically forbidden by API TOS](https://core.telegram.org/api/terms#2-transparency).
+6. Don't buy fake user accounts/sessions and don't extract api_id/hash/authkey/sessions from official clients, this is [specifically forbidden by API TOS](https://core.telegram.org/api/terms#2-transparency). You must use your own api_id and create your own sessions associated with it.
+7. If a phone number is brand new, it will be closely monitored by Telegram for abuse, and it can even already be considered a bad user due to bad behavior from the previous owner of that phone number (which may happens often with VoIP or other easy-to-buy-online numbers, so expect fast ban)
8. You may want to use your new phone number account with an official Telegram client and act like a normal user for some time (some weeks/months), before using it for automation with WTelegramClient.
9. When creating a new API ID/Hash, I recommend you use your own phone number with long history of normal Telegram usage, rather than a brand new phone number with short history.
In particular, DON'T create an API ID/Hash for every phone numbers you will control. One API ID/Hash represents your application, which can be used to control several user accounts.
@@ -164,23 +164,24 @@ That object must be created with both fields `channel_id` and `access_hash` corr
-#### 10. `chats.chats[id]` fails. My chats list is empty or does not contain the chat id.
+#### 10. `chats.chats[id]` fails. My chats list is empty or does not contain the chat I'm looking for.
There can be several reasons why `chats.chats` doesn't contain the chat you expect:
-- The currently logged-in user account has not joined this particular chat.
-API method [Messages_GetAllChats](https://corefork.telegram.org/method/messages.getAllChats) will only return those chat groups/channels the user is in, not all Telegram chat groups.
-- You're trying to use a Bot API (or TDLib) numerical ID, like -1001234567890
-Telegram Client API don't use these kind of IDs for chats. Remove the -100 prefix and try again with the rest (1234567890).
- You're searching for a user instead of a chat ID.
Private messages with a user are not called "chats". See [Terminology in ReadMe](README.md#terminology).
-To obtain the list of users (as well as chats and channels) the logged-in user is currenly engaged in a discussion with, you should [use the API method Messages_GetAllDialogs](EXAMPLES.md#list-dialogs)
+To obtain the list of users (as well as chats and channels) the logged-in user is currenly engaged in a discussion with, you should [use the API method `Messages_GetAllDialogs`](EXAMPLES.md#list-dialogs)
+- The currently logged-in user account has not joined this particular chat.
+API method [`Messages_GetAllChats`](https://corefork.telegram.org/method/messages.getAllChats) will only return those chat groups/channels the user is in, not all Telegram chat groups.
+If you're looking for other Telegram groups/channels/users, try API methods [`Contacts_ResolveUsername`](EXAMPLES.md#msg-by-name) or `Contacts_Search`
+- You're trying to use a Bot API (or TDLib) numerical ID, like -1001234567890
+Telegram Client API don't use these kind of IDs for chats. Remove the -100 prefix and try again with the rest (1234567890).
- the `chats.chats` dictionary is empty.
This is the case if you are logged-in as a brand new user account (that hasn't join any chat groups/channels)
or if you are connected to a Test DC (a Telegram datacenter server for tests) instead of Production DC
([read FAQ #6](#wrong-server) for more)
To help determine if `chats.chats` is empty or does not contain a certain chat, you should [dump the chat list to the screen](EXAMPLES.md#list-chats)
-or simply use a debugger: Place a breakpoint after the Messages_GetAllChats call, run the program up to there, and use a Watch pane to display the content of the chats.chats dictionary.
+or simply use a debugger: Place a breakpoint after the `Messages_GetAllChats` call, run the program up to there, and use a Watch pane to display the content of the chats.chats dictionary.
#### 11. I get "Connection shut down" errors in my logs
diff --git a/src/TL.Helpers.cs b/src/TL.Helpers.cs
index 529ec5d..0e8f82e 100644
--- a/src/TL.Helpers.cs
+++ b/src/TL.Helpers.cs
@@ -58,7 +58,7 @@ namespace TL
{
public abstract InputEncryptedFileBase ToInputEncryptedFile(int key_fingerprint);
public abstract InputSecureFileBase ToInputSecureFile(byte[] file_hash, byte[] secret);
- /// for a profile photo. for auto-detection
for a profile video. The video MUST be square and 10 seconds max
+ /// for a profile photo. for auto-detection
for a profile video. The video MUST be square, 10 seconds max, larger than 160x160
public InputChatUploadedPhoto ToInputChatPhoto(bool? isSquareVideo10s = null)
{
if (isSquareVideo10s ?? Path.GetExtension(Name)?.ToLowerInvariant() is ".mp4")
diff --git a/src/TL.Schema.cs b/src/TL.Schema.cs
index d012742..95f1d61 100644
--- a/src/TL.Schema.cs
+++ b/src/TL.Schema.cs
@@ -3870,7 +3870,7 @@ namespace TL
/// Folder ID
public int id;
/// Folder info
- [IfFlag(0)] public DialogFilterBase filter;
+ [IfFlag(0)] public DialogFilter filter;
[Flags] public enum Flags : uint
{
@@ -6306,7 +6306,7 @@ namespace TL
public class KeyboardButtonBuy : KeyboardButton
{
}
- /// Button to request a user to authorize via URL using Seamless Telegram Login. When the user clicks on such a button, messages.requestUrlAuth should be called, providing the button_id and the ID of the container message. The returned object will contain more details about the authorization request (request_write_access if the bot would like to send messages to the user along with the username of the bot which will be used for user authorization). Finally, the user can choose to call messages.acceptUrlAuth to get a with the URL to open instead of the url of this constructor, or a , in which case the url of this constructor must be opened, instead. If the user refuses the authorization request but still wants to open the link, the url of this constructor must be used. See
+ /// Button to request a user to authorize via URL using Seamless Telegram Login. When the user clicks on such a button, messages.requestUrlAuth should be called, providing the button_id and the ID of the container message. The returned object will contain more details about the authorization request (request_write_access if the bot would like to send messages to the user along with the username of the bot which will be used for user authorization). Finally, the user can choose to call messages.acceptUrlAuth to get a with the URL to open instead of the url of this constructor, or a , in which case the url of this constructor must be opened, instead. If the user refuses the authorization request but still wants to open the link, the url of this constructor must be used. See
[TLDef(0x10B78D29)]
public class KeyboardButtonUrlAuth : KeyboardButtonBase
{
@@ -11332,7 +11332,8 @@ namespace TL
}
}
- /// URL authorization result Derived classes: , , See
+ /// URL authorization result Derived classes: , See
+ /// a null value means urlAuthResultDefault
public abstract class UrlAuthResult : IObject { }
/// Details about the authorization request, for more info click here » See
[TLDef(0x92D33A0E)]
@@ -11358,9 +11359,6 @@ namespace TL
/// The URL name of the website on which the user has logged in.
public string url;
}
- /// Details about an accepted authorization request, for more info click here » See
- [TLDef(0xA9D6DB1F)]
- public class UrlAuthResultDefault : UrlAuthResult { }
/// Geographical location of supergroup (geogroups) See
/// a null value means channelLocationEmpty
@@ -11742,11 +11740,10 @@ namespace TL
public BankCardOpenUrl[] open_urls;
}
- /// Dialog filter (folder ») Derived classes: , See
- public abstract class DialogFilterBase : IObject { }
/// Dialog filter AKA folder See
+ /// a null value means dialogFilterDefault
[TLDef(0x7438F7E8)]
- public class DialogFilter : DialogFilterBase
+ public class DialogFilter : IObject
{
/// Flags, see TL conditional fields
public Flags flags;
@@ -11785,16 +11782,13 @@ namespace TL
has_emoticon = 0x2000000,
}
}
- /// Used only when reordering folders to indicate the default (all chats) folder. See
- [TLDef(0x363293AE)]
- public class DialogFilterDefault : DialogFilterBase { }
/// Suggested folders See
[TLDef(0x77744D4A)]
public class DialogFilterSuggested : IObject
{
/// Folder info
- public DialogFilterBase filter;
+ public DialogFilter filter;
/// Folder description
public string description;
}
@@ -12705,11 +12699,9 @@ namespace TL
public string short_name;
}
- /// Represents a scope where the bot commands, specified using bots.setBotCommands will be valid. Derived classes: , , , , , , See
+ /// Represents a scope where the bot commands, specified using bots.setBotCommands will be valid. Derived classes: , , , , , See
+ /// a null value means botCommandScopeDefault
public abstract class BotCommandScope : IObject { }
- /// The commands will be valid in all dialogs See
- [TLDef(0x2F6CB2AB)]
- public class BotCommandScopeDefault : BotCommandScope { }
/// The specified bot commands will only be valid in all private chats with users. See
[TLDef(0x3C4F04D8)]
public class BotCommandScopeUsers : BotCommandScope { }
@@ -13234,11 +13226,9 @@ namespace TL
}
}
- /// Indicates the action to execute when pressing the in-UI menu button for bots Derived classes: , , See
+ /// Indicates the action to execute when pressing the in-UI menu button for bots Derived classes: , See
+ /// a null value means botMenuButtonDefault
public abstract class BotMenuButtonBase : IObject { }
- /// Placeholder bot menu button never returned to users: see the docs for more info. See
- [TLDef(0x7533A588)]
- public class BotMenuButtonDefault : BotMenuButtonBase { }
/// Bot menu button that opens the bot command list when clicked. See
[TLDef(0x4258C205)]
public class BotMenuButtonCommands : BotMenuButtonBase { }
@@ -13263,11 +13253,9 @@ namespace TL
public DocumentBase[] ringtones;
}
- /// Represents a notification sound Derived classes: , , , See
+ /// Represents a notification sound Derived classes: , , See
+ /// a null value means notificationSoundDefault
public abstract class NotificationSound : IObject { }
- /// Indicates the default notification sound should be used See
- [TLDef(0x97E8BEBE)]
- public class NotificationSoundDefault : NotificationSound { }
/// No notification sound should be used See
[TLDef(0x6F0C34DF)]
public class NotificationSoundNone : NotificationSound { }
@@ -13483,11 +13471,9 @@ namespace TL
public long document_id;
}
- /// Available chat reactions Derived classes: , , See
+ /// Available chat reactions Derived classes: , See
+ /// a null value means chatReactionsNone
public abstract class ChatReactions : IObject { }
- /// No reactions are allowed See
- [TLDef(0xEAFC32BC)]
- public class ChatReactionsNone : ChatReactions { }
/// All reactions or all non-custom reactions are allowed See
[TLDef(0x52928BCA)]
public class ChatReactionsAll : ChatReactions
diff --git a/src/TL.SchemaFuncs.cs b/src/TL.SchemaFuncs.cs
index 5fca2b0..c0b70d1 100644
--- a/src/TL.SchemaFuncs.cs
+++ b/src/TL.SchemaFuncs.cs
@@ -2587,6 +2587,7 @@ namespace TL
/// The message
/// The ID of the button with the authorization request
/// URL used for link URL authorization, click here for more info »
+ /// a null value means urlAuthResultDefault
public static Task Messages_RequestUrlAuth(this Client client, InputPeer peer = null, int? msg_id = null, int? button_id = null, string url = null)
=> client.Invoke(new Messages_RequestUrlAuth
{
@@ -2603,6 +2604,7 @@ namespace TL
/// Message ID of the message with the login button
/// ID of the login button
/// URL used for link URL authorization, click here for more info »
+ /// a null value means urlAuthResultDefault
public static Task Messages_AcceptUrlAuth(this Client client, bool write_allowed = false, InputPeer peer = null, int? msg_id = null, int? button_id = null, string url = null)
=> client.Invoke(new Messages_AcceptUrlAuth
{
@@ -2691,7 +2693,7 @@ namespace TL
});
/// Get folders See
- public static Task Messages_GetDialogFilters(this Client client)
+ public static Task Messages_GetDialogFilters(this Client client)
=> client.Invoke(new Messages_GetDialogFilters
{
});
@@ -2705,7 +2707,7 @@ namespace TL
/// Update folder See Possible codes: 400 (details)
/// Folder ID
/// Folder info
- public static Task Messages_UpdateDialogFilter(this Client client, int id, DialogFilterBase filter = null)
+ public static Task Messages_UpdateDialogFilter(this Client client, int id, DialogFilter filter = null)
=> client.Invoke(new Messages_UpdateDialogFilter
{
flags = (Messages_UpdateDialogFilter.Flags)(filter != null ? 0x1 : 0),
@@ -4229,6 +4231,7 @@ namespace TL
/// Gets the menu button action for a given user or for all users, previously set using bots.setBotMenuButton; users can see this information in the . See [bots: ✓] Possible codes: 400 (details)
/// User ID or empty for the default menu button.
+ /// a null value means botMenuButtonDefault
public static Task Bots_GetBotMenuButton(this Client client, InputUserBase user_id)
=> client.Invoke(new Bots_GetBotMenuButton
{
@@ -7106,7 +7109,7 @@ namespace TL.Methods
}
[TLDef(0xF19ED96D)]
- public class Messages_GetDialogFilters : IMethod { }
+ public class Messages_GetDialogFilters : IMethod { }
[TLDef(0xA29CD42C)]
public class Messages_GetSuggestedDialogFilters : IMethod { }
@@ -7116,7 +7119,7 @@ namespace TL.Methods
{
public Flags flags;
public int id;
- [IfFlag(0)] public DialogFilterBase filter;
+ [IfFlag(0)] public DialogFilter filter;
[Flags] public enum Flags : uint
{
diff --git a/src/TL.Table.cs b/src/TL.Table.cs
index 27ecbc9..0ae1e3c 100644
--- a/src/TL.Table.cs
+++ b/src/TL.Table.cs
@@ -865,7 +865,7 @@ namespace TL
[0xE844EBFF] = typeof(Messages_SearchCounter),
[0x92D33A0E] = typeof(UrlAuthResultRequest),
[0x8F8C0E4E] = typeof(UrlAuthResultAccepted),
- [0xA9D6DB1F] = typeof(UrlAuthResultDefault),
+ [0xA9D6DB1F] = null,//UrlAuthResultDefault
[0xBFB5AD8B] = null,//ChannelLocationEmpty
[0x209B82DB] = typeof(ChannelLocation),
[0xCA461B5D] = typeof(PeerLocated),
@@ -891,7 +891,7 @@ namespace TL
[0xF568028A] = typeof(BankCardOpenUrl),
[0x3E24E573] = typeof(Payments_BankCardData),
[0x7438F7E8] = typeof(DialogFilter),
- [0x363293AE] = typeof(DialogFilterDefault),
+ [0x363293AE] = null,//DialogFilterDefault
[0x77744D4A] = typeof(DialogFilterSuggested),
[0xB637EDAF] = typeof(StatsDateRangeDays),
[0xCB43ACDE] = typeof(StatsAbsValueAndPrev),
@@ -942,7 +942,7 @@ namespace TL
[0xDCB118B7] = typeof(GroupCallParticipantVideoSourceGroup),
[0x67753AC8] = typeof(GroupCallParticipantVideo),
[0x85FEA03F] = typeof(Stickers_SuggestedShortName),
- [0x2F6CB2AB] = typeof(BotCommandScopeDefault),
+ [0x2F6CB2AB] = null,//BotCommandScopeDefault
[0x3C4F04D8] = typeof(BotCommandScopeUsers),
[0x6FE1A881] = typeof(BotCommandScopeChats),
[0xB9AA606A] = typeof(BotCommandScopeChatAdmins),
@@ -983,12 +983,12 @@ namespace TL
[0x0C14557C] = typeof(WebViewResultUrl),
[0x882F76BB] = typeof(SimpleWebViewResultUrl),
[0x0C94511C] = typeof(WebViewMessageSent),
- [0x7533A588] = typeof(BotMenuButtonDefault),
+ [0x7533A588] = null,//BotMenuButtonDefault
[0x4258C205] = typeof(BotMenuButtonCommands),
[0xC7B57CE6] = typeof(BotMenuButton),
[0xFBF6E8B1] = null,//Account_SavedRingtonesNotModified
[0xC1E92CC5] = typeof(Account_SavedRingtones),
- [0x97E8BEBE] = typeof(NotificationSoundDefault),
+ [0x97E8BEBE] = null,//NotificationSoundDefault
[0x6F0C34DF] = typeof(NotificationSoundNone),
[0x830B9AE4] = typeof(NotificationSoundLocal),
[0xFF6C8049] = typeof(NotificationSoundRingtone),
@@ -1011,7 +1011,7 @@ namespace TL
[0x79F5D419] = null,//ReactionEmpty
[0x1B2286B8] = typeof(ReactionEmoji),
[0x8935FC73] = typeof(ReactionCustomEmoji),
- [0xEAFC32BC] = typeof(ChatReactionsNone),
+ [0xEAFC32BC] = null,//ChatReactionsNone
[0x52928BCA] = typeof(ChatReactionsAll),
[0x661D4037] = typeof(ChatReactionsSome),
[0xB06FDBDF] = null,//Messages_ReactionsNotModified
@@ -1125,15 +1125,21 @@ namespace TL
[typeof(Help_PassportConfig)] = 0xBFB9F457, //help.passportConfigNotModified
[typeof(Help_UserInfo)] = 0xF3AE2EED, //help.userInfoEmpty
[typeof(Account_WallPapers)] = 0x1C199183, //account.wallPapersNotModified
+ [typeof(UrlAuthResult)] = 0xA9D6DB1F, //urlAuthResultDefault
[typeof(ChannelLocation)] = 0xBFB5AD8B, //channelLocationEmpty
[typeof(Account_Themes)] = 0xF41EB622, //account.themesNotModified
+ [typeof(DialogFilter)] = 0x363293AE, //dialogFilterDefault
[typeof(Help_CountriesList)] = 0x93CC1F32, //help.countriesListNotModified
+ [typeof(BotCommandScope)] = 0x2F6CB2AB, //botCommandScopeDefault
[typeof(Messages_AvailableReactions)] = 0x9F071957, //messages.availableReactionsNotModified
[typeof(AttachMenuBots)] = 0xF1D88A5C, //attachMenuBotsNotModified
+ [typeof(BotMenuButtonBase)] = 0x7533A588, //botMenuButtonDefault
[typeof(Account_SavedRingtones)] = 0xFBF6E8B1, //account.savedRingtonesNotModified
+ [typeof(NotificationSound)] = 0x97E8BEBE, //notificationSoundDefault
[typeof(EmojiStatus)] = 0x2DE11AAE, //emojiStatusEmpty
[typeof(Account_EmojiStatuses)] = 0xD08CE645, //account.emojiStatusesNotModified
[typeof(Reaction)] = 0x79F5D419, //reactionEmpty
+ [typeof(ChatReactions)] = 0xEAFC32BC, //chatReactionsNone
[typeof(Messages_Reactions)] = 0xB06FDBDF, //messages.reactionsNotModified
// from TL.Secret:
[typeof(DecryptedMessageMedia)] = 0x089F5C4A, //decryptedMessageMediaEmpty