new: Added support for Gotify notifications

This commit is contained in:
Sayantan Santra 2023-06-22 00:59:32 -05:00
parent bfb0981e05
commit 53c430d75a
Signed by: SinTan1729
GPG key ID: EB3E68BFBA25C85F
3 changed files with 26 additions and 6 deletions

View file

@ -1,5 +1,5 @@
# Revanced Builder
This repo will allow one to build [ReVanced](https://github.com/revanced/) apps automatically and post it to a telegram channel to access and possibly share the builds with friends. It uses [telegram.sh](https://github.com/fabianonline/telegram.sh) to send messages and [telegram-upload](https://github.com/Nekmo/telegram-upload) to upload files (optionally, disabled out by default). Make sure that `Java >=17` is installed and selected as default.
This repo will allow one to build [ReVanced](https://github.com/revanced/) apps automatically and post it to a telegram channel to access and possibly share the builds with friends. It uses [Gotify](https://gotify.net) or [telegram.sh](https://github.com/fabianonline/telegram.sh) to send messages and [telegram-upload](https://github.com/Nekmo/telegram-upload) to upload files (optionally, disabled out by default). Make sure that `Java >=17` is installed and selected as default.
## How to use
Just run `./build_revanced <working-directory> (force/clean/experimental/checkonly)`. Might be a good idea to set it up to run periodically using cron. I currently use the following in a user crontab to run it everyday at 6 AM:
@ -11,7 +11,7 @@ Just run `./build_revanced <working-directory> (force/clean/experimental/checkon
- To enable build for a particular apk, copy the `build_settings` file to your working directory and modify it to suit your needs.
- The script will download the **automatically selected compatible version** (using compatibility of patches as listed [here](https://github.com/revanced/revanced-patches#list-of-available-patches)) of Youtube on APKMirror, **NOT** latest official version on Google Play.
- Under **NO CIRCUMSTANCES** any APKs will be uploaded to this repository to avoid DMCA.
- If you enable the telegram notifications or uploads, make sure to fill up the config options inside the `build_settings` file. For more information about the config, take at look at the repos of `telegram.sh` and `telegram-upload` provided above.
- If you enable the Gotify or telegram notifications or uploads, make sure to fill up the config options inside the `build_settings` file. For more information about the config, take at look at the repos of `telegram.sh` and `telegram-upload` provided above.
- It can also run a post script (if exists) called `post_script.sh`. The `timestamp` is passed as `$1`.
- In the current configuration, the script only builds YouTube ReVanced and YouTube Music ReVanced (both nonroot), but it's easy to add support for any other ReVanced app. The code for root builds is included but disabled by default.
- All the packages are pulled from [APKMirror](https://apkmirror.com) and GitHub (the `revanced/*` repos).

View file

@ -253,18 +253,30 @@ if $TG_UPLOAD; then
/home/sintan/.local/bin/telegram-upload YouTube_ReVanced_nonroot_$timestamp.apk YouTube_Music_ReVanced_nonroot_$timestamp.apk --to "$CHANNEL_ADDRESS" --caption "" && sent=true
fi
# Create the message to be sent
msg=$(cat versions.json | tail -n+2 | head -n-1 | cut -c3- | sed "s/\"//g" | sed "s/,//g" | sed "s/com.google.android.apps.youtube.music/YouTube Music/" |
sed "s/com.google.android.youtube/YouTube/" | sed "s/VancedMicroG/Vanced microG/" | sed "s/revanced-/ReVanced /g" | sed "s/patches/Patches/" |
sed "s/cli/CLI/" | sed "s/integrations/Integrations/" | awk 1 ORS=$'\n') # I know, it's a hacky solution
if $TG_NOTIFICATIONS; then
echo "Sending messages to telegram"
# telegram.sh uses bot account, but it supports formatted messages
[[ "$TELEGRAM_TOKEN" == "" || "$TELEGRAM_CHAT" == "" ]] && echo "Please provide valid channel address in the settings!"
msg=$(cat versions.json | tail -n+2 | head -n-1 | cut -c3- | sed "s/\"//g" | sed "s/,//g" | sed "s/com.google.android.apps.youtube.music/YouTube Music/" |
sed "s/com.google.android.youtube/YouTube/" | sed "s/VancedMicroG/Vanced microG/" | sed "s/revanced-/ReVanced /g" | sed "s/patches/Patches/" |
sed "s/cli/CLI/" | sed "s/integrations/Integrations/" | awk 1 ORS=$'\n') # I know, it's a hacky solution
# [ $sent ] &&
./telegram.sh -t "$TELEGRAM_TOKEN" -c "$TELEGRAM_CHAT" -T "⚙⚙⚙ Build Details ⚙⚙⚙" -M "$msg"$'\n'"Timestamp: $timestamp"$'\n'"⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯"
[ $microg_updated ] && ./telegram.sh -t "$TELEGRAM_TOKEN" -c "$TELEGRAM_CHAT" -M "_An update of microg was published._"
fi
if $GOTIFY_NOTIFICATIONS; then
echo "Sending messages to Gotify"
MESSAGE="$msg"$'\n'"Timestamp: $timestamp"
curl -X POST "$GOTIFY_URL/message?token=$GOTIFY_TOKEN" \
-F "title=⚙⚙⚙ Build Details ⚙⚙⚙" -F "message=$MESSAGE" -F "priority=5"
MESSAGE="An update of microg was published."
[ $microg_updated ] && curl -X POST "$GOTIFY_URL/message?token=$GOTIFY_TOKEN" \
-F "title=⚙⚙⚙ Build Details ⚙⚙⚙" -F "message=$MESSAGE" -F "priority=5"
fi
# Do some cleanup, keep only the last 3 build's worth of files and a week worth of logs
mkdir -p archive
mv *ReVanced_*_$timestamp.apk archive/

View file

@ -20,3 +20,11 @@ TELEGRAM_CHAT=""
# Check out README for instructions
TG_UPLOAD=false
CHANNEL_ADDRESS=""
# Settings for sending Gotify notifications
# In case you decide to use it, please put valid config in the
# URL and TOKEN fields
# Check out README for instructions
GOTIFY_NOTIFICATIONS=false
GOTIFY_URL="https://push.example.com"
GOTIFY_TOKEN=""