36 lines
1 KiB
C#
36 lines
1 KiB
C#
using SharpChat.Events;
|
|
using System;
|
|
using System.Text;
|
|
|
|
namespace SharpChat.Protocol.SockChat.Packets {
|
|
public class ForceDisconnectPacket : ServerPacket {
|
|
public DateTimeOffset? Expires { get; }
|
|
public bool IsPermanent { get; }
|
|
|
|
public ForceDisconnectPacket(UserBanCreatedEvent ubce) {
|
|
Expires = ubce.Duration < 1
|
|
? null
|
|
: DateTimeOffset.Now + TimeSpan.FromSeconds(ubce.Duration);
|
|
IsPermanent = ubce.IsPermanent;
|
|
}
|
|
|
|
protected override string DoPack() {
|
|
StringBuilder sb = new();
|
|
|
|
sb.Append((int)ServerPacketId.BAKA);
|
|
sb.Append(IServerPacket.SEPARATOR);
|
|
|
|
if(Expires.HasValue) {
|
|
sb.Append('1');
|
|
sb.Append(IServerPacket.SEPARATOR);
|
|
if(IsPermanent)
|
|
sb.Append(-1);
|
|
else
|
|
sb.Append(Expires.Value.ToUnixTimeSeconds());
|
|
} else
|
|
sb.Append('0');
|
|
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
}
|