mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2026-04-04 14:07:41 +00:00
Support IDictionary in CollectUsersChats (closes #137)
Renamed UserID => UserId due to discrepancy
This commit is contained in:
parent
ddfa095f1a
commit
2f79411fce
3 changed files with 17 additions and 17 deletions
|
|
@ -527,7 +527,7 @@ namespace WTelegram
|
||||||
foreach (var kvp in ccp.users) result.users[kvp.Key] = kvp.Value;
|
foreach (var kvp in ccp.users) result.users[kvp.Key] = kvp.Value;
|
||||||
lock (participants)
|
lock (participants)
|
||||||
foreach (var participant in ccp.participants)
|
foreach (var participant in ccp.participants)
|
||||||
if (user_ids.Add(participant.UserID))
|
if (user_ids.Add(participant.UserId))
|
||||||
participants.Add(participant);
|
participants.Add(participant);
|
||||||
offset += ccp.participants.Length;
|
offset += ccp.participants.Length;
|
||||||
if (offset >= ccp.count || ccp.participants.Length == 0) break;
|
if (offset >= ccp.count || ccp.participants.Length == 0) break;
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ namespace TL
|
||||||
private class CollectorPeer : Peer
|
private class CollectorPeer : Peer
|
||||||
{
|
{
|
||||||
public override long ID => 0;
|
public override long ID => 0;
|
||||||
internal Dictionary<long, User> _users;
|
internal IDictionary<long, User> _users;
|
||||||
internal Dictionary<long, ChatBase> _chats;
|
internal IDictionary<long, ChatBase> _chats;
|
||||||
protected internal override IPeerInfo UserOrChat(Dictionary<long, User> users, Dictionary<long, ChatBase> chats)
|
protected internal override IPeerInfo UserOrChat(IDictionary<long, User> users, IDictionary<long, ChatBase> chats)
|
||||||
{
|
{
|
||||||
lock (_users)
|
lock (_users)
|
||||||
foreach (var user in users.Values)
|
foreach (var user in users.Values)
|
||||||
|
|
@ -34,7 +34,7 @@ namespace TL
|
||||||
|
|
||||||
/// <summary>Accumulate users/chats found in this structure in your dictionaries, ignoring <see href="https://core.telegram.org/api/min">Min constructors</see> when the full object is already stored</summary>
|
/// <summary>Accumulate users/chats found in this structure in your dictionaries, ignoring <see href="https://core.telegram.org/api/min">Min constructors</see> when the full object is already stored</summary>
|
||||||
/// <param name="structure">The structure having a <c>users</c></param>
|
/// <param name="structure">The structure having a <c>users</c></param>
|
||||||
public static void CollectUsersChats(this IPeerResolver structure, Dictionary<long, User> users, Dictionary<long, ChatBase> chats)
|
public static void CollectUsersChats(this IPeerResolver structure, IDictionary<long, User> users, IDictionary<long, ChatBase> chats)
|
||||||
=> structure.UserOrChat(new CollectorPeer { _users = users, _chats = chats });
|
=> structure.UserOrChat(new CollectorPeer { _users = users, _chats = chats });
|
||||||
|
|
||||||
public static Task<Messages_Chats> Messages_GetChats(this Client _) => throw new WTException("The method you're looking for is Messages_GetAllChats");
|
public static Task<Messages_Chats> Messages_GetChats(this Client _) => throw new WTException("The method you're looking for is Messages_GetAllChats");
|
||||||
|
|
|
||||||
|
|
@ -118,25 +118,25 @@ namespace TL
|
||||||
partial class Peer
|
partial class Peer
|
||||||
{
|
{
|
||||||
public abstract long ID { get; }
|
public abstract long ID { get; }
|
||||||
protected internal abstract IPeerInfo UserOrChat(Dictionary<long, User> users, Dictionary<long, ChatBase> chats);
|
protected internal abstract IPeerInfo UserOrChat(IDictionary<long, User> users, IDictionary<long, ChatBase> chats);
|
||||||
}
|
}
|
||||||
partial class PeerUser
|
partial class PeerUser
|
||||||
{
|
{
|
||||||
public override string ToString() => "user " + user_id;
|
public override string ToString() => "user " + user_id;
|
||||||
public override long ID => user_id;
|
public override long ID => user_id;
|
||||||
protected internal override IPeerInfo UserOrChat(Dictionary<long, User> users, Dictionary<long, ChatBase> chats) => users.TryGetValue(user_id, out var user) ? user : null;
|
protected internal override IPeerInfo UserOrChat(IDictionary<long, User> users, IDictionary<long, ChatBase> chats) => users.TryGetValue(user_id, out var user) ? user : null;
|
||||||
}
|
}
|
||||||
partial class PeerChat
|
partial class PeerChat
|
||||||
{
|
{
|
||||||
public override string ToString() => "chat " + chat_id;
|
public override string ToString() => "chat " + chat_id;
|
||||||
public override long ID => chat_id;
|
public override long ID => chat_id;
|
||||||
protected internal override IPeerInfo UserOrChat(Dictionary<long, User> users, Dictionary<long, ChatBase> chats) => chats.TryGetValue(chat_id, out var chat) ? chat : null;
|
protected internal override IPeerInfo UserOrChat(IDictionary<long, User> users, IDictionary<long, ChatBase> chats) => chats.TryGetValue(chat_id, out var chat) ? chat : null;
|
||||||
}
|
}
|
||||||
partial class PeerChannel
|
partial class PeerChannel
|
||||||
{
|
{
|
||||||
public override string ToString() => "channel " + channel_id;
|
public override string ToString() => "channel " + channel_id;
|
||||||
public override long ID => channel_id;
|
public override long ID => channel_id;
|
||||||
protected internal override IPeerInfo UserOrChat(Dictionary<long, User> users, Dictionary<long, ChatBase> chats) => chats.TryGetValue(channel_id, out var chat) ? chat : null;
|
protected internal override IPeerInfo UserOrChat(IDictionary<long, User> users, IDictionary<long, ChatBase> chats) => chats.TryGetValue(channel_id, out var chat) ? chat : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
partial class UserBase : IPeerInfo
|
partial class UserBase : IPeerInfo
|
||||||
|
|
@ -191,7 +191,7 @@ namespace TL
|
||||||
/// <summary>returns true if you're banned of any of these rights</summary>
|
/// <summary>returns true if you're banned of any of these rights</summary>
|
||||||
public abstract bool IsBanned(ChatBannedRights.Flags flags = 0);
|
public abstract bool IsBanned(ChatBannedRights.Flags flags = 0);
|
||||||
public abstract InputPeer ToInputPeer();
|
public abstract InputPeer ToInputPeer();
|
||||||
public static implicit operator InputPeer(ChatBase chat) => chat.ToInputPeer();
|
public static implicit operator InputPeer(ChatBase chat) => chat?.ToInputPeer();
|
||||||
}
|
}
|
||||||
partial class ChatEmpty
|
partial class ChatEmpty
|
||||||
{
|
{
|
||||||
|
|
@ -542,22 +542,22 @@ namespace TL
|
||||||
partial class ChannelParticipantBase
|
partial class ChannelParticipantBase
|
||||||
{
|
{
|
||||||
public virtual bool IsAdmin => false;
|
public virtual bool IsAdmin => false;
|
||||||
public abstract long UserID { get; }
|
public abstract long UserId { get; }
|
||||||
}
|
}
|
||||||
partial class ChannelParticipantCreator
|
partial class ChannelParticipantCreator
|
||||||
{
|
{
|
||||||
public override bool IsAdmin => true;
|
public override bool IsAdmin => true;
|
||||||
public override long UserID => user_id;
|
public override long UserId => user_id;
|
||||||
}
|
}
|
||||||
partial class ChannelParticipantAdmin
|
partial class ChannelParticipantAdmin
|
||||||
{
|
{
|
||||||
public override bool IsAdmin => true;
|
public override bool IsAdmin => true;
|
||||||
public override long UserID => user_id;
|
public override long UserId => user_id;
|
||||||
}
|
}
|
||||||
partial class ChannelParticipant { public override long UserID => user_id; }
|
partial class ChannelParticipant { public override long UserId => user_id; }
|
||||||
partial class ChannelParticipantSelf { public override long UserID => user_id; }
|
partial class ChannelParticipantSelf { public override long UserId => user_id; }
|
||||||
partial class ChannelParticipantBanned { public override long UserID => peer is PeerUser pu ? pu.user_id : 0; }
|
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 ChannelParticipantLeft { public override long UserId => peer is PeerUser pu ? pu.user_id : 0; }
|
||||||
|
|
||||||
partial class Messages_PeerDialogs { public IPeerInfo UserOrChat(DialogBase dialog) => dialog.Peer?.UserOrChat(users, chats); }
|
partial class Messages_PeerDialogs { public IPeerInfo UserOrChat(DialogBase dialog) => dialog.Peer?.UserOrChat(users, chats); }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue