diff --git a/src/Client.cs b/src/Client.cs
index faca522..9174e7b 100644
--- a/src/Client.cs
+++ b/src/Client.cs
@@ -1084,7 +1084,38 @@ namespace WTelegram
return user;
}
-#region TL-Helpers
+ /// Enable the collection of id/access_hash pairs (experimental)
+ public bool CollectAccessHash { get; set; }
+ readonly Dictionary> _accessHashes = new();
+ public IEnumerable> AllAccessHashesFor() where T : IObject
+ => _accessHashes.GetValueOrDefault(typeof(T));
+ /// Retrieve the access_hash associated with this id (for a TL class) if it was collected
+ /// This requires to be set to first.
+ ///
See Examples/Program_CollectAccessHash.cs for how to use this
+ /// a TL object class. For example User, Channel or Photo
+ public long GetAccessHashFor(long id) where T : IObject
+ {
+ lock (_accessHashes)
+ return _accessHashes.GetOrCreate(typeof(T)).TryGetValue(id, out var access_hash) ? access_hash : 0;
+ }
+ public void SetAccessHashFor(long id, long access_hash) where T : IObject
+ {
+ lock (_accessHashes)
+ _accessHashes.GetOrCreate(typeof(T))[id] = access_hash;
+ }
+ internal void UpdateAccessHash(object obj, Type type, object access_hash)
+ {
+ if (!CollectAccessHash) return;
+ if (access_hash is not long accessHash) return;
+ if (type.GetField("id") is not FieldInfo idField) return;
+ if (idField.GetValue(obj) is not long id)
+ if (idField.GetValue(obj) is not int idInt) return;
+ else id = idInt;
+ lock (_accessHashes)
+ _accessHashes.GetOrCreate(type)[id] = accessHash;
+ }
+
+ #region TL-Helpers
/// Helper function to upload a file to Telegram
/// Path to the file to upload
/// (optional) Callback for tracking the progression of the transfer
@@ -1479,37 +1510,13 @@ namespace WTelegram
await Task.WhenAll(Enumerable.Range('a', 26).Select(c => GetWithFilter(recurse(filter, (char)c), recurse)));
}
}
- #endregion
- /// Enable the collection of id/access_hash pairs (experimental)
- public bool CollectAccessHash { get; set; }
- readonly Dictionary> _accessHashes = new();
- public IEnumerable> AllAccessHashesFor() where T : IObject
- => _accessHashes.GetValueOrDefault(typeof(T));
- /// Retrieve the access_hash associated with this id (for a TL class) if it was collected
- /// This requires to be set to first.
- ///
See Examples/Program_CollectAccessHash.cs for how to use this
- /// a TL object class. For example User, Channel or Photo
- public long GetAccessHashFor(long id) where T : IObject
+ public Task GetFullChat(InputPeer peer) => peer switch
{
- lock (_accessHashes)
- return _accessHashes.GetOrCreate(typeof(T)).TryGetValue(id, out var access_hash) ? access_hash : 0;
- }
- public void SetAccessHashFor(long id, long access_hash) where T : IObject
- {
- lock (_accessHashes)
- _accessHashes.GetOrCreate(typeof(T))[id] = access_hash;
- }
- internal void UpdateAccessHash(object obj, Type type, object access_hash)
- {
- if (!CollectAccessHash) return;
- if (access_hash is not long accessHash) return;
- if (type.GetField("id") is not FieldInfo idField) return;
- if (idField.GetValue(obj) is not long id)
- if (idField.GetValue(obj) is not int idInt) return;
- else id = idInt;
- lock (_accessHashes)
- _accessHashes.GetOrCreate(type)[id] = accessHash;
- }
+ InputPeerChat chat => this.Messages_GetFullChat(chat.chat_id),
+ InputPeerChannel channel => this.Channels_GetFullChannel(channel),
+ _ => throw new ArgumentException("This method works on Chat & Channel only"),
+ };
+ #endregion
}
}