diff --git a/.github/dev.yml b/.github/dev.yml
index 04417b8..ddfdabc 100644
--- a/.github/dev.yml
+++ b/.github/dev.yml
@@ -2,7 +2,7 @@ pr: none
trigger:
- master
-name: 3.0.2-dev.$(Rev:r)
+name: 3.0.4-dev.$(Rev:r)
pool:
vmImage: ubuntu-latest
diff --git a/EXAMPLES.md b/EXAMPLES.md
index 59bf859..35a535c 100644
--- a/EXAMPLES.md
+++ b/EXAMPLES.md
@@ -7,7 +7,7 @@ using System.Linq;
using TL;
using var client = new WTelegram.Client(Environment.GetEnvironmentVariable);
-var myself = await client.LoginUserIfNeeded();
+await client.LoginUserIfNeeded();
```
In this case, environment variables are used for configuration so make sure to
@@ -58,7 +58,7 @@ If the username is invalid/unused, the API call raises an RpcException.*
### Convert message to/from HTML or Markdown, and send it to ourself (Saved Messages)
```csharp
// HTML-formatted text:
-var text = $"Hello dear {HtmlText.Escape(myself.first_name)}\n" +
+var text = $"Hello dear {HtmlText.Escape(client.User.first_name)}\n" +
"Enjoy this userbot written with WTelegramClient";
var entities = client.HtmlToEntities(ref text);
var sent = await client.SendMessageAsync(InputPeer.Self, text, entities: entities);
@@ -67,7 +67,7 @@ text = client.EntitiesToHtml(sent.message, sent.entities);
```
```csharp
// Markdown-style text:
-var text2 = $"Hello __dear *{Markdown.Escape(myself.first_name)}*__\n" +
+var text2 = $"Hello __dear *{Markdown.Escape(client.User.first_name)}*__\n" +
"Enjoy this `userbot` written with [WTelegramClient](https://github.com/wiz0u/WTelegramClient)";
var entities2 = client.MarkdownToEntities(ref text2);
var sent2 = await client.SendMessageAsync(InputPeer.Self, text2, entities: entities2);
@@ -147,7 +147,7 @@ var participants = await client.Channels_GetAllParticipants(channel);
You can use specific filters, for example to list only the channel owner/admins:
```csharp
var participants = await client.Channels_GetParticipants(channel, filter: new ChannelParticipantsAdmins());
-foreach (var participant in participants.participants) // This is the correct way to enumerate the result
+foreach (var participant in participants.participants) // This is the better way to enumerate the result
{
var user = participants.users[participant.UserID];
if (participant is ChannelParticipantCreator cpc) Console.WriteLine($"{user} is the owner '{cpc.rank}'");
@@ -232,7 +232,7 @@ var inputMedias = new List
{
photoFromTelegram, // PhotoBase has implicit conversion to InputMediaPhoto
new InputMediaUploadedPhoto { file = uploadedFile },
- new InputMediaPhotoExternal() { url = photoUrl },
+ new InputMediaPhotoExternal { url = photoUrl },
};
await client.SendAlbumAsync(InputPeer.Self, inputMedias, "My first album");
```
@@ -349,7 +349,7 @@ var messages = await client.Messages_Search(chat, lim
foreach (var msg in messages.Messages)
await client.Messages_SendReaction(chat, msg.ID, reaction: new[] { reaction });
```
-*Note: you can find custom emoji document IDs via API methods like [Messages_GetFeaturedEmojiStickers](https://corefork.telegram.org/method/messages.getFeaturedEmojiStickers) or inspecting incoming messages. Access hash is not required*
+*Note: you can find custom emoji document IDs via API methods like [Messages_GetFeaturedEmojiStickers](https://corefork.telegram.org/methods#working-with-custom-animated-emojis) or inspecting incoming messages. Access hash is not required*
@@ -407,7 +407,7 @@ var contacts = await client.Contacts_ImportContacts(new[] { new InputPhoneContac
if (contacts.imported.Length > 0)
await client.SendMessageAsync(contacts.users[contacts.imported[0].user_id], "Hello!");
```
-*Note: Don't use this method too much. To prevent spam, Telegram may restrict your ability to add new phone numbers.*
+*Note: Don't use this method too much. To prevent spam, Telegram may restrict your ability to add new phone numbers or ban your account.*
### Retrieve the current user's contacts list
@@ -457,7 +457,7 @@ client.TcpHandler = async (address, port) =>
var proxy = new Socks5ProxyClient(ProxyHost, ProxyPort, ProxyUsername, ProxyPassword);
return proxy.CreateConnection(address, port);
};
-var myself = await client.LoginUserIfNeeded();
+await client.LoginUserIfNeeded();
```
or with [xNetStandard](https://www.nuget.org/packages/xNetStandard/):
```csharp
@@ -472,7 +472,7 @@ MTProxy (MTProto proxy) can be used to prevent ISP blocking Telegram servers, th
```csharp
using var client = new WTelegram.Client(Environment.GetEnvironmentVariable);
client.MTProxyUrl = "http://t.me/proxy?server=...&port=...&secret=...";
-var myself = await client.LoginUserIfNeeded();
+await client.LoginUserIfNeeded();
```
You can find a list of working MTProxies in channels like [@ProxyMTProto](https://t.me/ProxyMTProto) or [@MTProxyT](https://t.me/MTProxyT) *(right-click the "Connect" buttons)*
If your Telegram client is already connected to such MTPROTO proxy, you can also export its URL by clicking on the shield button  and then **⋮** > **Share**
diff --git a/src/TL.Helpers.cs b/src/TL.Helpers.cs
index 0e8f82e..3bf8380 100644
--- a/src/TL.Helpers.cs
+++ b/src/TL.Helpers.cs
@@ -129,6 +129,7 @@ namespace TL
{
public override long ID => id;
public override bool IsActive => (flags & Flags.deleted) == 0;
+ public string MainUsername => username ?? usernames?.FirstOrDefault(u => u.flags.HasFlag(Username.Flags.active))?.username;
public override string ToString() => username != null ? '@' + username : last_name == null ? first_name : $"{first_name} {last_name}";
public override InputPeer ToInputPeer() => new InputPeerUser(id, access_hash);
protected override InputUser ToInputUser() => new(id, access_hash);
diff --git a/src/TL.Schema.cs b/src/TL.Schema.cs
index b785fb9..eb74e8c 100644
--- a/src/TL.Schema.cs
+++ b/src/TL.Schema.cs
@@ -3207,7 +3207,7 @@ namespace TL
public DateTime date;
/// New profile photo
public UserProfilePhoto photo;
- /// (), if one of the previously used photos is set a profile photo.
+ /// (), if one of the previously used photos is set a profile photo.
public bool previous;
}
/// New encrypted message. See
diff --git a/src/TL.SchemaFuncs.cs b/src/TL.SchemaFuncs.cs
index 081d365..5eb402f 100644
--- a/src/TL.SchemaFuncs.cs
+++ b/src/TL.SchemaFuncs.cs
@@ -290,7 +290,7 @@ namespace TL
/// Avoid receiving (silent and invisible background) notifications. Useful to save battery.
/// Device token type, see PUSH updates for the possible values.
/// Device token, see PUSH updates for the possible values.
- /// If is transmitted, a sandbox-certificate will be used during transmission.
+ /// If is transmitted, a sandbox-certificate will be used during transmission.
/// For FCM and APNS VoIP, optional encryption key used to encrypt push notifications
/// List of user identifiers of other users currently using the client
public static Task Account_RegisterDevice(this Client client, int token_type, string token, bool app_sandbox, byte[] secret, long[] other_uids, bool no_muted = false)
@@ -354,7 +354,7 @@ namespace TL
});
/// Updates online user status. See Possible codes: 403 (details)
- /// If is transmitted, user status will change to .
+ /// If is transmitted, user status will change to .
public static Task Account_UpdateStatus(this Client client, bool offline)
=> client.Invoke(new Account_UpdateStatus
{
@@ -1656,7 +1656,7 @@ namespace TL
/// Send typing event by the current user to a secret chat. See Possible codes: 400 (details)
/// Secret chat ID
- /// Typing.
Possible values:
, if the user started typing and more than 5 seconds have passed since the last request
, if the user stopped typing
+ /// Typing.
Possible values:
, if the user started typing and more than 5 seconds have passed since the last request
, if the user stopped typing
public static Task Messages_SetEncryptedTyping(this Client client, InputEncryptedChat peer, bool typing)
=> client.Invoke(new Messages_SetEncryptedTyping
{