diff --git a/SharpChat/ChatContext.cs b/SharpChat/ChatContext.cs index ce5c385..f0cf96a 100644 --- a/SharpChat/ChatContext.cs +++ b/SharpChat/ChatContext.cs @@ -138,6 +138,7 @@ namespace SharpChat string statusText = null, int? rank = null, ChatUserPermissions? perms = null, + bool? isSuper = null, bool silent = false ) { if(user == null) @@ -184,6 +185,11 @@ namespace SharpChat hasChanged = true; } + if(isSuper.HasValue) { + user.IsSuper = isSuper.Value; + hasChanged = true; + } + if(hasChanged) SendToUserChannels(user, new UserUpdatePacket(user, previousName)); } diff --git a/SharpChat/ChatUser.cs b/SharpChat/ChatUser.cs index 09ba00c..1cae0f1 100644 --- a/SharpChat/ChatUser.cs +++ b/SharpChat/ChatUser.cs @@ -12,6 +12,7 @@ namespace SharpChat { public ChatColour Colour { get; set; } public int Rank { get; set; } public ChatUserPermissions Permissions { get; set; } + public bool IsSuper { get; set; } public string NickName { get; set; } public ChatUserStatus Status { get; set; } public string StatusText { get; set; } @@ -42,7 +43,8 @@ namespace SharpChat { ChatUserPermissions perms, string nickName = null, ChatUserStatus status = ChatUserStatus.Online, - string statusText = null + string statusText = null, + bool isSuper = false ) { UserId = userId; UserName = userName ?? throw new ArgumentNullException(nameof(userName)); diff --git a/SharpChat/Commands/KickBanCommand.cs b/SharpChat/Commands/KickBanCommand.cs index 16a694c..8b88ae5 100644 --- a/SharpChat/Commands/KickBanCommand.cs +++ b/SharpChat/Commands/KickBanCommand.cs @@ -35,7 +35,7 @@ namespace SharpChat.Commands { return; } - if(banUser == ctx.User || banUser.Rank >= ctx.User.Rank) { + if(banUser.Rank >= ctx.User.Rank && banUser != ctx.User) { ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.KICK_NOT_ALLOWED, true, banUser.LegacyName)); return; } diff --git a/SharpChat/Misuzu/MisuzuAuthInfo.cs b/SharpChat/Misuzu/MisuzuAuthInfo.cs index 3750aef..f2f0359 100644 --- a/SharpChat/Misuzu/MisuzuAuthInfo.cs +++ b/SharpChat/Misuzu/MisuzuAuthInfo.cs @@ -25,5 +25,8 @@ namespace SharpChat.Misuzu { [JsonPropertyName("perms")] public ChatUserPermissions Permissions { get; set; } + + [JsonPropertyName("super")] + public bool IsSuper { get; set; } } } diff --git a/SharpChat/PacketHandlers/AuthHandler.cs b/SharpChat/PacketHandlers/AuthHandler.cs index 6a73f8f..e7d875a 100644 --- a/SharpChat/PacketHandlers/AuthHandler.cs +++ b/SharpChat/PacketHandlers/AuthHandler.cs @@ -108,7 +108,8 @@ namespace SharpChat.PacketHandlers { fai.UserName, fai.Colour, fai.Rank, - fai.Permissions + fai.Permissions, + isSuper: fai.IsSuper ); else ctx.Chat.UpdateUser( @@ -116,7 +117,8 @@ namespace SharpChat.PacketHandlers { userName: fai.UserName, colour: fai.Colour, rank: fai.Rank, - perms: fai.Permissions + perms: fai.Permissions, + isSuper: fai.IsSuper ); // Enforce a maximum amount of connections per user