2024-05-19 21:02:17 +00:00
|
|
|
|
using System.Text;
|
2022-08-30 15:00:58 +00:00
|
|
|
|
|
2024-05-20 23:00:47 +00:00
|
|
|
|
namespace SharpChat.PacketsS2C {
|
|
|
|
|
public class UsersPopulateS2CPacket : SockChatS2CPacket {
|
2024-05-19 02:17:51 +00:00
|
|
|
|
public record ListEntry(long Id, string Name, Colour Colour, int Rank, UserPermissions Perms, bool Visible);
|
2022-08-30 15:00:58 +00:00
|
|
|
|
|
2024-05-10 18:29:48 +00:00
|
|
|
|
private readonly ListEntry[] Entries;
|
|
|
|
|
|
2024-05-20 23:00:47 +00:00
|
|
|
|
public UsersPopulateS2CPacket(ListEntry[] entries) {
|
2024-05-19 01:53:14 +00:00
|
|
|
|
Entries = entries;
|
2022-08-30 15:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-10 15:24:43 +00:00
|
|
|
|
public override string Pack() {
|
2023-02-07 15:01:56 +00:00
|
|
|
|
StringBuilder sb = new();
|
2022-08-30 15:00:58 +00:00
|
|
|
|
|
2024-05-10 18:29:48 +00:00
|
|
|
|
sb.AppendFormat("7\t0\t{0}", Entries.Length);
|
2022-08-30 15:00:58 +00:00
|
|
|
|
|
2024-05-10 18:29:48 +00:00
|
|
|
|
foreach(ListEntry entry in Entries)
|
2024-05-10 17:28:52 +00:00
|
|
|
|
sb.AppendFormat(
|
|
|
|
|
"\t{0}\t{1}\t{2}\t{3} {4} {5} {6} {7}\t{8}",
|
2024-05-10 18:29:48 +00:00
|
|
|
|
entry.Id,
|
|
|
|
|
entry.Name,
|
|
|
|
|
entry.Colour,
|
|
|
|
|
entry.Rank,
|
2024-05-19 02:17:51 +00:00
|
|
|
|
entry.Perms.HasFlag(UserPermissions.KickUser) ? 1 : 0,
|
|
|
|
|
entry.Perms.HasFlag(UserPermissions.ViewLogs) ? 1 : 0,
|
|
|
|
|
entry.Perms.HasFlag(UserPermissions.SetOwnNickname) ? 1 : 0,
|
|
|
|
|
entry.Perms.HasFlag(UserPermissions.CreateChannel) ? (
|
|
|
|
|
entry.Perms.HasFlag(UserPermissions.SetChannelPermanent) ? 2 : 1
|
2024-05-10 18:29:48 +00:00
|
|
|
|
) : 0,
|
|
|
|
|
entry.Visible ? 1 : 0
|
2024-05-10 17:28:52 +00:00
|
|
|
|
);
|
2022-08-30 15:00:58 +00:00
|
|
|
|
|
2024-05-10 15:24:43 +00:00
|
|
|
|
return sb.ToString();
|
2022-08-30 15:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|