2022-08-30 15:00:58 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace SharpChat.Packet {
|
|
|
|
|
public class UserConnectPacket : ServerPacket {
|
|
|
|
|
public DateTimeOffset Joined { get; private set; }
|
|
|
|
|
public ChatUser User { get; private set; }
|
|
|
|
|
|
|
|
|
|
public UserConnectPacket(DateTimeOffset joined, ChatUser user) {
|
|
|
|
|
Joined = joined;
|
|
|
|
|
User = user ?? throw new ArgumentNullException(nameof(user));
|
|
|
|
|
}
|
|
|
|
|
|
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}",
|
|
|
|
|
Joined.ToUnixTimeSeconds(),
|
|
|
|
|
User.UserId,
|
|
|
|
|
User.LegacyNameWithStatus,
|
|
|
|
|
User.Colour,
|
|
|
|
|
User.Rank,
|
|
|
|
|
User.Can(ChatUserPermissions.KickUser) ? 1 : 0,
|
|
|
|
|
User.Can(ChatUserPermissions.ViewLogs) ? 1 : 0,
|
|
|
|
|
User.Can(ChatUserPermissions.SetOwnNickname) ? 1 : 0,
|
|
|
|
|
User.Can(ChatUserPermissions.CreateChannel | ChatUserPermissions.SetChannelPermanent, true) ? 2 : (
|
|
|
|
|
User.Can(ChatUserPermissions.CreateChannel) ? 1 : 0
|
|
|
|
|
),
|
|
|
|
|
SequenceId
|
|
|
|
|
);
|
2022-08-30 15:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|