docs(bots): Simplify variable handling

Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com>
Signed-off-by: Michael Bell <mb@igloos.one>
This commit is contained in:
Michael Bell 2025-11-26 20:46:32 +10:00 committed by GitHub
parent a6f3dc816e
commit 0801853077
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -335,32 +335,10 @@ Bots can also send message. On the sending process the same signature/verificati
```bash
#!/bin/bash
# Required environment variables:
# NC_URL: The URL of the Nextcloud instance (e.g., "https://nextcloud.example.com")
# TOKEN: The token of the conversation
# SECRET: Shared secret that is specified when installing a bot
# MESSAGE: The message to be sent
# Check if required variables are set
if [ -z "$NC_URL" ]; then
echo "Error: NC_URL is not set."
exit 1
fi
if [ -z "$TOKEN" ]; then
echo "Error: TOKEN is not set."
exit 1
fi
if [ -z "$SECRET" ]; then
echo "Error: SECRET is not set."
exit 1
fi
if [ -z "$MESSAGE" ]; then
echo "Error: MESSAGE is not set."
exit 1
fi
NC_URL="https://nextcloud.example.tld/" # The URL of the Nextcloud instance (e.g., "https://nextcloud.example.com")
TOKEN="12345678" # The token of the conversation
SECRET="53CR3T" # Shared secret that is specified when installing a bot
MESSAGE=$1 # Pass the message as first argument
# Generate a random header and signature
RANDOM_HEADER=$(openssl rand -hex 32)