mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2026-04-05 06:25:30 +00:00
added MarkdownToEntities
This commit is contained in:
parent
b94ec0abca
commit
e615f83db6
3 changed files with 102 additions and 2 deletions
13
EXAMPLES.md
13
EXAMPLES.md
|
|
@ -15,11 +15,12 @@ Remember that these are just simple example codes that you should adjust to your
|
|||
```csharp
|
||||
using var client = new WTelegram.Client(Environment.GetEnvironmentVariable);
|
||||
await client.LoginUserIfNeeded();
|
||||
var resolved = await client.Contacts_ResolveUsername("username");
|
||||
var resolved = await client.Contacts_ResolveUsername("username"); // without the @
|
||||
await client.SendMessageAsync(resolved, "Hello!");
|
||||
```
|
||||
*Note: This also works if the @username points to a chat, but you must join the chat before posting there.
|
||||
You can check `resolved` properties to ensure it's a user or a chat. If the username is invalid/unused, the API call raises an exception.*
|
||||
|
||||
### Send a message to someone by phone number
|
||||
```csharp
|
||||
using var client = new WTelegram.Client(Environment.GetEnvironmentVariable);
|
||||
|
|
@ -30,6 +31,16 @@ if (contacts.imported.Length > 0)
|
|||
```
|
||||
*Note: To prevent spam, Telegram may restrict your ability to add new phone numbers.*
|
||||
|
||||
### Send a Markdown message to ourself (Saved Messages)
|
||||
```csharp
|
||||
using var client = new WTelegram.Client(Environment.GetEnvironmentVariable);
|
||||
await client.LoginUserIfNeeded();
|
||||
var text = "Hello __dear *friend*__!\nEnjoy this `userbot` written with [WTelegramClient](https://github.com/wiz0u/WTelegramClient)";
|
||||
var entities = client.MarkdownToEntities(ref text);
|
||||
await client.SendMessageAsync(InputPeer.Self, text, entities: entities);
|
||||
```
|
||||
See [MarkdownV2 formatting style](https://core.telegram.org/bots/api/#markdownv2-style) for details.
|
||||
|
||||
### List all chats (groups/channels) the user is in and send a message to one
|
||||
```csharp
|
||||
using var client = new WTelegram.Client(Environment.GetEnvironmentVariable);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue