37 lines
977 B
Nix
37 lines
977 B
Nix
{ pkgs, ... }:
|
|
let
|
|
getLatestN = pkgs.writeShellApplication {
|
|
name = "misskey-getLatestN";
|
|
runtimeInputs = with pkgs; [
|
|
curl
|
|
jq
|
|
];
|
|
text = ''
|
|
if [ ! -e /tmp//misskey-scripts/getLatestN.fifo ]; then
|
|
mkdir -p /tmp/misskey-scripts
|
|
mkfifo /tmp/misskey-scripts/getLatestN.fifo
|
|
fi
|
|
|
|
limitNum=$1
|
|
delim=$2
|
|
pipeLocation=/tmp/misskey-scripts/getLatestN.fifo
|
|
queryText='.[].text + '
|
|
queryText+='"'
|
|
queryText+="$delim"
|
|
queryText+='"'
|
|
|
|
jq -M -r "$queryText" <(curl https://misskey.io/api/notes -s --request POST --header 'Content-Type: application/json' --data "{\"local\": true, \"reply\": false, \"renote\": false, \"withFiles\": false, \"poll\": false, \"limit\": $limitNum}") > $pipeLocation &
|
|
|
|
while read -r line; do
|
|
echo "$line"
|
|
done < $pipeLocation
|
|
wait
|
|
'';
|
|
};
|
|
|
|
in
|
|
pkgs.symlinkJoin {
|
|
name = "misskey-scripts";
|
|
paths = [ getLatestN ];
|
|
}
|