WIP: API usage as main
This commit is contained in:
@@ -1,26 +1,51 @@
|
||||
from os import sep
|
||||
from os import path, sep
|
||||
from pathlib import Path
|
||||
|
||||
from pyrogram import filters
|
||||
from pyrogram.client import Client
|
||||
from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
|
||||
InlineKeyboardMarkup)
|
||||
from pyrogram.types import CallbackQuery
|
||||
|
||||
from modules.api_client import upload_pic
|
||||
from modules.app import app
|
||||
from modules.submissions import subBlock, subUnblock
|
||||
from modules.utils import configGet, jsonLoad, jsonSave, locale
|
||||
from modules.database import col_submitted
|
||||
from bson import ObjectId
|
||||
|
||||
|
||||
@app.on_callback_query(filters.regex("sub_yes_[\s\S]*_[\s\S]*"))
|
||||
@app.on_callback_query(filters.regex("sub_yes_[\s\S]*"))
|
||||
async def callback_query_yes(app: Client, clb: CallbackQuery):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
user_locale = clb.from_user.language_code
|
||||
try:
|
||||
submission = await app.get_messages(int(fullclb[2]), int(fullclb[3]))
|
||||
except:
|
||||
|
||||
# Check if submission is in DB and really exists
|
||||
|
||||
# Upload the file to the API server
|
||||
|
||||
# Modify submission in DB to state that it's accepted (or so called "done")
|
||||
|
||||
# Change keyboard to a completed variant
|
||||
|
||||
# Send replies to both user and admin about accepting the application
|
||||
|
||||
db_entry = col_submitted.find_one({"_id": ObjectId(fullclb[2])})
|
||||
|
||||
if db_entry is None:
|
||||
await clb.answer(text=locale("sub_msg_unavail", "message", locale=user_locale), show_alert=True)
|
||||
return
|
||||
else:
|
||||
if db_entry["tmp"]["uuid"] is not None:
|
||||
if not path.exists(path.join(configGet("data", "locations"), "submissions", db_entry["tmp"]["uuid"], db_entry["tmp"]["file"])):
|
||||
await clb.answer(text=locale("sub_msg_unavail", "message", locale=user_locale), show_alert=True)
|
||||
return
|
||||
else:
|
||||
try:
|
||||
submission = await app.get_messages(db_entry["user"], db_entry["telegram"]["msg_id"])
|
||||
except:
|
||||
await clb.answer(text=locale("sub_msg_unavail", "message", locale=user_locale), show_alert=True)
|
||||
return
|
||||
|
||||
try:
|
||||
if configGet("api_based", "mode") is True:
|
||||
media = await app.download_media(submission, file_name=configGet("tmp", "locations")+sep)
|
||||
@@ -51,7 +76,7 @@ async def callback_query_yes(app: Client, clb: CallbackQuery):
|
||||
# await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
|
||||
|
||||
@app.on_callback_query(filters.regex("sub_no_[\s\S]*_[\s\S]*"))
|
||||
@app.on_callback_query(filters.regex("sub_no_[\s\S]*"))
|
||||
async def callback_query_no(app: Client, clb: CallbackQuery):
|
||||
fullclb = clb.data.split("_")
|
||||
user_locale = clb.from_user.language_code
|
||||
|
Reference in New Issue
Block a user