Skip to content

Commit 5d6fa5f

Browse files
committed
Only run PL update if needed
1 parent 78c1e3d commit 5d6fa5f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/commands/IrcPlumbCommand.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ limitations under the License.
1515
*/
1616

1717
import { ICommand } from "./ICommand";
18-
import { LogLevel, LogService, MatrixClient } from "matrix-bot-sdk";
18+
import { LogLevel, LogService, MatrixClient, PowerLevelAction } from "matrix-bot-sdk";
1919
import { Conference } from "../Conference";
2020
import { IRCBridge } from "../IRCBridge";
2121
import { logMessage } from "../LogProxy";
@@ -70,8 +70,10 @@ export class IrcPlumbCommand implements ICommand {
7070
}
7171

7272
try {
73-
// The bridge needs the ability to kick KLINED users.
74-
await client.setUserPowerLevel(this.ircBridge.botUserId, resolvedRoomId, KickPowerLevel);
73+
if (!await client.userHasPowerLevelForAction(this.ircBridge.botUserId, resolvedRoomId, PowerLevelAction.Kick)) {
74+
// The bridge needs the ability to kick KLINED users.
75+
await client.setUserPowerLevel(this.ircBridge.botUserId, resolvedRoomId, KickPowerLevel);
76+
}
7577
} catch (ex) {
7678
LogService.warn("IrcPlumbCommand", ex);
7779
return logMessage(LogLevel.WARN, "IrcPlumbCommand", `Could not plumb channel to room ${resolvedRoomId}: could not set AS power level`);

0 commit comments

Comments
 (0)