Why Nostr?What is Njump?
IngwiePhoenix / Ingwie Phoenix
npub1tce…jmky
2024-05-09 15:51:09
in reply to nevent1q…n7ah

IngwiePhoenix on Nostr: Per script, ja! Nennt sich "Policy" oder "Plugin" und es gibt paar frameworks. Aber ...

Per script, ja! Nennt sich "Policy" oder "Plugin" und es gibt paar frameworks. Aber an sich ist das erstmal nichts anderes als ein program/befehl der einfach das Event auf STDIN bekommt: https://github.com/hoytech/strfry/blob/master/docs/plugins.md
Es gibt sowohl ein Framework in Deno von Alex Gleason als auch ein Go framework mit denen man die schreiben kann.
Aber die aller einfachste Variante ist im Grunde:

#!/bin/sh
input=$(cat)
if test "$(echo $input | wc -c)" = 0; then exit 1; fi
id=$(echo $input | jq -r ".event.id")
kind=$(echo $input | jq -r ".event.kind")
msg=$(echo $input | jq -r ".event.content")
rtmsg=""
if test $kind = 1; then
case $msg in
*badword*) rtmsg='{"id": "'$id'", "action": "shadowReject"}';;
esac
fi
echo $rtmsg
exit 0

Gibt bei weitem bessere Beispiele - aber das dient eher als Orientierung. :)
Author Public Key
npub1tcekjparmkju6k83r5tzmzjvjwy0nnajlrwyk35us9g7x7wx80ys9hjmky