Skip to content

Commit

Permalink
matrix markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
EnigmaCurry committed Jun 22, 2024
1 parent 0b1716f commit 7489e04
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config/bash/alias.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias bb='rlwrap bb'
alias ec="${HOME}/git/vendor/enigmacurry/emacs/ec"

vars() { set -o posix; set | cut -d= -f1 | column; }
21 changes: 18 additions & 3 deletions config/bash/matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
## https://matrix-org.github.io/matrix-hookshot/latest/hookshot.html
## https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/docs/configuring-playbook-bridge-hookshot.md

## Put these required config vars into your ~/.bashrc.local :
## MATRIX_ALERT_WEBHOOK=https://matrix.enigmacurry.com/hookshot/webhooks/XXXXXXX
## BCT_ACTION_COMMAND='matrix-send "Command completed on ${HOSTNAME} :: ${output_str}"'

matrix-alert() {
if [[ -n "${MATRIX_ALERT_WEBHOOK}" ]]; then
curl -X POST "${MATRIX_ALERT_WEBHOOK}" --json '{"text":"'"$*"'"}' >/dev/null 2>&1
Expand All @@ -13,6 +17,17 @@ matrix-alert() {
fi
}

## Put this in your ~/.bashrc.local :
## MATRIX_ALERT_WEBHOOK=https://matrix.enigmacurry.com/hookshot/webhooks/XXXXXXX
## BCT_ACTION_COMMAND='matrix-send "Command completed on ${HOSTNAME} :: ${output_str}"'
matrix-markdown() {
local MARKDOWN_FILE=$1;
if [[ ! -f "${MARKDOWN_FILE}" ]]; then
echo "Markdown file does not exist: ${MARKDOWN_FILE}" >/dev/stderr
return 1
fi
if [[ -z "${MATRIX_ALERT_WEBHOOK}" ]]; then
echo "Missing MATRIX_ALERT_WEBHOOK env var." >/dev/stderr
return 1
else
curl -X POST "${MATRIX_ALERT_WEBHOOK}" --json "$(echo "{}" | jq -c --rawfile md $1 '.text=$md')" >/dev/null 2>&1
fi
}

0 comments on commit 7489e04

Please sign in to comment.