Skip to content

Commit

Permalink
patch twnesss
Browse files Browse the repository at this point in the history
  • Loading branch information
twnesss committed Jul 29, 2024
1 parent 4167aa6 commit a405573
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 1 deletion.
84 changes: 84 additions & 0 deletions .github/taamarinbot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import asyncio
import os
import sys
from telethon import TelegramClient
from telethon.tl.functions.help import GetConfigRequest

API_ID = os.environ.get("API_ID")
API_HASH = os.environ.get("API_HASH")

CHAT_ID = int(os.environ.get("CHAT_ID"))
MESSAGE_THREAD_ID = int(os.environ.get("MESSAGE_THREAD_ID"))
BOT_TOKEN = os.environ.get("BOT_TOKEN")
VERSION = os.environ.get("VERSION")
COMMIT = os.environ.get("COMMIT")
MSG_TEMPLATE = """
{version}
Commit:
{commit}
[source fork](https://github.com/LawnchairLauncher/lawnicons)
#Android #apk #icon #pack
""".strip()

def get_caption():
msg = MSG_TEMPLATE.format(
version=VERSION,
commit=COMMIT
)
if len(msg) > 1024:
return COMMIT
return msg

def check_environ():
if BOT_TOKEN is None:
print("[-] Invalid BOT_TOKEN")
exit(1)
if CHAT_ID is None:
print("[-] Invalid CHAT_ID")
exit(1)
if MESSAGE_THREAD_ID is None:
print("[-] Invalid MESSAGE_THREAD_ID")
exit(1)
if VERSION is None:
print("[-] Invalid VERSION")
exit(1)
if COMMIT is None:
print("[-] Invalid COMMIT")
exit(1)

async def main():
print("[+] Uploading to telegram")
check_environ()
files = sys.argv[1:]
print("[+] Files:", files)
if len(files) <= 0:
print("[-] No files to upload")
exit(1)
print("[+] Logging in Telegram with bot")
script_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
session_dir = os.path.join(script_dir, "bot.session")
async with await TelegramClient(session=session_dir, api_id=API_ID, api_hash=API_HASH).start(bot_token=BOT_TOKEN) as bot:
caption = [""] * len(files)
caption[-1] = get_caption()
print("[+] Caption: ")
print("---")
print(caption)
print("---")
print("[+] Sending")
sent_messages = await bot.send_file(entity=CHAT_ID, file=files, caption=caption, reply_to=MESSAGE_THREAD_ID, parse_mode="markdown")

# Pin the last sent message
if sent_messages:
last_message_id = sent_messages[-1].id
await bot.pin_message(entity=CHAT_ID, message=last_message_id)

print("[+] Done!")

if __name__ == "__main__":
try:
asyncio.run(main())
except Exception as e:
print(f"[-] An error occurred: {e}")
102 changes: 102 additions & 0 deletions .github/workflows/build_apk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Build APK

on:
workflow_dispatch:
push:
branches:
- develop

jobs:
build-release-apk:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: checkout repository
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0

- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17

- uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

- name: write sign info
run: |
if [ ! -z "${{ secrets.KEYSTORE_CONTENT }}" ]; then
echo storePassword='${{ secrets.KEYSTORE_PASSWORD }}' >> keystore.properties
echo keyAlias='${{ secrets.KEY_ALIAS }}' >> keystore.properties
echo keyPassword='${{ secrets.KEY_PASSWORD }}' >> keystore.properties
echo storeFile='${{ github.workspace }}/key.jks' >> keystore.properties
echo ${{ secrets.KEYSTORE_CONTENT }} | base64 --decode > key.jks
fi
- name: prepare prebuild
run: |
chmod +x gradlew
./gradlew svg-processor:run
- name: build with gradle
run: |
./gradlew app:assembleRelease
- name: checking release version
id: version
run: |
echo ::set-output name=release_version::$(cat app/build.gradle.kts | grep -o "versionName = \"[0-9.]*\"" | grep -o "[0-9.]*")
echo ::set-output name=release_patch::$(git rev-parse --short HEAD)
- name: rename apks
run: |
APK="lawn_icons_v${{ steps.version.outputs.release_version }}_${{ steps.version.outputs.release_patch }}.apk"
mv -f app/build/outputs/apk/app/release/*.apk app/build/outputs/apk/app/release/$APK
- name: upload artifact
uses: actions/upload-artifact@v3
with:
name: Release apk
path: app/build/outputs/apk/app/release/*.apk

- uses: andreaswilli/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: Prerelease
deleteOnlyFromDrafts: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: richardsimko/[email protected]
with:
tag_name: Prerelease
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: softprops/action-gh-release@v1
with:
tag_name: Prerelease
files: app/build/outputs/apk/app/release/*.apk
draft: false
prerelease: true
generate_release_notes: true

# - name: upload to telegram
# if: ${{ success() }}
# env:
# CHAT_ID: "-1001597117128"
# MESSAGE_THREAD_ID: "282263"
# API_HASH: ${{ secrets.API_HASH }}
# API_ID: ${{ secrets.API_ID }}
# BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
# run: |
# if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
# export VERSION="lawn_icons_v${{ steps.version.outputs.release_version }}_${{ steps.version.outputs.release_patch }}"
# export COMMIT=$(git log --oneline -n 10 --no-decorate | sed 's/^[0-9a-f]* //' | sed 's/^/— /')
# FILE=$(find ./app/build/outputs/apk/app/release -name "*.apk")
# pip3 install telethon==1.31.1
# python3 $GITHUB_WORKSPACE/.github/taamarinbot.py $FILE
# fi
2 changes: 2 additions & 0 deletions app/assets/appfilter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12307,4 +12307,6 @@
<item component="ComponentInfo{com.starbucks.co/com.starbucks.co2.ui.intro.IntroActivity}" drawable="starbucks" name="스타벅스 ~~ Starbucks" />
<item component="ComponentInfo{viva.republica.toss/viva.republica.toss.splash.SplashActivity}" drawable="toss" name="토스 ~~ Toss" />
<item component="ComponentInfo{space.takashima.keypo/org.mozc.android.inputmethod.japanese.LauncherActivity}" drawable="keyboard" name="タクト キーボード ~~ Takt keyboard" />
<item component="ComponentInfo{ru.fieldtest.modemcaps/a.am}" drawable="qct_modem_capabilities" name="Qct Modem" />
<item component="ComponentInfo{xyz.chz.bfm/xyz.chz.bfm.ui.activity.MainActivity}" drawable="box_manager" name="Box Manager" />
</resources>
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ android {
minSdk = 26
targetSdk = compileSdk
versionCode = 14
versionName = versionDisplayName
versionName = "4.0"
vectorDrawables.useSupportLibrary = true
}

Expand Down
1 change: 1 addition & 0 deletions svgs/box_manager.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions svgs/qct_modem_capabilities.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a405573

Please sign in to comment.