Finer grained local permissions, also User.Can is gone.

This commit is contained in:
flash 2025-04-27 00:18:17 +00:00
parent bef41b2718
commit dd377358e2
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E
19 changed files with 70 additions and 54 deletions

View file

@ -23,14 +23,17 @@ public class FlashiiAuthResult : AuthResult {
if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_MESSAGE_EDIT_ANY)) if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_MESSAGE_EDIT_ANY))
perms |= UserPermissions.EditAnyMessage; perms |= UserPermissions.EditAnyMessage;
if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_MESSAGE_BROADCAST)) if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_MESSAGE_BROADCAST))
perms |= UserPermissions.Broadcast; perms |= UserPermissions.SendBroadcast;
if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_USER_KICK)) if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_USER_KICK))
perms |= UserPermissions.KickUser; perms |= UserPermissions.KickUser;
if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_USER_BAN)) if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_USER_BAN))
perms |= UserPermissions.BanUser; perms |= UserPermissions.BanUser
| UserPermissions.ViewBanList
| UserPermissions.PardonUser
| UserPermissions.PardonIPAddress;
if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_USER_VIEW_ADDR)) if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_USER_VIEW_ADDR))
perms |= UserPermissions.SeeIPAddress; perms |= UserPermissions.ViewIPAddress;
if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_CHANNEL_CREATE)) if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_CHANNEL_CREATE))
perms |= UserPermissions.CreateChannel; perms |= UserPermissions.CreateChannel;
@ -39,7 +42,7 @@ public class FlashiiAuthResult : AuthResult {
if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_CHANNEL_SET_PASSWORD)) if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_CHANNEL_SET_PASSWORD))
perms |= UserPermissions.SetChannelPassword; perms |= UserPermissions.SetChannelPassword;
if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_CHANNEL_SET_MIN_RANK)) if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_CHANNEL_SET_MIN_RANK))
perms |= UserPermissions.SetChannelHierarchy; perms |= UserPermissions.SetChannelMinimumRank;
if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_CHANNEL_DELETE)) if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_CHANNEL_DELETE))
perms |= UserPermissions.DeleteChannel; perms |= UserPermissions.DeleteChannel;
if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_CHANNEL_JOIN_ANY)) if(UserPermissionsRaw.HasFlag(FlashiiUserPermissions.C_CHANNEL_JOIN_ANY))

View file

@ -12,7 +12,7 @@ public class BanListClientCommand(BansClient bansClient) : ClientCommand {
public async Task Dispatch(ClientCommandContext ctx) { public async Task Dispatch(ClientCommandContext ctx) {
long msgId = ctx.Chat.RandomSnowflake.Next(); long msgId = ctx.Chat.RandomSnowflake.Next();
if(!ctx.User.Can(UserPermissions.BanUser | UserPermissions.KickUser)) { if(!ctx.User.Permissions.HasFlag(UserPermissions.ViewBanList)) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}")); await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}"));
return; return;
} }

View file

@ -12,7 +12,7 @@ public class BroadcastClientCommand : ClientCommand {
public async Task Dispatch(ClientCommandContext ctx) { public async Task Dispatch(ClientCommandContext ctx) {
long msgId = ctx.Chat.RandomSnowflake.Next(); long msgId = ctx.Chat.RandomSnowflake.Next();
if(!ctx.User.Can(UserPermissions.Broadcast)) { if(!ctx.User.Permissions.HasFlag(UserPermissions.SendBroadcast)) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}")); await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}"));
return; return;
} }

View file

@ -10,7 +10,7 @@ public class CreateChannelClientCommand : ClientCommand {
public async Task Dispatch(ClientCommandContext ctx) { public async Task Dispatch(ClientCommandContext ctx) {
long msgId = ctx.Chat.RandomSnowflake.Next(); long msgId = ctx.Chat.RandomSnowflake.Next();
if(!ctx.User.Can(UserPermissions.CreateChannel)) { if(!ctx.User.Permissions.HasFlag(UserPermissions.CreateChannel)) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}")); await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}"));
return; return;
} }
@ -47,7 +47,7 @@ public class CreateChannelClientCommand : ClientCommand {
Channel createChan = new( Channel createChan = new(
createChanName, createChanName,
isTemporary: !ctx.User.Can(UserPermissions.SetChannelPermanent), isTemporary: !ctx.User.Permissions.HasFlag(UserPermissions.SetChannelPermanent),
rank: createChanHierarchy, rank: createChanHierarchy,
ownerId: ctx.User.UserId ownerId: ctx.User.UserId
); );

View file

@ -26,7 +26,7 @@ public class DeleteChannelClientCommand : ClientCommand {
return; return;
} }
if(!ctx.User.Can(UserPermissions.DeleteChannel) && delChan.IsOwner(ctx.User)) { if(!ctx.User.Permissions.HasFlag(UserPermissions.DeleteChannel) && delChan.IsOwner(ctx.User)) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.CHANNEL_DELETE_FAILED, true, delChan.Name)); await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.CHANNEL_DELETE_FAILED, true, delChan.Name));
return; return;
} }

