mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
Deploy Bot with Local API Server via multiprocessing
This commit is contained in:
parent
2973df379f
commit
31aea5612e
41
.github/tg.py
vendored
41
.github/tg.py
vendored
@ -1,19 +1,36 @@
|
|||||||
import telegram
|
import telegram
|
||||||
from tgconfig import *
|
from tgconfig import *
|
||||||
from json import load
|
from json import load
|
||||||
|
import multiprocessing
|
||||||
|
from os import system as run
|
||||||
|
from time import sleep as wait
|
||||||
|
|
||||||
f = open('commit.json')
|
def deploy():
|
||||||
data = load(f)
|
run(f'~/bot-api --local --api_id={TG_API_ID} --api_hash={TG_API_HASH}')
|
||||||
f.close()
|
|
||||||
|
|
||||||
bot = telegram.Bot(TG_TOKEN)
|
def bot():
|
||||||
bot.send_photo(TG_POST_ID, open('alpha.png', 'rb'), f'''*Libretube {data['sha'][0:7]} // Alpha*
|
wait(10)
|
||||||
|
f = open('commit.json')
|
||||||
|
data = load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
{data['commit']['message']}
|
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*
|
||||||
|
|
||||||
Signed-off-by: {data['commit']['author']['name']}
|
{data['commit']['message']}
|
||||||
''', parse_mode=telegram.ParseMode.MARKDOWN)
|
|
||||||
bot.send_document(TG_POST_ID, open('app-arm64-v8a-debug.apk', 'rb'))
|
Signed-off-by: {data['commit']['author']['name']}
|
||||||
bot.send_document(TG_POST_ID, open('app-armeabi-v7a-debug.apk', 'rb'))
|
''', parse_mode=telegram.ParseMode.MARKDOWN)
|
||||||
bot.send_document(TG_POST_ID, open('app-x86_64-debug.apk', 'rb'))
|
bot.send_document(TG_POST_ID, open('app-arm64-v8a-debug.apk', 'rb'))
|
||||||
bot.send_document(TG_POST_ID, open('app-x86-debug.apk', 'rb'))
|
bot.send_document(TG_POST_ID, open('app-armeabi-v7a-debug.apk', 'rb'))
|
||||||
|
bot.send_document(TG_POST_ID, open('app-x86_64-debug.apk', 'rb'))
|
||||||
|
bot.send_document(TG_POST_ID, open('app-x86-debug.apk', 'rb'))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
multideploy = multiprocessing.Process(target=deploy)
|
||||||
|
multibot = multiprocessing.Process(target=bot)
|
||||||
|
multideploy.start()
|
||||||
|
multibot.start()
|
||||||
|
multideploy.join()
|
||||||
|
multibot.join()
|
||||||
|
3
.github/workflows/tg-bot.yml
vendored
3
.github/workflows/tg-bot.yml
vendored
@ -39,7 +39,8 @@ jobs:
|
|||||||
mv ./app/build/outputs/apk/debug/*.apk .github/
|
mv ./app/build/outputs/apk/debug/*.apk .github/
|
||||||
cd .github
|
cd .github
|
||||||
curl https://libre-tube.github.io/assets/LibreAlpha.png --output alpha.png
|
curl https://libre-tube.github.io/assets/LibreAlpha.png --output alpha.png
|
||||||
curl https://raw.githubusercontent.com/LibreTubeAlpha/Telegram-BotAPI/main/bin/telegram-bot-api --output bot-api
|
curl https://raw.githubusercontent.com/LibreTubeAlpha/Telegram-BotAPI/main/exec --output ~/bot-api
|
||||||
|
chmod 755 ~/bot-api
|
||||||
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user