forked from PixelExtended/OTA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tg_notify.sh
48 lines (39 loc) · 1.79 KB
/
tg_notify.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
DEVICE_JSON_URL="https://raw.githubusercontent.com/PixelExtended/OTA/trece"
DEVICE_CHANGELOG_URL="https://raw.githubusercontent.com/PixelExtended/OTA/trece/changelogs/"
CHANGED_FILE="$(git diff --name-only HEAD~1 | head -1)"
if ! [[ "${CHANGED_FILE}" =~ "json" ]]; then
echo "Skipping since no json file was changed!"
exit 0
fi
STATUS="$(jq -r '.status' "${CHANGED_FILE}")"
DEVICE="$(jq -r '.device' "${CHANGED_FILE}")"
STICKER="sticker.tgs"
PHOTO="banner.jpeg"
BUILD_DATE="$(date +'%d-%b-%Y' -d @$(jq '.datetime' ${CHANGED_FILE}))"
CHANGELOG="${DEVICE_CHANGELOG_URL}${DEVICE}/$(jq -r '.filename' "${CHANGED_FILE}")"
SFLINK="$(jq -r '.url' "${CHANGED_FILE}")"
DEVICE_NAME="$(jq -r '.device_name' "${CHANGED_FILE}")"
PEXV="$(jq -r '.pexv' "${CHANGED_FILE}")"
XDA="$(jq -r '.xda_thread' "${CHANGED_FILE}")"
USERNAME="$(jq -r '.tg_username' "${CHANGED_FILE}")"
ROM="https://github.com/PixelExtended/OTA/blob/trece/changelog.md"
DONATION="https://heisinbug.tech/pay"
if [[ $STATUS = "Active" ]]
then
curl -X POST -F sticker=@"${STICKER}" https://api.telegram.org/bot"${TOKEN}"/sendSticker -F chat_id="${CHAT_ID}"
curl -X POST -F photo=@"${PHOTO}" https://api.telegram.org/bot"${TOKEN}"/sendPhoto -F chat_id="${CHAT_ID}" -F parse_mode=HTML -F "caption=PixelExtended ${PEXV} OFFICIAL Update for ${DEVICE_NAME} is available
By : @${USERNAME}
Build Version : ${PEXV}
Build Date : ${BUILD_DATE}
Codename : ${DEVICE}
📥 Download : <a href='${SFLINK}'>SourceForge</a>
💬 XDA thread : <a href='${XDA}'>XDA</a>
📄 Changelog : <a href='${CHANGELOG}.txt'>Device</a> | <a href='${ROM}'>ROM</a>
Support : @pixelextended
Channel : @pexupdates
Site : pixelextended.tech
Liked My Project <a href='${DONATION}'>Donate Here</a>
#PEX #${DEVICE}"
else
echo "Device is inactive thus no notification pushed"
fi