LibreTube/.github/tg.py

34 lines
1.2 KiB
Python
Raw Normal View History

2022-06-12 00:47:52 +05:30
import telegram
2022-06-16 14:33:41 +05:30
from tgconfig import *
2022-06-12 23:11:49 +05:30
from json import load
import multiprocessing
2022-06-18 00:55:25 +05:30
import os
from time import sleep as wait
2022-06-12 23:11:49 +05:30
def deploy():
2022-06-18 00:55:25 +05:30
os.system(f'~/bot-api --local --api-id={TG_API_ID} --api-hash={TG_API_HASH}')
2022-06-12 00:47:52 +05:30
def bot():
wait(10)
f = open('commit.json')
data = load(f)
f.close()
2022-06-15 21:45:39 +05:30
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*
2022-06-15 21:45:39 +05:30
2022-06-18 00:31:22 +05:30
{data['commit']['message']}
2022-06-18 00:31:22 +05:30
Signed-off-by: {data['commit']['author']['name']}
''', parse_mode=telegram.ParseMode.MARKDOWN)
2022-06-18 19:43:57 +05:30
bot.send_media_group(TG_POST_ID, [telegram.InputMediaDocument(open('app-x86-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-x86_64-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-armeabi-v7a-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-arm64-v8a-debug.apk', 'rb'))])
2022-06-18 19:50:08 +05:30
os.system('killall -9 python || true')
if __name__ == '__main__':
multideploy = multiprocessing.Process(target=deploy)
multibot = multiprocessing.Process(target=bot)
multideploy.start()
multibot.start()
multideploy.join()
multibot.join()