public static void SetGroup(IContext context, IBotUser botUser, IBotGroup group) { EnsureIdentified(context); if(context.User.Equals(botUser)) throw new InvalidOperationException("Cannot set your own group."); if(botUser.Group.IsMoreOrSamePrivileged(context.User.Group)) throw new InvalidOperationException("Cannot set group for users that have the same or more privileges than yourself."); if(group.IsMoreOrSamePrivileged(context.User.Group)) throw new InvalidOperationException("Cannot set group to one that has the same or more privileges than yourself."); botUser.Group = group; }
private static void EnsureAllowGroup(IContext context, IBotGroup group) { if(group.IsMoreOrSamePrivileged(context.User.Group)) throw new InvalidOperationException("Cannot change permissions for a group with the same or more privileges than yours."); }