Skip to content

Commit 97290d7

Browse files
Half-Shotreivilibre
authored andcommitted
Only run PL update if needed
1 parent 9cd4a93 commit 97290d7

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";
@@ -71,8 +71,10 @@ export class IrcPlumbCommand implements ICommand {
7171
}
7272

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

0 commit comments

Comments
 (0)