View file

@ -13,9 +13,9 @@ public class DeleteMessageClientCommand : ClientCommand {
public async Task Dispatch(ClientCommandContext ctx) { public async Task Dispatch(ClientCommandContext ctx) {
long msgId = ctx.Chat.RandomSnowflake.Next(); long msgId = ctx.Chat.RandomSnowflake.Next();
bool deleteAnyMessage = ctx.User.Can(UserPermissions.DeleteAnyMessage); bool deleteAnyMessage = ctx.User.Permissions.HasFlag(UserPermissions.DeleteAnyMessage);
if(!deleteAnyMessage && !ctx.User.Can(UserPermissions.DeleteOwnMessage)) { if(!deleteAnyMessage && !ctx.User.Permissions.HasFlag(UserPermissions.DeleteOwnMessage)) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}")); await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}"));
return; return;
} }

View file

@ -14,7 +14,7 @@ public class KickBanClientCommand(BansClient bansClient) : ClientCommand {
bool isBanning = ctx.NameEquals("ban"); bool isBanning = ctx.NameEquals("ban");
long msgId = ctx.Chat.RandomSnowflake.Next(); long msgId = ctx.Chat.RandomSnowflake.Next();
if(!ctx.User.Can(isBanning ? UserPermissions.BanUser : UserPermissions.KickUser)) { if(!ctx.User.Permissions.HasFlag(isBanning ? UserPermissions.BanUser : UserPermissions.KickUser)) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}")); await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}"));
return; return;
} }

View file

@ -14,9 +14,9 @@ public class NickClientCommand : ClientCommand {
public async Task Dispatch(ClientCommandContext ctx) { public async Task Dispatch(ClientCommandContext ctx) {
long msgId = ctx.Chat.RandomSnowflake.Next(); long msgId = ctx.Chat.RandomSnowflake.Next();
bool setOthersNick = ctx.User.Can(UserPermissions.SetOthersNickname); bool setOthersNick = ctx.User.Permissions.HasFlag(UserPermissions.SetOthersNickname);
if(!setOthersNick && !ctx.User.Can(UserPermissions.SetOwnNickname)) { if(!setOthersNick && !ctx.User.Permissions.HasFlag(UserPermissions.SetOwnNickname)) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}")); await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}"));
return; return;
} }

View file

@ -13,7 +13,7 @@ public class PardonAddressClientCommand(BansClient bansClient) : ClientCommand {
public async Task Dispatch(ClientCommandContext ctx) { public async Task Dispatch(ClientCommandContext ctx) {
long msgId = ctx.Chat.RandomSnowflake.Next(); long msgId = ctx.Chat.RandomSnowflake.Next();
if(!ctx.User.Can(UserPermissions.BanUser | UserPermissions.KickUser)) { if(!ctx.User.Permissions.HasFlag(UserPermissions.PardonIPAddress)) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}")); await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}"));
return; return;
} }

View file

@ -12,7 +12,7 @@ public class PardonUserClientCommand(BansClient bansClient) : ClientCommand {
public async Task Dispatch(ClientCommandContext ctx) { public async Task Dispatch(ClientCommandContext ctx) {
long msgId = ctx.Chat.RandomSnowflake.Next(); long msgId = ctx.Chat.RandomSnowflake.Next();
if(!ctx.User.Can(UserPermissions.BanUser | UserPermissions.KickUser)) { if(!ctx.User.Permissions.HasFlag(UserPermissions.PardonUser)) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}")); await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}"));
return; return;
} }

View file

