Optimized for API

This commit is contained in:
2023-01-17 14:11:23 +01:00
parent 9f0ed202da
commit aebe804b58
7 changed files with 156 additions and 36 deletions

View File

@@ -70,6 +70,7 @@ if args.norun:
try:
from modules.app import app
from pyrogram import idle
from requests import get, post
except ModuleNotFoundError:
print(locale("deps_missing", "console", locale=configGet("locale")), flush=True)
exit()
@@ -122,6 +123,9 @@ if configGet("submit", "mode"):
from modules.callbacks.submission import *
from modules.commands.mode_submit import *
from modules.handlers.submission import *
if configGet("api_based", "mode"):
from modules.api_client import authorize
#===========================================================================================================================================
# Work in progress
@@ -147,6 +151,11 @@ if __name__ == "__main__":
if configGet("post", "mode"):
scheduler.start()
if configGet("api_based", "mode"):
token = authorize()
if len(get(f'{configGet("address", "posting", "api")}/albums?q={configGet("queue", "posting", "api", "albums")}', headers={"Authorization": f"Bearer {token}"}).json()["results"]) == 0:
post(f'{configGet("address", "posting", "api")}/albums?name={configGet("queue", "posting", "api", "albums")}&title={configGet("queue", "posting", "api", "albums")}', headers={"Authorization": f"Bearer {token}"})
idle()
app.send_message(configGet("admin"), locale("shutdown", "message", locale=configGet("locale")).format(str(pid)))