diff --git a/EXAMPLES.md b/EXAMPLES.md
index ca291dd..70b43c7 100644
--- a/EXAMPLES.md
+++ b/EXAMPLES.md
@@ -126,6 +126,7 @@ long chatId = long.Parse(Console.ReadLine());
await client.SendMessageAsync(chats.chats[chatId], "Hello, World");
```
Notes:
+- This list does not include discussions with other users. For this, you need to use [Messages_GetDialogs](#list-dialogs).
- The list returned by Messages_GetAllChats contains the `access_hash` for those chats. Read [FAQ #4](FAQ.MD#access-hash) about this.
- If a small private chat group has been migrated to a supergroup, you may find both the old `Chat` and a `Channel` with different IDs in the `chats.chats` result,
but the old `Chat` will be marked with flag [deactivated] and should not be used anymore. See [Terminology in ReadMe](README.md#terminology).
diff --git a/src/Client.cs b/src/Client.cs
index 5130676..939eddc 100644
--- a/src/Client.cs
+++ b/src/Client.cs
@@ -116,8 +116,8 @@ namespace WTelegram
public static string DefaultConfig(string what) => what switch
{
"session_pathname" => Path.Combine(
- Path.GetDirectoryName(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory.TrimEnd(Path.DirectorySeparatorChar))),
- "WTelegram.session"),
+ Path.GetDirectoryName(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory.TrimEnd(Path.DirectorySeparatorChar)))
+ ?? AppDomain.CurrentDomain.BaseDirectory, "WTelegram.session"),
#if DEBUG
"server_address" => "149.154.167.40:443",
#else
diff --git a/src/Helpers.cs b/src/Helpers.cs
index 7fb65b0..2fbfa03 100644
--- a/src/Helpers.cs
+++ b/src/Helpers.cs
@@ -14,9 +14,6 @@ namespace WTelegram
/// For serializing indented Json with fields included
public static readonly JsonSerializerOptions JsonOptions = new() { IncludeFields = true, WriteIndented = true, IgnoreReadOnlyProperties = true };
- public static V GetOrCreate(this Dictionary dictionary, K key) where V : new()
- => dictionary.TryGetValue(key, out V value) ? value : dictionary[key] = new V();
-
private static readonly ConsoleColor[] LogLevelToColor = new[] { ConsoleColor.DarkGray, ConsoleColor.DarkCyan, ConsoleColor.Cyan,
ConsoleColor.Yellow, ConsoleColor.Red, ConsoleColor.Magenta, ConsoleColor.DarkBlue };
private static void DefaultLogger(int level, string message)
@@ -26,6 +23,9 @@ namespace WTelegram
Console.ResetColor();
}
+ public static V GetOrCreate(this Dictionary dictionary, K key) where V : new()
+ => dictionary.TryGetValue(key, out V value) ? value : dictionary[key] = new V();
+
/// Get a cryptographic random 64-bit value
public static long RandomLong()
{
@@ -42,11 +42,11 @@ namespace WTelegram
internal static byte[] ToBigEndian(ulong value) // variable-size buffer
{
- int i;
- var temp = value;
- for (i = 1; (temp >>= 8) != 0; i++) ;
+ int i = 1;
+ for (ulong temp = value; (temp >>= 8) != 0; ) i++;
var result = new byte[i];
- while (--i >= 0) { result[i] = (byte)value; value >>= 8; }
+ for (; --i >= 0; value >>= 8)
+ result[i] = (byte)value;
return result;
}
diff --git a/src/TL.Helpers.cs b/src/TL.Helpers.cs
index 241ae09..8b6efa9 100644
--- a/src/TL.Helpers.cs
+++ b/src/TL.Helpers.cs
@@ -257,6 +257,52 @@ namespace TL
partial class Updates_DifferenceSlice { public override Updates_State State => intermediate_state; }
partial class Updates_DifferenceTooLong { public override Updates_State State => null; }
+ partial class UpdatesBase
+ {
+ public abstract Update[] UpdateList { get; }
+ public virtual Dictionary Users => NoUsers;
+ public virtual Dictionary Chats => NoChats;
+ private static readonly Dictionary NoUsers = new();
+ private static readonly Dictionary NoChats = new();
+ }
+ partial class UpdatesCombined
+ {
+ public override Update[] UpdateList => updates;
+ public override Dictionary Users => users;
+ public override Dictionary Chats => chats;
+ }
+ partial class Updates
+ {
+ public override Update[] UpdateList => updates;
+ public override Dictionary Users => users;
+ public override Dictionary Chats => chats;
+ }
+ partial class UpdatesTooLong { public override Update[] UpdateList => Array.Empty(); }
+ partial class UpdateShort { public override Update[] UpdateList => new[] { update }; }
+ partial class UpdateShortSentMessage { public override Update[] UpdateList => Array.Empty(); }
+ partial class UpdateShortMessage { public override Update[] UpdateList => new[] { new UpdateNewMessage
+ {
+ message = new Message
+ {
+ flags = (Message.Flags)flags | Message.Flags.has_from_id, id = id, date = date,
+ message = message, entities = entities, reply_to = reply_to,
+ from_id = new PeerUser { user_id = user_id },
+ peer_id = new PeerUser { user_id = user_id },
+ fwd_from = fwd_from, via_bot_id = via_bot_id, ttl_period = ttl_period
+ }, pts = pts, pts_count = pts_count
+ } }; }
+ partial class UpdateShortChatMessage { public override Update[] UpdateList => new[] { new UpdateNewMessage
+ {
+ message = new Message
+ {
+ flags = (Message.Flags)flags | Message.Flags.has_from_id, id = id, date = date,
+ message = message, entities = entities, reply_to = reply_to,
+ from_id = new PeerUser { user_id = from_id },
+ peer_id = new PeerChat { chat_id = chat_id },
+ fwd_from = fwd_from, via_bot_id = via_bot_id, ttl_period = ttl_period
+ }, pts = pts, pts_count = pts_count
+ } }; }
+
partial class EncryptedFile
{
public static implicit operator InputEncryptedFile(EncryptedFile file) => file == null ? null : new InputEncryptedFile { id = file.id, access_hash = file.access_hash };
@@ -365,54 +411,10 @@ namespace TL
partial class ChannelParticipantBanned { public override long UserID => peer is PeerUser pu ? pu.user_id : 0; }
partial class ChannelParticipantLeft { public override long UserID => peer is PeerUser pu ? pu.user_id : 0; }
- partial class UpdatesBase
- {
- public abstract Update[] UpdateList { get; }
- public virtual Dictionary Users => NoUsers;
- public virtual Dictionary Chats => NoChats;
- private static readonly Dictionary NoUsers = new();
- private static readonly Dictionary NoChats = new();
- }
- partial class UpdatesCombined
- {
- public override Update[] UpdateList => updates;
- public override Dictionary Users => users;
- public override Dictionary Chats => chats;
- }
- partial class Updates
- {
- public override Update[] UpdateList => updates;
- public override Dictionary Users => users;
- public override Dictionary Chats => chats;
- }
- partial class UpdatesTooLong { public override Update[] UpdateList => Array.Empty(); }
- partial class UpdateShort { public override Update[] UpdateList => new[] { update }; }
- partial class UpdateShortSentMessage { public override Update[] UpdateList => Array.Empty(); }
- partial class UpdateShortMessage { public override Update[] UpdateList => new[] { new UpdateNewMessage
- {
- message = new Message
- {
- flags = (Message.Flags)flags | Message.Flags.has_from_id, id = id, date = date,
- message = message, entities = entities, reply_to = reply_to,
- from_id = new PeerUser { user_id = user_id },
- peer_id = new PeerUser { user_id = user_id },
- fwd_from = fwd_from, via_bot_id = via_bot_id, ttl_period = ttl_period
- }, pts = pts, pts_count = pts_count
- } }; }
- partial class UpdateShortChatMessage { public override Update[] UpdateList => new[] { new UpdateNewMessage
- {
- message = new Message
- {
- flags = (Message.Flags)flags | Message.Flags.has_from_id, id = id, date = date,
- message = message, entities = entities, reply_to = reply_to,
- from_id = new PeerUser { user_id = from_id },
- peer_id = new PeerChat { chat_id = chat_id },
- fwd_from = fwd_from, via_bot_id = via_bot_id, ttl_period = ttl_period
- }, pts = pts, pts_count = pts_count
- } }; }
-
partial class Messages_PeerDialogs { public IPeerInfo UserOrChat(DialogBase dialog) => dialog.Peer.UserOrChat(users, chats); }
+ partial class WebDocument { public static implicit operator InputWebFileLocation(WebDocument doc) => new() { url = doc.url, access_hash = doc.access_hash }; }
+
partial class SecureFile
{
public static implicit operator InputSecureFile(SecureFile file) => new() { id = file.id, access_hash = file.access_hash };
diff --git a/src/TL.Schema.cs b/src/TL.Schema.cs
index b63078c..8a21a0d 100644
--- a/src/TL.Schema.cs
+++ b/src/TL.Schema.cs
@@ -8298,7 +8298,7 @@ namespace TL
}
/// Remote document See
[TLDef(0x1C570ED1)]
- public class WebDocument : WebDocumentBase
+ public partial class WebDocument : WebDocumentBase
{
/// Document URL
public string url;