make the post scripts have desc support

This commit is contained in:
root 2022-12-13 05:43:33 +00:00
parent bc9464f0ed
commit e032dcf06c
4 changed files with 28 additions and 29 deletions

View File

@ -1,8 +1,11 @@
#!/usr/bin/env -S bash -e
[[ -z "$1" ]] && {
printf "Usage: %s message\n" "$0"
printf "Usage: %s message [description]\n" "$0"
exit 1
}
instance="https://fedi.vern.cc"
curl "${instance}"/api/v1/statuses -H 'Authorization: Bearer '"$(</root/priv/vernannouncetoken)" -F 'status='"${1}"
if [[ -z ${2} ]]; then
curl "${instance}"/api/v1/statuses -H 'Authorization: Bearer '"$(</root/priv/vernannouncetoken)" -F "status=${1}"
else
curl "${instance}"/api/v1/statuses -H 'Authorization: Bearer '"$(</root/priv/vernannouncetoken)" -F "status=${2}" -F "spoiler_text=${1}"
fi

View File

@ -1,17 +0,0 @@
#!/usr/bin/env -S bash -e
[[ -z "$1" ]] && {
printf "Usage: %s message\n" "$0"
exit 1
}
{
cat << EOF
NICK vern
PASS $(</root/priv/sojupass)
USER vern bnc.vern.cc bnc.vern.cc vern
EOF
cat << EOF
JOIN #vern-announcements
EOF
} | openssl s_client -connect irc.tilde.chat:6697 -quiet

View File

@ -1,6 +1,6 @@
#!/usr/bin/env -S bash -e
[[ -z "$1" ]] && {
printf "Usage: %s message\n" "$0"
printf "Usage: %s message [description]\n" "$0"
exit 1
}
TxnId() { # Random chars. Needed for sending messages. I am not using tr on /dev/urandom for speed reasons
@ -11,9 +11,18 @@ TxnId() { # Random chars. Needed for sending messages. I am not using tr on /dev
}
instance='https://mtrx.vern.cc'
RoomId='!DbQXembCUWglXOcHRx:vern.cc'
curl -s \
-X PUT \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer '"$(<root/priv/root-access-token)" \
-d '{"msgtype":"m.text", "body":"'"${1}"'"}' \
"$instance"'/_matrix/client/r0/rooms/'"$RoomId"'/send/m.room.message/'"$(TxnId)"
if [[ -z ${2} ]]; then
curl -s \
-X PUT \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer '"$(</root/priv/root-access-token)" \
-d '{"msgtype":"m.text", "body":"'"${1}"'"}' \
"$instance"'/_matrix/client/r0/rooms/'"$RoomId"'/send/m.room.message/'"$(TxnId)"
else
curl -s \
-X PUT \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer '"$(</root/priv/root-access-token)" \
-d '{"msgtype":"m.text", "body":"'"SUBJECT: ${1}\n${2}"'"}' \
"$instance"'/_matrix/client/r0/rooms/'"$RoomId"'/send/m.room.message/'"$(TxnId)"
fi

View File

@ -1,6 +1,10 @@
#!/usr/bin/env -S bash -e
[[ -z "$1" ]] && {
printf "Usage: %s message\n" "$0"
printf "Usage: %s message [description]\n" "$0"
exit 1
}
echo "${1}" | hsendxmpp -u announcements -p "$(</root/priv/xmppannouncepasswd)" -j vern.cc -c announcements@muc.vern.cc -r announcementsbot
if [[ -z ${2} ]]; then
echo "${1}" | hsendxmpp -u announcements -p "$(</root/priv/xmppannouncepasswd)" -j vern.cc -c announcements@muc.vern.cc -r announcementsbot
else
printf "SUBJECT: ${1}\n${2}" | hsendxmpp -u announcements -p "$(</root/priv/xmppannouncepasswd)" -j vern.cc -c announcements@muc.vern.cc -r announcementsbot
fi