diff --git a/EXAMPLES.md b/EXAMPLES.md index 70810f3..3bf8182 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -214,12 +214,12 @@ var chats = await client.Messages_GetAllChats(null); const long chatId = 1234567890; // the target chat var chat = chats.chats[chatId]; ``` -After the above code, once you have obtained an InputUser (or User), you can: +After the above code, once you [have obtained](https://github.com/wiz0u/WTelegramClient/blob/master/FAQ.md#access-hash) an `InputUser` or `User`, you can: ```csharp // • Directly add the user to a simple Chat: -await client.Messages_AddChatUser(1234567890, inputUser, int.MaxValue); +await client.Messages_AddChatUser(1234567890, user, int.MaxValue); // • Directly add the user to a Channel/group: -await client.Channels_InviteToChannel((Channel)chat, new[] { inputUser }); +await client.Channels_InviteToChannel((Channel)chat, new[] { user }); // You may get exception USER_PRIVACY_RESTRICTED if the user has denied the right to be added to a chat // or exception USER_NOT_MUTUAL_CONTACT if the user left the chat previously and you want to add him again @@ -229,19 +229,19 @@ var mcf = await client.Messages_GetFullChat(1234567890); var mcf = await client.Channels_GetFullChannel((Channel)chat); // extract the invite link and send it to the user: var invite = (ChatInviteExported)mcf.full_chat.ExportedInvite; -await client.SendMessageAsync(inputUser, "Join our group with this link: " + invite.link); +await client.SendMessageAsync(user, "Join our group with this link: " + invite.link); // • Create a new invite link for the chat/channel, and send it to the user var invite = (ChatInviteExported)await client.Messages_ExportChatInvite(chat, title: "MyLink"); -await client.SendMessageAsync(inputUser, "Join our group with this link: " + invite.link); +await client.SendMessageAsync(user, "Join our group with this link: " + invite.link); // • Revoke then delete that invite link (when you no longer need it) await client.Messages_EditExportedChatInvite(chat, invite.link, revoked: true); await client.Messages_DeleteExportedChatInvite(chat, invite.link); // • Remove the user from a simple Chat: -await client.Messages_DeleteChatUser(1234567890, inputUser); +await client.Messages_DeleteChatUser(1234567890, user); // • Remove the user from a Channel/group: -await client.Channels_EditBanned((Channel)chat, inputUser, new ChatBannedRights { flags = ChatBannedRights.Flags.view_messages }); +await client.Channels_EditBanned((Channel)chat, user, new ChatBannedRights { flags = ChatBannedRights.Flags.view_messages }); ``` diff --git a/FAQ.md b/FAQ.md index f990dac..a586863 100644 --- a/FAQ.md +++ b/FAQ.md @@ -49,7 +49,8 @@ However most common chat groups are not `Chat` but a `Channel` supergroup (witho Some TL methods only applies to private `Chat`, some only applies to `Channel` and some to both. The `access_hash` must usually be provided within the `Input...` structure you pass in argument to an API method (`InputPeer`, `InputChannel`, `InputUser`, etc...). -You obtain the `access_hash` through **description structures** like `Channel`, `User`, `Photo`, `Document` that you receive through updates or when you query them through API methods like `Messages_GetAllChats`, `Messages_GetDialogs`, `Contacts_ResolveUsername`, etc... +You obtain the `access_hash` through **description structures** like `Channel`, `User`, `Photo`, `Document` that you receive through updates or when you query them through API methods like `Messages_GetAllChats`, `Messages_GetDialogs`, `Contacts_ResolveUsername`, etc... +*(if you have a `Peer` object, you can convert it to a `User`/`Channel`/`Chat` via the `UserOrChat` helper from the root class that contained the peer)* Once you obtained the description structure, there are 3 methods for building your `Input...` structure: * **Recommended:** If you take a look at the **description structure** class or `ChatBase/UserBase`, diff --git a/README.md b/README.md index 2673c5a..6b9f1b6 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,8 @@ await client.SendMessageAsync(target, "Hello, World"); In the API, Telegram uses some terms/classnames that can be confusing as they differ from the terms shown to end-users: - `Channel` : A (large or public) chat group *(sometimes called supergroup)* or a broadcast channel (the `broadcast` flag differenciate those) -- `Chat` : A private simple chat group with less than 200 members (it may be migrated to a supergroup `Channel` with a new ID when it gets bigger or public, in which case the old `Chat` will still exist but be `deactivated`) +- `Chat` : A private simple chat group with less than 200 members (it may be migrated to a supergroup `Channel` with a new ID when it gets bigger or public, in which case the old `Chat` will still exist but be `deactivated`) +**⚠ Most chat groups you see are really of type `Channel` not `Chat`!** - chats : In plural or general meaning, it means either `Chat` or `Channel` - `Peer` : Either a `Chat`, `Channel` or a private chat with a `User` - Dialog : The current status of a chat with a `Peer` *(draft, last message, unread count, pinned...)* diff --git a/src/TL.Schema.cs b/src/TL.Schema.cs index ea62130..339702f 100644 --- a/src/TL.Schema.cs +++ b/src/TL.Schema.cs @@ -55,7 +55,7 @@ namespace TL { /// User identifier public long user_id; - /// access_hash value from the constructor + /// REQUIRED FIELD. See how to obtain it
access_hash value from the constructor
public long access_hash; } /// Defines a channel for further interaction. See @@ -64,7 +64,7 @@ namespace TL { /// Channel identifier public long channel_id; - /// access_hash value from the constructor + /// REQUIRED FIELD. See how to obtain it
access_hash value from the constructor
public long access_hash; } ///
Defines a min user that was seen in a certain message of a certain chat. See @@ -102,7 +102,7 @@ namespace TL { /// User identifier public long user_id; - /// access_hash value from the constructor + /// REQUIRED FIELD. See how to obtain it
access_hash value from the constructor
public long access_hash; } ///
Defines a min user that was seen in a certain message of a certain chat. See @@ -506,7 +506,7 @@ namespace TL { /// Photo identifier public long id; - /// access_hash value from the constructor + /// REQUIRED FIELD. See how to obtain it
access_hash value from the constructor
public long access_hash; ///
File reference public byte[] file_reference; @@ -533,7 +533,7 @@ namespace TL { /// File ID, id parameter value from public long id; - /// Checksum, access_hash parameter value from + /// REQUIRED FIELD. See how to obtain it
Checksum, access_hash parameter value from
public long access_hash; } /// Document location (video, voice, audio, basically every type except photo) See @@ -542,7 +542,7 @@ namespace TL { /// Document ID public long id; - /// access_hash parameter from the constructor + /// REQUIRED FIELD. See how to obtain it
access_hash parameter from the constructor
public long access_hash; ///
File reference public byte[] file_reference; @@ -555,7 +555,7 @@ namespace TL { /// File ID, id parameter value from public long id; - /// Checksum, access_hash parameter value from + /// REQUIRED FIELD. See how to obtain it
Checksum, access_hash parameter value from
public long access_hash; } /// Empty constructor for takeout See @@ -567,7 +567,7 @@ namespace TL { /// Photo ID, obtained from the object public long id; - /// Photo's access hash, obtained from the object + /// REQUIRED FIELD. See how to obtain it
Photo's access hash, obtained from the object
public long access_hash; ///
File reference public byte[] file_reference; @@ -580,7 +580,7 @@ namespace TL { /// Photo ID public long id; - /// Access hash + /// REQUIRED FIELD. See how to obtain it
Access hash
public long access_hash; /// File reference public byte[] file_reference; @@ -4758,7 +4758,7 @@ namespace TL { /// Chat ID public int chat_id; - /// Checking sum from constructor , or + /// REQUIRED FIELD. See how to obtain it
Checking sum from constructor , or
public long access_hash; } @@ -4808,7 +4808,7 @@ namespace TL { /// File ID, value of id parameter from public long id; - /// Checking sum, value of access_hash parameter from + /// REQUIRED FIELD. See how to obtain it
Checking sum, value of access_hash parameter from
public long access_hash; /// File ID, value of id parameter from @@ -4933,7 +4933,7 @@ namespace TL { /// Document ID public long id; - /// access_hash parameter from the constructor + /// REQUIRED FIELD. See how to obtain it
access_hash parameter from the constructor
public long access_hash; /// File reference public byte[] file_reference; @@ -5797,7 +5797,7 @@ namespace TL { /// ID public long id; - /// Access hash + /// REQUIRED FIELD. See how to obtain it
Access hash
public long access_hash; } /// Stickerset by short name, from tg://addstickers?set=short_name See @@ -6232,7 +6232,7 @@ namespace TL { /// Channel ID public long channel_id; - /// Access hash taken from the constructor + /// REQUIRED FIELD. See how to obtain it
Access hash taken from the constructor
public long access_hash; /// Channel ID @@ -7333,7 +7333,7 @@ namespace TL public int dc_id; /// ID of message, contains both the (32-bit, legacy) owner ID and the message ID, used only for Bot API backwards compatibility with 32-bit user ID. public long id; - /// Access hash of message + /// REQUIRED FIELD. See how to obtain it
Access hash of message
public long access_hash; /// DC ID to use when working with this inline message @@ -7351,7 +7351,7 @@ namespace TL public long owner_id; /// ID of message public int id; - /// Access hash of message + /// REQUIRED FIELD. See how to obtain it
Access hash of message
public long access_hash; /// DC ID to use when working with this inline message @@ -7653,7 +7653,7 @@ namespace TL { /// game ID from constructor public long id; - /// access hash from constructor + /// REQUIRED FIELD. See how to obtain it
access hash from constructor
public long access_hash; } ///
Game by short name See @@ -8343,7 +8343,7 @@ namespace TL { /// HTTP URL of file public string url; - /// Access hash + /// REQUIRED FIELD. See how to obtain it
Access hash
public long access_hash; /// Access hash @@ -8355,7 +8355,7 @@ namespace TL { /// Geolocation public InputGeoPoint geo_point; - /// Access hash + /// REQUIRED FIELD. See how to obtain it
Access hash
public long access_hash; /// Map width in pixels before applying scale; 16-1024 public int w; @@ -8620,7 +8620,7 @@ namespace TL { /// Call ID public long id; - /// Access hash + /// REQUIRED FIELD. See how to obtain it
Access hash
public long access_hash; } @@ -9673,7 +9673,7 @@ namespace TL { /// Secure file ID public long id; - /// Secure file access hash + /// REQUIRED FIELD. See how to obtain it
Secure file access hash
public long access_hash; /// Secure file ID @@ -10613,7 +10613,7 @@ namespace TL { /// Wallpaper ID public long id; - /// Access hash + /// REQUIRED FIELD. See how to obtain it
Access hash
public long access_hash; } ///
Wallpaper by slug (a unique ID) See @@ -10941,7 +10941,7 @@ namespace TL { /// ID public long id; - /// Access hash + /// REQUIRED FIELD. See how to obtain it
Access hash
public long access_hash; } ///
Theme by theme ID See @@ -11869,7 +11869,7 @@ namespace TL { /// Group call ID public long id; - /// Group call access hash + /// REQUIRED FIELD. See how to obtain it
Group call access hash
public long access_hash; } @@ -13694,14 +13694,14 @@ namespace TL { id = id, }); - ///
Returns full chat info according to its ID. See [bots: ✓] Possible codes: 400 (details) + /// This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a
Returns full chat info according to its ID. See [bots: ✓] Possible codes: 400 (details)
/// Chat ID public static Task Messages_GetFullChat(this Client client, long chat_id) => client.Invoke(new Messages_GetFullChat { chat_id = chat_id, }); - /// Chanages chat name and sends a service message on it. See [bots: ✓] Possible codes: 400 (details) + /// This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a
Chanages chat name and sends a service message on it. See [bots: ✓] Possible codes: 400 (details)
/// Chat ID /// New chat name, different from the old one public static Task Messages_EditChatTitle(this Client client, long chat_id, string title) @@ -13710,7 +13710,7 @@ namespace TL chat_id = chat_id, title = title, }); - /// Changes chat photo and sends a service message on it See [bots: ✓] Possible codes: 400 (details) + /// This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a
Changes chat photo and sends a service message on it See [bots: ✓] Possible codes: 400 (details)
/// Chat ID /// Photo to be set public static Task Messages_EditChatPhoto(this Client client, long chat_id, InputChatPhotoBase photo) @@ -13719,7 +13719,7 @@ namespace TL chat_id = chat_id, photo = photo, }); - /// Adds a user to a chat and sends a service message on it. See Possible codes: 400,403 (details) + /// This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a
Adds a user to a chat and sends a service message on it. See Possible codes: 400,403 (details)
/// Chat ID /// User ID to be added /// Number of last messages to be forwarded @@ -13730,7 +13730,7 @@ namespace TL user_id = user_id, fwd_limit = fwd_limit, }); - /// Deletes a user from a chat and sends a service message on it. See [bots: ✓] Possible codes: 400 (details) + /// This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a
Deletes a user from a chat and sends a service message on it. See [bots: ✓] Possible codes: 400 (details)
/// Remove the entire chat history of the specified user in this chat. /// Chat ID /// User ID to be deleted @@ -13974,7 +13974,7 @@ namespace TL id = id, increment = increment, }); - /// Make a user admin in a legacy group. See Possible codes: 400 (details) + /// This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a
Make a user admin in a legacy group. See Possible codes: 400 (details)
/// The ID of the group /// The user to make admin /// Whether to make him admin @@ -13985,7 +13985,7 @@ namespace TL user_id = user_id, is_admin = is_admin, }); - /// Turn a legacy group into a supergroup See Possible codes: 400,403 (details) + /// This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a
Turn a legacy group into a supergroup See Possible codes: 400,403 (details)
/// Legacy group to migrate public static Task Messages_MigrateChat(this Client client, long chat_id) => client.Invoke(new Messages_MigrateChat @@ -14830,7 +14830,7 @@ namespace TL { peer = peer, }); - /// Delete a chat See Possible codes: 400 (details) + /// This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a
Delete a chat See Possible codes: 400 (details)
/// Chat ID public static Task Messages_DeleteChat(this Client client, long chat_id) => client.Invoke(new Messages_DeleteChat diff --git a/src/TL.Table.cs b/src/TL.Table.cs index 5a3ec92..6856fa3 100644 --- a/src/TL.Table.cs +++ b/src/TL.Table.cs @@ -6,7 +6,7 @@ namespace TL { public static class Layer { - public const int Version = 135; // fetched 08/12/2021 14:03:48 + public const int Version = 135; // fetched 27/11/2021 01:12:30 internal const uint VectorCtor = 0x1CB5C415; internal const uint NullCtor = 0x56730BCC; internal const uint RpcResultCtor = 0xF35C6D01;