Now using black for formatting
This commit is contained in:
@@ -11,15 +11,14 @@ from modules.logger import logWrite
|
||||
|
||||
from modules.utils import configGet
|
||||
|
||||
class PosterClient(Client):
|
||||
|
||||
def __init__(self, name: str, **kwargs): # type: ignore
|
||||
class PosterClient(Client):
|
||||
def __init__(self, name: str, **kwargs): # type: ignore
|
||||
super().__init__(name, **kwargs)
|
||||
self.owner = configGet("owner")
|
||||
self.admins = configGet("admins")+[configGet("owner")]
|
||||
self.admins = configGet("admins") + [configGet("owner")]
|
||||
|
||||
async def submit_photo(self, id: str) -> Union[Message, None]:
|
||||
|
||||
db_entry = col_submitted.find_one({"_id": ObjectId(id)})
|
||||
submission = None
|
||||
|
||||
@@ -27,35 +26,66 @@ class PosterClient(Client):
|
||||
raise SubmissionUnavailableError()
|
||||
else:
|
||||
if db_entry["temp"]["uuid"] is not None:
|
||||
if not path.exists(path.join(configGet("data", "locations"), "submissions", db_entry["temp"]["uuid"], db_entry["temp"]["file"])):
|
||||
if not path.exists(
|
||||
path.join(
|
||||
configGet("data", "locations"),
|
||||
"submissions",
|
||||
db_entry["temp"]["uuid"],
|
||||
db_entry["temp"]["file"],
|
||||
)
|
||||
):
|
||||
raise SubmissionUnavailableError()
|
||||
else:
|
||||
filepath = path.join(configGet("data", "locations"), "submissions", db_entry["temp"]["uuid"], db_entry["temp"]["file"])
|
||||
filepath = path.join(
|
||||
configGet("data", "locations"),
|
||||
"submissions",
|
||||
db_entry["temp"]["uuid"],
|
||||
db_entry["temp"]["file"],
|
||||
)
|
||||
try:
|
||||
submission = await self.get_messages(db_entry["user"], db_entry["telegram"]["msg_id"])
|
||||
submission = await self.get_messages(
|
||||
db_entry["user"], db_entry["telegram"]["msg_id"]
|
||||
)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
submission = await self.get_messages(db_entry["user"], db_entry["telegram"]["msg_id"])
|
||||
filepath = await self.download_media(submission, file_name=configGet("tmp", "locations")+sep)
|
||||
submission = await self.get_messages(
|
||||
db_entry["user"], db_entry["telegram"]["msg_id"]
|
||||
)
|
||||
filepath = await self.download_media(
|
||||
submission, file_name=configGet("tmp", "locations") + sep
|
||||
)
|
||||
except:
|
||||
raise SubmissionUnavailableError()
|
||||
|
||||
response = await upload_pic(str(filepath), allow_duplicates=configGet("allow_duplicates", "submission"))
|
||||
|
||||
response = await upload_pic(
|
||||
str(filepath), allow_duplicates=configGet("allow_duplicates", "submission")
|
||||
)
|
||||
|
||||
if len(response[1]) > 0:
|
||||
raise SubmissionDuplicatesError(str(filepath), response[1])
|
||||
|
||||
col_submitted.find_one_and_update({"_id": ObjectId(id)}, {"$set": {"done": True}})
|
||||
|
||||
col_submitted.find_one_and_update(
|
||||
{"_id": ObjectId(id)}, {"$set": {"done": True}}
|
||||
)
|
||||
|
||||
try:
|
||||
if db_entry["temp"]["uuid"] is not None:
|
||||
rmtree(path.join(configGet("data", "locations"), "submissions", db_entry["temp"]["uuid"]), ignore_errors=True)
|
||||
rmtree(
|
||||
path.join(
|
||||
configGet("data", "locations"),
|
||||
"submissions",
|
||||
db_entry["temp"]["uuid"],
|
||||
),
|
||||
ignore_errors=True,
|
||||
)
|
||||
else:
|
||||
remove(str(filepath))
|
||||
except (FileNotFoundError, NotADirectoryError):
|
||||
logWrite(f"Could not delete '{filepath}' on submission accepted", debug=True)
|
||||
logWrite(
|
||||
f"Could not delete '{filepath}' on submission accepted", debug=True
|
||||
)
|
||||
|
||||
return submission
|
||||
|
||||
@@ -63,4 +93,4 @@ class PosterClient(Client):
|
||||
pass
|
||||
|
||||
async def unban_user(self, id: int) -> None:
|
||||
pass
|
||||
pass
|
||||
|
Reference in New Issue
Block a user