Created
May 20, 2024 22:15
-
-
Save edubxb/e09beb643bec805a044fe06b45dd75b7 to your computer and use it in GitHub Desktop.
OpenMediaVault Telegram notification script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## +info: ## | |
## https://docs.openmediavault.org/en/latest/administration/general/notifications.html#third-party-notifications | |
## https://forum.openmediavault.org/index.php?thread/14919-guide-use-telegram-as-notification-service/ | |
BOT_TOKEN="<BOT_TOKEN>" | |
CHAT_ID="<CHAT_ID>" | |
URL="https://api.telegram.org/bot${BOT_TOKEN}" | |
MSG_URL="${URL}/sendMessage?chat_id=${CHAT_ID}&parse_mode=Markdown" | |
MSG_ICON="" | |
if [[ "${OMV_NOTIFICATION_SUBJECT}" =~ ^Monitoring\ (alert|restart).* ]]; then | |
MSG_ICON="π¨ " | |
elif [[ "${OMV_NOTIFICATION_SUBJECT}" =~ ^Cron.* ]] || | |
[[ "${OMV_NOTIFICATION_SUBJECT}" =~ ^CRON-APT\ .* ]] || | |
[[ "${OMV_NOTIFICATION_SUBJECT}" =~ ^Anacron\ .* ]]; then | |
MSG_ICON="π " | |
elif [[ "${OMV_NOTIFICATION_SUBJECT}" =~ ^.*SECURITY.* ]] || | |
[[ "${OMV_NOTIFICATION_SUBJECT}" =~ ^Your\ user\ account\ was\ used\ to\ log\ in\ to\ the\ openmediavault\ control\ panel\ via\ a\ web\ browser ]]; then | |
MSG_ICON="π " | |
elif [[ "${OMV_NOTIFICATION_SUBJECT}" =~ ^Pending\ configuration.* ]]; then | |
MSG_ICON="βοΈ " | |
fi | |
content="${MSG_ICON}*ARK* | |
**${OMV_NOTIFICATION_SUBJECT}** | |
__${OMV_NOTIFICATION_DATE}__ | |
\`\`\` | |
$(cat ${OMV_NOTIFICATION_MESSAGE_FILE}) | |
\`\`\`" | |
curl --data-urlencode "text=${content[@]}" "${MSG_URL}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment