Keep track of super user status.

This commit is contained in:
flash 2023-11-07 14:49:12 +00:00
parent 294471dcfd
commit a9ca3705ad
5 changed files with 17 additions and 4 deletions

View file

@ -138,6 +138,7 @@ namespace SharpChat
string statusText = null, string statusText = null,
int? rank = null, int? rank = null,
ChatUserPermissions? perms = null, ChatUserPermissions? perms = null,
bool? isSuper = null,
bool silent = false bool silent = false
) { ) {
if(user == null) if(user == null)
@ -184,6 +185,11 @@ namespace SharpChat
hasChanged = true; hasChanged = true;
} }
if(isSuper.HasValue) {
user.IsSuper = isSuper.Value;
hasChanged = true;
}
if(hasChanged) if(hasChanged)
SendToUserChannels(user, new UserUpdatePacket(user, previousName)); SendToUserChannels(user, new UserUpdatePacket(user, previousName));
} }

View file

@ -12,6 +12,7 @@ namespace SharpChat {
public ChatColour Colour { get; set; } public ChatColour Colour { get; set; }
public int Rank { get; set; } public int Rank { get; set; }
public ChatUserPermissions Permissions { get; set; } public ChatUserPermissions Permissions { get; set; }
public bool IsSuper { get; set; }
public string NickName { get; set; } public string NickName { get; set; }
public ChatUserStatus Status { get; set; } public ChatUserStatus Status { get; set; }
public string StatusText { get; set; } public string StatusText { get; set; }
@ -42,7 +43,8 @@ namespace SharpChat {
ChatUserPermissions perms, ChatUserPermissions perms,
string nickName = null, string nickName = null,
ChatUserStatus status = ChatUserStatus.Online, ChatUserStatus status = ChatUserStatus.Online,
string statusText = null string statusText = null,
bool isSuper = false
) { ) {
UserId = userId; UserId = userId;
UserName = userName ?? throw new ArgumentNullException(nameof(userName)); UserName = userName ?? throw new ArgumentNullException(nameof(userName));

View file

@ -35,7 +35,7 @@ namespace SharpChat.Commands {
return; 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)); ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.KICK_NOT_ALLOWED, true, banUser.LegacyName));
return; return;
} }

View file

@ -25,5 +25,8 @@ namespace SharpChat.Misuzu {
[JsonPropertyName("perms")] [JsonPropertyName("perms")]
public ChatUserPermissions Permissions { get; set; } public ChatUserPermissions Permissions { get; set; }
[JsonPropertyName("super")]
public bool IsSuper { get; set; }
} }
} }

View file

@ -108,7 +108,8 @@ namespace SharpChat.PacketHandlers {
fai.UserName, fai.UserName,
fai.Colour, fai.Colour,
fai.Rank, fai.Rank,
fai.Permissions fai.Permissions,
isSuper: fai.IsSuper
); );
else else
ctx.Chat.UpdateUser( ctx.Chat.UpdateUser(
@ -116,7 +117,8 @@ namespace SharpChat.PacketHandlers {
userName: fai.UserName, userName: fai.UserName,
colour: fai.Colour, colour: fai.Colour,
rank: fai.Rank, rank: fai.Rank,
perms: fai.Permissions perms: fai.Permissions,
isSuper: fai.IsSuper
); );
// Enforce a maximum amount of connections per user // Enforce a maximum amount of connections per user