Skip to content

Commit

Permalink
feat: Set room state and account data via commands
Browse files Browse the repository at this point in the history
  • Loading branch information
krille-chan committed Feb 11, 2025
1 parent beef67b commit 7945450
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/src/utils/commands_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,32 @@ extension CommandsClientExtension on Client {
stdout?.write(DefaultCommandOutput(users: [mxid]).toString());
return null;
});
addCommand('setRoomState', (args, stdout) async {
final arguments = args.msg.split(' ');
final roomId = arguments.removeAt(0);
final eventType = arguments.removeAt(0);
final stateKey = arguments.removeAt(0);
final body = jsonDecode(arguments.join(' '));
final eventId =
await setRoomStateWithKey(roomId, eventType, stateKey, body);
stdout?.write(DefaultCommandOutput(rooms: [eventId]).toString());
return null;
});
addCommand('setAccountData', (args, stdout) async {
final arguments = args.msg.split(' ');
final eventType = arguments.removeAt(0);
final body = jsonDecode(arguments.join(' '));
await setAccountData(userID!, eventType, body);
return null;
});
addCommand('setRoomAccountData', (args, stdout) async {
final arguments = args.msg.split(' ');
final roomId = arguments.removeAt(0);
final eventType = arguments.removeAt(0);
final body = jsonDecode(arguments.join(' '));
await setAccountDataPerRoom(userID!, roomId, eventType, body);
return null;
});
}
}

Expand Down

0 comments on commit 7945450

Please sign in to comment.