@ -11,7 +11,7 @@ public class PasswordChannelClientCommand : ClientCommand {
public async Task Dispatch(ClientCommandContext ctx) { public async Task Dispatch(ClientCommandContext ctx) {
long msgId = ctx.Chat.RandomSnowflake.Next(); long msgId = ctx.Chat.RandomSnowflake.Next();
if(!ctx.User.Can(UserPermissions.SetChannelPassword) || ctx.Channel.IsOwner(ctx.User)) { if(!ctx.User.Permissions.HasFlag(UserPermissions.SetChannelPassword) || ctx.Channel.IsOwner(ctx.User)) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}")); await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}"));
return; return;
} }

View file

@ -12,7 +12,7 @@ public class RankChannelClientCommand : ClientCommand {
public async Task Dispatch(ClientCommandContext ctx) { public async Task Dispatch(ClientCommandContext ctx) {
long msgId = ctx.Chat.RandomSnowflake.Next(); long msgId = ctx.Chat.RandomSnowflake.Next();
if(!ctx.User.Can(UserPermissions.SetChannelHierarchy) || ctx.Channel.IsOwner(ctx.User)) { if(!ctx.User.Permissions.HasFlag(UserPermissions.SetChannelMinimumRank) || ctx.Channel.IsOwner(ctx.User)) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}")); await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}"));
return; return;
} }

View file

@ -12,7 +12,7 @@ public class RemoteAddressClientCommand : ClientCommand {
public async Task Dispatch(ClientCommandContext ctx) { public async Task Dispatch(ClientCommandContext ctx) {
long msgId = ctx.Chat.RandomSnowflake.Next(); long msgId = ctx.Chat.RandomSnowflake.Next();
if(!ctx.User.Can(UserPermissions.SeeIPAddress)) { if(!ctx.User.Permissions.HasFlag(UserPermissions.ViewIPAddress)) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, "/ip")); await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, "/ip"));
return; return;
} }

View file

@ -37,7 +37,7 @@ public class WhoClientCommand : ClientCommand {
return; return;
} }
if(whoChan.Rank > ctx.User.Rank || (whoChan.HasPassword && !ctx.User.Can(UserPermissions.JoinAnyChannel))) { if(whoChan.Rank > ctx.User.Rank || (whoChan.HasPassword && !ctx.User.Permissions.HasFlag(UserPermissions.JoinAnyChannel))) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.USERS_LISTING_ERROR, true, whoChanStr)); await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.USERS_LISTING_ERROR, true, whoChanStr));
return; return;
} }

View file

