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.
20 lines
868 B
Bash
20 lines
868 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[] | .value.state.events[] | select(.type == \"m.room.member\") | {\"user_id\": .sender, \"displayname\": .content.displayname}] | unique_by(.user_id) | map(select(.user_id | match(\"$pattern\")))" "$input_file"
|
|
|
|
else
|
|
jq ".rooms.join | [to_entries[] | .value.state.events[] | select(.type == \"m.room.member\") | {\"user_id\": .sender, \"displayname\": .content.displayname}] | unique_by(.user_id) | map(select(.user_id | match(\"$pattern\")))" "$input_file" > "$output_file"
|
|
fi
|