documentation

This commit is contained in:
Wizou 2021-12-24 07:21:02 +01:00
parent 27f62b7537
commit 2881155f8b
5 changed files with 44 additions and 42 deletions

View file

@ -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 });
```
<a name="history"></a>