Split out the Flashii interaction code into a separate library.
This commit is contained in:
parent
51f5c4c948
commit
2eba089a21
55 changed files with 769 additions and 552 deletions
SharpChat/ClientCommands
|
@ -1,11 +1,9 @@
|
|||
using SharpChat.Misuzu;
|
||||
using SharpChat.Bans;
|
||||
using SharpChat.S2CPackets;
|
||||
using System.Net;
|
||||
|
||||
namespace SharpChat.ClientCommands {
|
||||
public class PardonAddressClientCommand(MisuzuClient msz) : ClientCommand {
|
||||
private readonly MisuzuClient Misuzu = msz ?? throw new ArgumentNullException(nameof(msz));
|
||||
|
||||
public class PardonAddressClientCommand(BansClient bansClient) : ClientCommand {
|
||||
public bool IsMatch(ClientCommandContext ctx) {
|
||||
return ctx.NameEquals("pardonip")
|
||||
|| ctx.NameEquals("unbanip");
|
||||
|
@ -28,19 +26,13 @@ namespace SharpChat.ClientCommands {
|
|||
unbanAddrTarget = unbanAddr.ToString();
|
||||
|
||||
Task.Run(async () => {
|
||||
MisuzuBanInfo? banInfo = await Misuzu.CheckBanAsync(ipAddr: unbanAddrTarget);
|
||||
if(banInfo is null) {
|
||||
ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.GENERIC_ERROR, true));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!banInfo.IsBanned || banInfo.HasExpired) {
|
||||
BanInfo? banInfo = await bansClient.BanGetAsync(remoteAddr: unbanAddr);
|
||||
if(banInfo?.Kind != BanKind.IPAddress) {
|
||||
ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.USER_NOT_BANNED, true, unbanAddrTarget));
|
||||
return;
|
||||
}
|
||||
|
||||
bool wasBanned = await Misuzu.RevokeBanAsync(banInfo, MisuzuClient.BanRevokeKind.RemoteAddress);
|
||||
if(wasBanned)
|
||||
if(await bansClient.BanRevokeAsync(banInfo))
|
||||
ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.USER_UNBANNED, false, unbanAddrTarget));
|
||||
else
|
||||
ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.USER_NOT_BANNED, true, unbanAddrTarget));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue