Announcement RSS feed

This commit is contained in:
root 2023-01-02 02:45:07 +00:00
parent b208996168
commit 549ec3020a
4 changed files with 19 additions and 11 deletions

View File

@ -1,9 +0,0 @@
#!/usr/bin/env -S bash -e
[[ -z "$1" ]] && {
printf "Usage: %s message [description]\n" "$0"
exit 1
}
mkfpost "${1}" "$(! [[ -z ${2} ]] && echo "${2}")"
mkwpost "${1}" "$(! [[ -z ${2} ]] && echo "${2}")"
mkxpost "${1}" "$(! [[ -z ${2} ]] && echo "${2}")"
mkmpost "${1}" "$(! [[ -z ${2} ]] && echo "${2}")"

View File

@ -23,6 +23,6 @@ else
-X PUT \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer '"$(</root/priv/root-access-token)" \
-d '{"msgtype":"m.text", "body":"'"SUBJECT: ${1}\n${2}"'"}' \
-d '{"msgtype":"m.text", "body":"'"${1}\n\n${2}"'"}' \
"$instance"'/_matrix/client/r0/rooms/'"$RoomId"'/send/m.room.message/'"$(TxnId)"
fi

View File

@ -5,6 +5,7 @@
}
mkwpost "$1" "$2"
mkfpost "$1" "$2"
mkfpost "$1" ${2:+"$2"}
mkmpost "$1" "$2"
mkxpost "$1" "$2"
mkrpost "$1" "$2"

16
tilserv/mkrpost Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env -S bash -e
[[ -z "$1" ]] && {
printf "Usage: %s message [description]\n" "$0"
exit 1
}
RSS=/var/log/announcements.xml
DATE="$(date --rfc-email -u)"
MSG='\n\t<item>\n\t\t<title>'"$1"'<\/title>\n\t\t<description>'"$2"'<\/description>\n\t\t<author>root@vern.cc<\/author>\n\t\t<link>https:\/\/vern.cc\/announcements<\/link>\n\t\t<pubDate>'"$DATE"'<\/pubDate>\n\t<\/item>'
[[ -z "$2" ]] && {
MSG='\n\t<item>\n\t\t<title>'"$1"'<\/title>\n\t\t<author>root@vern.cc<\/author>\n\t\t<link>https:\/\/vern.cc\/announcements<\/link>\n\t\t<pubDate>'"$DATE"'<\/pubDate>\n\t<\/item>'
}
sed -i "s/<\/webMaster>/<\/webMaster>$MSG/" $RSS