sharp-chat/SharpChat/Packet/BanListPacket.cs

29 lines
841 B
C#

using System;
using System.Linq;
using System.Text;
namespace SharpChat.Packet {
public class BanListPacket : ServerPacket {
private readonly string[] Bans;
public BanListPacket(string[] bans) {
Bans = bans ?? throw new ArgumentNullException(nameof(bans));
}
public override string Pack() {
StringBuilder sb = new();
sb.AppendFormat("2\t{0}\t-1\t0\fbanlist\f", DateTimeOffset.Now.ToUnixTimeSeconds());
foreach(string ban in Bans)
sb.AppendFormat(@"<a href=""javascript:void(0);"" onclick=""Chat.SendMessageWrapper('/unban '+ this.innerHTML);"">{0}</a>, ", ban);
if(Bans.Any())
sb.Length -= 2;
sb.AppendFormat("\t{0}\t10010", SequenceId);
return sb.ToString();
}
}
}