Merge pull request #2038 from famedly/krille/add-command-to-upgrade-room

feat: Add command to upgrade room
This commit is contained in:
Krille-chan 2025-03-10 16:23:32 +01:00 committed by GitHub
commit ef2c7a628e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -2046,6 +2046,8 @@ class Room {
/// `m.sticker` use `canSendEvent('<event-type>')`. /// `m.sticker` use `canSendEvent('<event-type>')`.
bool get canSendDefaultMessages { bool get canSendDefaultMessages {
if (encrypted && !client.encryptionEnabled) return false; if (encrypted && !client.encryptionEnabled) return false;
if (isExtinct) return false;
if (membership != Membership.join) return false;
return canSendEvent(encrypted ? EventTypes.Encrypted : EventTypes.Message); return canSendEvent(encrypted ? EventTypes.Encrypted : EventTypes.Message);
} }

View File

@ -460,6 +460,16 @@ extension CommandsClientExtension on Client {
stdout?.write(DefaultCommandOutput(users: [mxid]).toString()); stdout?.write(DefaultCommandOutput(users: [mxid]).toString());
return null; return null;
}); });
addCommand('roomupgrade', (args, stdout) async {
final version = args.msg;
if (version.isEmpty) {
throw CommandException('Please provide a room version');
}
final newRoomId =
await args.room!.client.upgradeRoom(args.room!.id, version);
stdout?.write(DefaultCommandOutput(rooms: [newRoomId]).toString());
return null;
});
} }
} }