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,10 +1,8 @@
|
|||
using SharpChat.Misuzu;
|
||||
using SharpChat.Bans;
|
||||
using SharpChat.S2CPackets;
|
||||
|
||||
namespace SharpChat.ClientCommands {
|
||||
public class BanListClientCommand(MisuzuClient msz) : ClientCommand {
|
||||
private readonly MisuzuClient Misuzu = msz ?? throw new ArgumentNullException(nameof(msz));
|
||||
|
||||
public class BanListClientCommand(BansClient bansClient) : ClientCommand {
|
||||
public bool IsMatch(ClientCommandContext ctx) {
|
||||
return ctx.NameEquals("bans")
|
||||
|| ctx.NameEquals("banned");
|
||||
|
@ -19,18 +17,15 @@ namespace SharpChat.ClientCommands {
|
|||
}
|
||||
|
||||
Task.Run(async () => {
|
||||
MisuzuBanInfo[]? mbis = await Misuzu.GetBanListAsync();
|
||||
if(mbis is null)
|
||||
ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.GENERIC_ERROR, true));
|
||||
else
|
||||
try {
|
||||
BanInfo[] banInfos = await bansClient.BanGetListAsync();
|
||||
ctx.Chat.SendTo(ctx.User, new BanListS2CPacket(
|
||||
msgId,
|
||||
mbis.Where(mbi => mbi.IsBanned && !mbi.HasExpired)
|
||||
.Select(mbi => new BanListS2CPacket.Entry(
|
||||
BanListS2CPacket.Type.UserName, // Misuzu currently only does username bans so we can just do this
|
||||
mbi.UserName ?? $"({mbi.UserId})"
|
||||
))
|
||||
banInfos.Select(bi => new BanListS2CPacket.Entry(bi.Kind, bi.ToString()))
|
||||
));
|
||||
} catch(Exception) {
|
||||
ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.GENERIC_ERROR, true));
|
||||
}
|
||||
}).Wait();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue