Telegram APK Auto-Patcher #135
This file contains 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
name: Telegram APK Auto-Patcher | |
on: | |
schedule: | |
- cron: '0 */12 * * *' | |
workflow_dispatch: | |
jobs: | |
auto_patch: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'adopt' | |
java-version: '17' | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: sudo apt-get install -y wget zipalign aapt | |
- name: Download Telegram APK | |
run: | | |
tg_apk_url="https://telegram.org/dl/android/apk" | |
wget -q --show-progress $tg_apk_url -O Telegram.apk | |
- name: Get latest Telegram version | |
id: get_version | |
run: | | |
aapt dump badging Telegram.apk | grep -oP "versionName='[^']*" | cut -d "'" -f2 > tg_version.txt | |
echo "Latest version: $(cat tg_version.txt)" | |
- name: Check if new version is available | |
id: version_check | |
run: | | |
if [ -f backup_tg_version.txt ]; then | |
old_version=$(cat backup_tg_version.txt) | |
else | |
old_version="" | |
fi | |
new_version=$(cat tg_version.txt) | |
if [ "$new_version" != "$old_version" ]; then | |
echo "new_version_available=true" >> $GITHUB_ENV | |
else | |
echo "new_version_available=false" >> $GITHUB_ENV | |
fi | |
- name: Download apktool | |
if: env.new_version_available == 'true' | |
run: | | |
if [ ! -f apktool.jar ]; then | |
echo "apktool.jar not found, downloading..." | |
wget -q --show-progress https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.10.0.jar -O apktool.jar | |
fi | |
- name: Decompile APK | |
if: env.new_version_available == 'true' | |
run: | | |
java -jar apktool.jar d Telegram.apk -f | |
rm -rf Telegram/lib/x86* | |
- name: Apply Normal Patches | |
if: env.new_version_available == 'true' | |
run: | | |
echo "Applying Normal Patches..." | |
python3 tgpatcher.py --normal --dir Telegram/ | |
echo "Patches applied, building apk..." | |
java -jar apktool.jar b Telegram/ -o Telegram_Patched.apk | |
echo "NOTE: apk may not be signed, you may need to sign it manually." | |
- name: Apply Anti+Normal Patches | |
if: env.new_version_available == 'true' | |
run: | | |
java -jar apktool.jar d Telegram.apk -f | |
rm -rf Telegram/lib/x86* | |
echo "Applying Anti+Normal Patches..." | |
python3 tgpatcher.py --anti --dir Telegram/ | |
echo "Patches applied, building apk..." | |
java -jar apktool.jar b Telegram/ -o Telegram_Anti_Patched.apk | |
echo "NOTE: apk may not be signed, you may need to sign it manually." | |
- name: ZipAlign APks | |
if: env.new_version_available == 'true' | |
run: | | |
zipalign -p -f 4 Telegram_Patched.apk Telegram_Patched_aligned.apk | |
rm Telegram_Patched.apk | |
zipalign -p -f 4 Telegram_Anti_Patched.apk Telegram_Anti_Patched_aligned.apk | |
rm Telegram_Anti_Patched.apk | |
- name: Sign APks | |
if: env.new_version_available == 'true' | |
run: | | |
java -jar keystore/apksigner.jar sign --in Telegram_Patched_aligned.apk --out Telegram_Patched.apk --ks keystore/debug.keystore --ks-key-alias androiddebugkey --ks-pass pass:android --key-pass pass:android --v1-signing-enabled true --v2-signing-enabled true --v3-signing-enabled true --v4-signing-enabled false | |
rm Telegram_Patched_aligned.apk | |
java -jar keystore/apksigner.jar sign --in Telegram_Anti_Patched_aligned.apk --out Telegram_Anti_Patched.apk --ks keystore/debug.keystore --ks-key-alias androiddebugkey --ks-pass pass:android --key-pass pass:android --v1-signing-enabled true --v2-signing-enabled true --v3-signing-enabled true --v4-signing-enabled false | |
rm Telegram_Anti_Patched_aligned.apk | |
- name: Set Telegram Version | |
if: env.new_version_available == 'true' | |
id: set_version | |
run: echo "version=$(cat tg_version.txt)" >> $GITHUB_ENV | |
- name: Install upload requirements | |
if: env.new_version_available == 'true' | |
run: pip install pyrofork tgcrypto | |
- name: Send Normal APK to Telegram | |
if: env.new_version_available == 'true' | |
run: | | |
export BOT_TOKEN=${{ secrets.BOT_TOKEN }} | |
export API_ID=${{ secrets.API_ID }} | |
export API_HASH=${{ secrets.API_HASH }} | |
python3 tgupload.py Telegram_Patched.apk --chat-id ${{ secrets.CHAT_ID }} --caption "$(cat <<EOF | |
**Telegram [ Premium ] [ Local+ ] [ Direct ] [ Normal ]** | |
**Version :** ${{ env.version }} | |
**Architecture :** Arm + Arm64 | |
**Requirements:** Android 6.0 and up | |
**Overview:** | |
Telegram is a messaging app with a focus on speed and security. | |
**❏Changelogs:** | |
● See [Full Changelogs](https://telegra.ph/Telegram-premium-08-16-5) | |
- **Released by [ Abhi ]** | |
👉 **How to Save/Forward from copyrighted channels:** [Watch Here](https://youtu.be/TIlxcnzC-mM) | |
**NOTE:** | |
- If you're **facing issue during login** like internal error, not getting OTP then **download Telegram X** from play store -> Login in it -> come back and login to mod | |
- Adding stories functionality gets unlocked with premium mod, but | |
- If you still didn't get the story feature, [read more about it here](http://tginfo.me/stories-by-countries) | |
EOF | |
)" | |
- name: Send Anti APK to Telegram | |
if: env.new_version_available == 'true' | |
run: | | |
export BOT_TOKEN=${{ secrets.BOT_TOKEN }} | |
export API_ID=${{ secrets.API_ID }} | |
export API_HASH=${{ secrets.API_HASH }} | |
python3 tgupload.py Telegram_Anti_Patched.apk --chat-id ${{ secrets.CHAT_ID }} --caption "$(cat <<EOF | |
**Telegram [ Premium ] [ Local+ ] [ Direct ] [ Anti ]** | |
**Version :** ${{ env.version }} | |
**Architecture :** Arm + Arm64 | |
**Requirements:** Android 6.0 and up | |
**Overview:** | |
Telegram is a messaging app with a focus on speed and security. | |
**❏Changelogs:** | |
● See [Full Changelogs](https://telegra.ph/Telegram-premium-08-16-5) | |
- **Released by [ Abhi ]** | |
👉 **How to Save/Forward from copyrighted channels:** [Watch Here](https://youtu.be/TIlxcnzC-mM) | |
**NOTE:** | |
- If you're **facing issue during login** like internal error, not getting OTP then **download Telegram X** from play store -> Login in it -> come back and login to mod | |
- Adding stories functionality gets unlocked with premium mod, but | |
- If you still didn't get the story feature, [read more about it here](http://tginfo.me/stories-by-countries) | |
EOF | |
)" | |
- name: Update version files and commit changes | |
if: env.new_version_available == 'true' | |
run: | | |
cp tg_version.txt backup_tg_version.txt | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add backup_tg_version.txt | |
git commit -m "Update version files to $(cat tg_version.txt)" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |