Class PowerLevels
A room's power levels with the spec's defaults filled in.
Inherited Members
Namespace: Uniform.Matrix.Protocol.Server
Assembly: Uniform.Matrix.Protocol.Server.dll
Syntax
public sealed class PowerLevels
Constructors
| Edit this page View SourcePowerLevels(JsonObject?, string?, IReadOnlyCollection<string>?)
Wrap the content of m.room.power_levels, or null when the room has none, in which case only creator has power.
Declaration
public PowerLevels(JsonObject? content, string? creator, IReadOnlyCollection<string>? creators = null)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonObject | content | Power levels content, or null. |
| string | creator | Creator, who has 100 without power levels. |
| IReadOnlyCollection<string> | creators | Creators of room version 12 and later, who always have unlimited power, MaxValue. |
Properties
| Edit this page View SourceBan
Level needed to ban; 50 by default.
Declaration
public long Ban { get; }
Property Value
| Type | Description |
|---|---|
| long |
Exists
Whether the room has a power levels event.
Declaration
public bool Exists { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Invite
Level needed to invite; 0 by default.
Declaration
public long Invite { get; }
Property Value
| Type | Description |
|---|---|
| long |
Kick
Level needed to kick; 50 by default.
Declaration
public long Kick { get; }
Property Value
| Type | Description |
|---|---|
| long |
Redact
Level needed to redact others' events; 50 by default.
Declaration
public long Redact { get; }
Property Value
| Type | Description |
|---|---|
| long |
Methods
| Edit this page View SourceEventLevel(string, bool)
Return the level needed to send type: from events, else state_default (50) or events_default (0); everything is 0 without power levels.
Declaration
public long EventLevel(string type, bool isState)
Parameters
| Type | Name | Description |
|---|---|---|
| string | type | |
| bool | isState |
Returns
| Type | Description |
|---|---|
| long |
TryGetInteger(JsonNode, out long)
Read a JSON integer, whether parsed or built from a .NET number; fractions and other kinds are not integers.
Declaration
public static bool TryGetInteger(JsonNode node, out long value)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonNode | node | |
| long | value |
Returns
| Type | Description |
|---|---|
| bool |
UserLevel(string)
Return a user's level: unlimited for creators of version 12 rooms, else from users, else users_default; without power levels, 100 for the creator and 0 for others.
Declaration
public long UserLevel(string userId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId |
Returns
| Type | Description |
|---|---|
| long |