Skip to content

Commit 478b5c6

Browse files
committed
🔨Feat(Ci): Support update to Telegram
1 parent 2e85653 commit 478b5c6

2 files changed

Lines changed: 47 additions & 8 deletions

File tree

.github/bot.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
CHAT_ID = int(os.environ.get("CHAT_ID"))
1111
BOT_CI_SESSION = os.environ.get("BOT_CI_SESSION")
1212

13-
async def send_telegram_files(files):
13+
async def send_telegram_files(files, caption=None):
1414
"""
1515
Connects to Telegram and sends the specified files as a group message.
1616
"""
@@ -25,18 +25,32 @@ async def send_telegram_files(files):
2525
await client.send_file(
2626
entity=CHAT_ID,
2727
file=files,
28+
caption=caption,
29+
parse_mode='html',
2830
)
2931
print("[+] Files sent successfully.")
3032

3133

3234
if __name__ == '__main__':
33-
if len(sys.argv) > 1:
34-
# Get all file paths from command-line arguments
35-
apk_files = sys.argv[1:]
36-
print(f"[+] Found files to upload: {apk_files}")
35+
caption = None
36+
files = []
37+
38+
args = sys.argv[1:]
39+
i = 0
40+
while i < len(args):
41+
if args[i] == '--caption':
42+
i += 1
43+
if i < len(args):
44+
caption = args[i]
45+
else:
46+
files.append(args[i])
47+
i += 1
48+
49+
if files:
50+
print(f"[+] Found files to upload: {files}")
51+
print(f"[+] Caption: {caption}")
3752
try:
38-
# Run the asynchronous function
39-
asyncio.run(send_telegram_files(apk_files))
53+
asyncio.run(send_telegram_files(files, caption=caption))
4054
except Exception as e:
4155
print(f"[-] An error occurred: {e}")
4256
else:

.github/workflows/Build Kernel.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,29 @@ jobs:
171171
with:
172172
name: ${{steps.gen_name.outputs.artifact_name}}
173173
path: kernel_workspace/AnyKernel3/*
174+
175+
- name: Generate Telegram caption
176+
id: gen_caption
177+
run: |
178+
COMMIT_SHA=$(git rev-parse --short HEAD)
179+
COMMIT_MSG=$(git log -1 --pretty=format:'%s')
180+
echo "caption<<EOF" >> $GITHUB_OUTPUT
181+
echo "<pre>" >> $GITHUB_OUTPUT
182+
echo "🔧 Commit: ${COMMIT_SHA} - ${COMMIT_MSG}" >> $GITHUB_OUTPUT
183+
echo "" >> $GITHUB_OUTPUT
184+
echo "📦 Feature:" >> $GITHUB_OUTPUT
185+
if [ "${{ github.event.inputs.BBR }}" = "true" ]; then
186+
echo "✅ BBR" >> $GITHUB_OUTPUT
187+
else
188+
echo "❌ BBR" >> $GITHUB_OUTPUT
189+
fi
190+
if [ "${{ github.event.inputs.DroidSpace }}" = "true" ]; then
191+
echo "✅ DroidSpace" >> $GITHUB_OUTPUT
192+
else
193+
echo "❌ DroidSpace" >> $GITHUB_OUTPUT
194+
fi
195+
echo "</pre>" >> $GITHUB_OUTPUT
196+
echo "EOF" >> $GITHUB_OUTPUT
174197
175198
- name: Upload to Telegram
176199
env:
@@ -179,6 +202,8 @@ jobs:
179202
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
180203
CHAT_ID: ${{ secrets.CHAT_ID }}
181204
BOT_CI_SESSION: ${{ secrets.BOT_CI_SESSION }}
205+
CAPTION: ${{ steps.gen_caption.outputs.caption }}
182206
run: |
183207
pip3 install telethon
184-
python3 .github/bot.py "$GITHUB_WORKSPACE/kernel_workspace/${{ steps.gen_name.outputs.artifact_name }}.zip"
208+
python3 .github/bot.py --caption "$CAPTION" \
209+
"$GITHUB_WORKSPACE/kernel_workspace/${{ steps.gen_name.outputs.artifact_name }}.zip"

0 commit comments

Comments
 (0)