@ -275,7 +275,7 @@ public class Context {
return; return;
} }
if(!user.Can(UserPermissions.JoinAnyChannel) && chan.IsOwner(user)) { if(!user.Permissions.HasFlag(UserPermissions.JoinAnyChannel) && chan.IsOwner(user)) {
if(chan.Rank > user.Rank) { if(chan.Rank > user.Rank) {
await SendTo(user, new CommandResponseS2CPacket(RandomSnowflake.Next(), LCR.CHANNEL_INSUFFICIENT_HIERARCHY, true, chan.Name)); await SendTo(user, new CommandResponseS2CPacket(RandomSnowflake.Next(), LCR.CHANNEL_INSUFFICIENT_HIERARCHY, true, chan.Name));
await ForceChannel(user); await ForceChannel(user);

View file

@ -8,7 +8,7 @@ public partial class MariaDBEventStorage {
if(sup.HasFlag(StoredUserPermissions.BanUser)) if(sup.HasFlag(StoredUserPermissions.BanUser))
perms |= UserPermissions.BanUser; perms |= UserPermissions.BanUser;
if(sup.HasFlag(StoredUserPermissions.Broadcast)) if(sup.HasFlag(StoredUserPermissions.Broadcast))
perms |= UserPermissions.Broadcast; perms |= UserPermissions.SendBroadcast;
if(sup.HasFlag(StoredUserPermissions.SetOwnNickname)) if(sup.HasFlag(StoredUserPermissions.SetOwnNickname))
perms |= UserPermissions.SetOwnNickname; perms |= UserPermissions.SetOwnNickname;
if(sup.HasFlag(StoredUserPermissions.SetOthersNickname)) if(sup.HasFlag(StoredUserPermissions.SetOthersNickname))
@ -22,7 +22,7 @@ public partial class MariaDBEventStorage {
if(sup.HasFlag(StoredUserPermissions.SetChannelPassword)) if(sup.HasFlag(StoredUserPermissions.SetChannelPassword))
perms |= UserPermissions.SetChannelPassword; perms |= UserPermissions.SetChannelPassword;
if(sup.HasFlag(StoredUserPermissions.SetChannelHierarchy)) if(sup.HasFlag(StoredUserPermissions.SetChannelHierarchy))
perms |= UserPermissions.SetChannelHierarchy; perms |= UserPermissions.SetChannelMinimumRank;
if(sup.HasFlag(StoredUserPermissions.JoinAnyChannel)) if(sup.HasFlag(StoredUserPermissions.JoinAnyChannel))
perms |= UserPermissions.JoinAnyChannel; perms |= UserPermissions.JoinAnyChannel;
if(sup.HasFlag(StoredUserPermissions.SendMessage)) if(sup.HasFlag(StoredUserPermissions.SendMessage))
@ -36,9 +36,15 @@ public partial class MariaDBEventStorage {
if(sup.HasFlag(StoredUserPermissions.EditAnyMessage)) if(sup.HasFlag(StoredUserPermissions.EditAnyMessage))
perms |= UserPermissions.EditAnyMessage; perms |= UserPermissions.EditAnyMessage;
if(sup.HasFlag(StoredUserPermissions.SeeIPAddress)) if(sup.HasFlag(StoredUserPermissions.SeeIPAddress))
perms |= UserPermissions.SeeIPAddress; perms |= UserPermissions.ViewIPAddress;
if(sup.HasFlag(StoredUserPermissions.ViewLogs)) if(sup.HasFlag(StoredUserPermissions.ViewLogs))
perms |= UserPermissions.ViewLogs; perms |= UserPermissions.ViewLogs;
if(sup.HasFlag(StoredUserPermissions.ViewBanList))
perms |= UserPermissions.ViewBanList;
if(sup.HasFlag(StoredUserPermissions.PardonUser))
perms |= UserPermissions.PardonUser;
if(sup.HasFlag(StoredUserPermissions.PardonIPAddress))
perms |= UserPermissions.PardonIPAddress;
return perms; return perms;
} }
@ -50,7 +56,7 @@ public partial class MariaDBEventStorage {
perms |= StoredUserPermissions.KickUser; perms |= StoredUserPermissions.KickUser;
if(up.HasFlag(UserPermissions.BanUser)) if(up.HasFlag(UserPermissions.BanUser))
perms |= StoredUserPermissions.BanUser; perms |= StoredUserPermissions.BanUser;
if(up.HasFlag(UserPermissions.Broadcast)) if(up.HasFlag(UserPermissions.SendBroadcast))
perms |= StoredUserPermissions.Broadcast; perms |= StoredUserPermissions.Broadcast;
if(up.HasFlag(UserPermissions.SetOwnNickname)) if(up.HasFlag(UserPermissions.SetOwnNickname))
perms |= StoredUserPermissions.SetOwnNickname; perms |= StoredUserPermissions.SetOwnNickname;
@ -64,7 +70,7 @@ public partial class MariaDBEventStorage {
perms |= StoredUserPermissions.SetChannelPermanent; perms |= StoredUserPermissions.SetChannelPermanent;
if(up.HasFlag(UserPermissions.SetChannelPassword)) if(up.HasFlag(UserPermissions.SetChannelPassword))
perms |= StoredUserPermissions.SetChannelPassword; perms |= StoredUserPermissions.SetChannelPassword;
if(up.HasFlag(UserPermissions.SetChannelHierarchy)) if(up.HasFlag(UserPermissions.SetChannelMinimumRank))
perms |= StoredUserPermissions.SetChannelHierarchy; perms |= StoredUserPermissions.SetChannelHierarchy;
if(up.HasFlag(UserPermissions.JoinAnyChannel)) if(up.HasFlag(UserPermissions.JoinAnyChannel))
perms |= StoredUserPermissions.JoinAnyChannel; perms |= StoredUserPermissions.JoinAnyChannel;
@ -78,10 +84,16 @@ public partial class MariaDBEventStorage {
perms |= StoredUserPermissions.EditOwnMessage; perms |= StoredUserPermissions.EditOwnMessage;
if(up.HasFlag(UserPermissions.EditAnyMessage)) if(up.HasFlag(UserPermissions.EditAnyMessage))
perms |= StoredUserPermissions.EditAnyMessage; perms |= StoredUserPermissions.EditAnyMessage;
if(up.HasFlag(UserPermissions.SeeIPAddress)) if(up.HasFlag(UserPermissions.ViewIPAddress))
perms |= StoredUserPermissions.SeeIPAddress; perms |= StoredUserPermissions.SeeIPAddress;
if(up.HasFlag(UserPermissions.ViewLogs)) if(up.HasFlag(UserPermissions.ViewLogs))
perms |= StoredUserPermissions.ViewLogs; perms |= StoredUserPermissions.ViewLogs;
if(up.HasFlag(UserPermissions.ViewBanList))
perms |= StoredUserPermissions.ViewBanList;
if(up.HasFlag(UserPermissions.PardonUser))
perms |= StoredUserPermissions.PardonUser;
if(up.HasFlag(UserPermissions.PardonIPAddress))
perms |= StoredUserPermissions.PardonIPAddress;
return perms; return perms;
} }

View file

@ -2,23 +2,26 @@
[Flags] [Flags]
public enum StoredUserPermissions : int { public enum StoredUserPermissions : int {
KickUser = 0x00000001, KickUser = 0x1,
BanUser = 0x00000002, BanUser = 0x2,
//SilenceUser = 0x00000004, //SilenceUser = 0x4,
Broadcast = 0x00000008, Broadcast = 0x8,
SetOwnNickname = 0x00000010, SetOwnNickname = 0x10,
SetOthersNickname = 0x00000020, SetOthersNickname = 0x20,
CreateChannel = 0x00000040, CreateChannel = 0x40,
DeleteChannel = 0x00010000, SetChannelPermanent = 0x80,
SetChannelPermanent = 0x00000080, SetChannelPassword = 0x100,
SetChannelPassword = 0x00000100, SetChannelHierarchy = 0x200,
SetChannelHierarchy = 0x00000200, SendMessage = 0x400,
JoinAnyChannel = 0x00020000, DeleteOwnMessage = 0x800,
SendMessage = 0x00000400, DeleteAnyMessage = 0x1000,
DeleteOwnMessage = 0x00000800, EditOwnMessage = 0x2000,
DeleteAnyMessage = 0x00001000, EditAnyMessage = 0x4000,
EditOwnMessage = 0x00002000, SeeIPAddress = 0x8000,
EditAnyMessage = 0x00004000, DeleteChannel = 0x10000,
SeeIPAddress = 0x00008000, JoinAnyChannel = 0x20000,
ViewLogs = 0x00040000, ViewLogs = 0x40000,
ViewBanList = 0x80000,
PardonUser = 0x100000,
PardonIPAddress = 0x200000,
} }

View file

@ -49,11 +49,6 @@ public class User(
} }
} }
public bool Can(UserPermissions perm, bool strict = false) {
UserPermissions perms = Permissions & perm;
return strict ? perms == perm : perms > 0;
}
public bool NameEquals(string name) { public bool NameEquals(string name) {
return string.Equals(name, UserName, StringComparison.InvariantCultureIgnoreCase) return string.Equals(name, UserName, StringComparison.InvariantCultureIgnoreCase)
|| string.Equals(name, NickName, StringComparison.InvariantCultureIgnoreCase) || string.Equals(name, NickName, StringComparison.InvariantCultureIgnoreCase)

View file

@ -12,17 +12,20 @@ public enum UserPermissions : ulong {
DeleteAnyMessage = 1ul << 3, DeleteAnyMessage = 1ul << 3,
EditOwnMessage = 1ul << 4, EditOwnMessage = 1ul << 4,
EditAnyMessage = 1ul << 5, EditAnyMessage = 1ul << 5,
Broadcast = 1ul << 6, SendBroadcast = 1ul << 6,
ViewLogs = 1ul << 7, ViewLogs = 1ul << 7,
KickUser = 1ul << 10, KickUser = 1ul << 10,
BanUser = 1ul << 11, BanUser = 1ul << 11,
SeeIPAddress = 1ul << 12, PardonUser = 1ul << 12,
PardonIPAddress = 1ul << 13,
ViewIPAddress = 1ul << 14,
ViewBanList = 1ul << 15,
CreateChannel = 1ul << 20, CreateChannel = 1ul << 20,
SetChannelPermanent = 1ul << 21, SetChannelPermanent = 1ul << 21,
SetChannelPassword = 1ul << 22, SetChannelPassword = 1ul << 22,
SetChannelHierarchy = 1ul << 23, SetChannelMinimumRank = 1ul << 23,
DeleteChannel = 1ul << 24, DeleteChannel = 1ul << 24,
JoinAnyChannel = 1ul << 25, JoinAnyChannel = 1ul << 25,