You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
776 B
Bash
19 lines
776 B
Bash
#!/bin/bash
|
|
|
|
input_file=$1
|
|
output_file=$3
|
|
pattern=$2
|
|
|
|
if [ -z $input_file -o -z $pattern ]; then
|
|
echo "input file: $input_file, pattern: $pattern"
|
|
echo "Usage: $0 <./path/to/matrix-rooms.txt> <PATTERN> [./path/to/output.txt]"
|
|
exit 0
|
|
fi
|
|
|
|
echo "Converting matrix account data into a comprehensive room list ..."
|
|
if [ -z $output_file ]; then
|
|
jq ".rooms.join | [to_entries[] | {\"room_id\": .key, \"room_name\": .value.state.events[] | select(.type == \"m.room.name\").content.name} | select(.room_name | match(\"$pattern\"))]" $input_file
|
|
else
|
|
jq ".rooms.join | [to_entries[] | {\"room_id\": .key, \"room_name\": .value.state.events[] | select(.type == \"m.room.name\").content.name} | select(.room_name | match(\"$pattern\"))]" $input_file > $output_file
|
|
fi
|