TG upload with pyrogram.

This commit is contained in:
rozari0 2022-10-28 17:57:06 +06:00
parent ddafb9c769
commit 382a111eb7
2 changed files with 35 additions and 37 deletions

49
.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
import multiprocessing from os import listdir
from os import system
from time import sleep as wait
def deploy(): from pyrogram import Client
system(f'./exec --local --api-id={TG_API_ID} --api-hash={TG_API_HASH}') from pyrogram.types import InputMediaDocument
from tgconfig import *
def bot(): files = listdir()
wait(10)
f = open('commit.json') mediadocuments = [
InputMediaDocument(file) for file in files if file.endswith("signed.apk")
]
with open("commit.json") as f:
data = load(f) data = load(f)
f.close()
bot = telegram.Bot(TG_TOKEN, base_url="http://0.0.0.0:8081/bot") caption = f"""**Libretube {data['sha'][0:7]} // Alpha**
bot.send_photo(TG_POST_ID, open('alpha.png', 'rb'), 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')
if __name__ == '__main__':
multideploy = multiprocessing.Process(target=deploy) async def main():
multibot = multiprocessing.Process(target=bot) async with Client("libretube", TG_API_ID, TG_API_HASH, bot_token=TG_TOKEN) as app:
multideploy.start() await app.send_photo(
multibot.start() int(TG_POST_ID), "https://libre-tube.github.io/images/Alpha.png", caption
multideploy.join() )
multibot.join() await app.send_media_group(int(TG_POST_ID), mediadocuments)
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