Skip to content

Commit

Permalink
feat: BREAKING improve command_extension
Browse files Browse the repository at this point in the history
- unify behavior of all message sending related command
- add a StringBuffer as stdout-like output buffer for commands
- create a typedef for the command function signature
- create a common exception type for command execution
- enable commands to run on Client-level rather than Room-level
- BREAKING: Client.addCommand signature now takes an optional StringBuffer as second parameter
  • Loading branch information
coder-with-a-bushido committed Feb 4, 2025
1 parent 51b1005 commit f5bf821
Show file tree
Hide file tree
Showing 4 changed files with 360 additions and 92 deletions.
2 changes: 1 addition & 1 deletion lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Client extends MatrixApi {
DateTime? _accessTokenExpiresAt;

// For CommandsClientExtension
final Map<String, FutureOr<String?> Function(CommandArgs)> commands = {};
final Map<String, CommandExecutionCallback> commands = {};
final Filter syncFilter;

final NativeImplementations nativeImplementations;
Expand Down
2 changes: 2 additions & 0 deletions lib/src/room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ class Room {
String msgtype = MessageTypes.Text,
String? threadRootEventId,
String? threadLastEventId,
StringBuffer? commandStdout,
}) {
if (parseCommands) {
return client.parseAndRunCommand(
Expand All @@ -635,6 +636,7 @@ class Room {
txid: txid,
threadRootEventId: threadRootEventId,
threadLastEventId: threadLastEventId,
stdout: commandStdout,
);
}
final event = <String, dynamic>{
Expand Down
Loading

0 comments on commit f5bf821

Please sign in to comment.