sharp-chat/SharpChat/Packet/UserConnectPacket.cs

42 lines
1.4 KiB
C#
Raw Normal View History

namespace SharpChat.Packet {
public class UserConnectPacket : SockChatTimedS2CPacket {
private readonly long UserId;
private readonly string UserName;
private readonly Colour UserColour;
private readonly int UserRank;
private readonly UserPermissions UserPerms;
2022-08-30 15:00:58 +00:00
public UserConnectPacket(
long userId,
string userName,
Colour userColour,
int userRank,
UserPermissions userPerms
) {
UserId = userId;
UserName = userName;
UserColour = userColour;
UserRank = userRank;
UserPerms = userPerms;
2022-08-30 15:00:58 +00:00
}
2024-05-10 15:24:43 +00:00
public override string Pack() {
2024-05-10 17:28:52 +00:00
return string.Format(
"1\t{0}\t{1}\t{2}\t{3}\t{4} {5} {6} {7} {8}\t{9}",
TimeStamp.ToUnixTimeSeconds(),
UserId,
UserName,
UserColour,
UserRank,
UserPerms.HasFlag(UserPermissions.KickUser) ? 1 : 0,
UserPerms.HasFlag(UserPermissions.ViewLogs) ? 1 : 0,
UserPerms.HasFlag(UserPermissions.SetOwnNickname) ? 1 : 0,
UserPerms.HasFlag(UserPermissions.CreateChannel) ? (
UserPerms.HasFlag(UserPermissions.SetChannelPermanent) ? 2 : 1
) : 0,
MessageId
2024-05-10 17:28:52 +00:00
);
2022-08-30 15:00:58 +00:00
}
}
}