Merge pull request #1669 from TheCrowClub/master

TG upload with pyrogram.
This commit is contained in:
Bnyro 2022-10-28 21:35:28 +02:00 committed by GitHub
commit e6545ca265
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 37 deletions

67
.github/tg.py vendored
View File

@ -1,33 +1,34 @@
import telegram import asyncio
from tgconfig import * from json import load
from json import load from os import listdir
import multiprocessing
from os import system from pyrogram import Client
from time import sleep as wait from pyrogram.types import InputMediaDocument
from tgconfig import *
def deploy():
system(f'./exec --local --api-id={TG_API_ID} --api-hash={TG_API_HASH}') files = listdir()
def bot(): mediadocuments = [
wait(10) InputMediaDocument(file) for file in files if file.endswith("signed.apk")
f = open('commit.json') ]
data = load(f)
f.close() with open("commit.json") as f:
data = load(f)
bot = telegram.Bot(TG_TOKEN, base_url="http://0.0.0.0:8081/bot")
bot.send_photo(TG_POST_ID, open('alpha.png', 'rb'), f'''*Libretube {data['sha'][0:7]} // Alpha* caption = f"""**Libretube {data['sha'][0:7]} // Alpha**
[{data['commit']['message']}]({data['html_url']}) <a href="{data['html_url']}">{data['commit']['message']}</a>
Signed-off-by: {data['commit']['author']['name']} Signed-off-by: {data['commit']['author']['name']}
''', parse_mode=telegram.ParseMode.MARKDOWN) """
bot.send_media_group(TG_POST_ID, [telegram.InputMediaDocument(open('app-universal-debug-signed.apk', 'rb')), telegram.InputMediaDocument(open('app-x86-debug-signed.apk', 'rb')), telegram.InputMediaDocument(open('app-x86_64-debug-signed.apk', 'rb')), telegram.InputMediaDocument(open('app-armeabi-v7a-debug-signed.apk', 'rb')), telegram.InputMediaDocument(open('app-arm64-v8a-debug-signed.apk', 'rb'))])
system('killall -9 python')
async def main():
if __name__ == '__main__': async with Client("libretube", TG_API_ID, TG_API_HASH, bot_token=TG_TOKEN) as app:
multideploy = multiprocessing.Process(target=deploy) await app.send_photo(
multibot = multiprocessing.Process(target=bot) int(TG_POST_ID), "https://libre-tube.github.io/images/Alpha.png", caption
multideploy.start() )
multibot.start() await app.send_media_group(int(TG_POST_ID), mediadocuments)
multideploy.join()
multibot.join()
asyncio.run(main())

View File

@ -81,15 +81,12 @@ jobs:
continue-on-error: true continue-on-error: true
run: | run: |
cd archive cd archive
curl https://libre-tube.github.io/images/Alpha.png --output alpha.png
chmod 755 ./exec
mv ../tgconfig.py . mv ../tgconfig.py .
echo "TG_TOKEN = '${{ secrets.TG_TOKEN }}'" >> tgconfig.py echo "TG_TOKEN = '${{ secrets.TG_TOKEN }}'" >> tgconfig.py
echo "TG_API_ID = '${{ secrets.TG_API_ID }}'" >> tgconfig.py echo "TG_API_ID = '${{ secrets.TG_API_ID }}'" >> tgconfig.py
echo "TG_POST_ID = '${{ secrets.TG_POST_ID }}'" >> tgconfig.py echo "TG_POST_ID = '${{ secrets.TG_POST_ID }}'" >> tgconfig.py
echo "TG_API_HASH = '${{ secrets.TG_API_HASH }}'" >> tgconfig.py echo "TG_API_HASH = '${{ secrets.TG_API_HASH }}'" >> tgconfig.py
python -m pip install --upgrade pip python -m pip install --upgrade pip TgCrypto Pyrogram
pip install python-telegram-bot
mv ../.github/tg.py . mv ../.github/tg.py .
mv ../.github/commit.json . mv ../.github/commit.json .
python tg.py python tg.py