Changed contact viewing logic

This commit is contained in:
Profitroll 2022-10-23 11:48:34 +02:00
parent fc0579f2f6
commit b1ca1fb0be

10
main.py
View File

@ -1,6 +1,6 @@
from datetime import datetime, timedelta
from time import time
from os import getpid, listdir, remove
from os import getpid, path
from modules.utils import *
from pyrogram.client import Client
@ -228,9 +228,9 @@ async def callback_query_refuse(app, clb):
# Contact getting ==============================================================================================================
@app.on_message(~ filters.scheduled & filters.contact)
@app.on_message(~ filters.scheduled & filters.contact & filters.private)
async def get_contact(app, msg):
if (msg.from_user.id in configGet("admins")) or (msg.from_user.id == configGet("owner")):
if (path.exists(f"{configGet('data', 'locations')}{sep}users{sep}{msg.from_user.id}.json") and jsonLoad(f"{configGet('data', 'locations')}{sep}users{sep}{msg.from_user.id}.json")["approved"]) or (msg.from_user.id in configGet("admins")) or (msg.from_user.id == configGet("owner")):
if msg.contact.user_id != None:
try:
user_data = jsonLoad(f"{configGet('data', 'locations')}{sep}users{sep}{msg.contact.user_id}.json")
@ -242,9 +242,9 @@ async def get_contact(app, msg):
if user_data["sent"]:
application = jsonLoad(f"{configGet('data', 'locations')}{sep}applications.json")[str(msg.contact.user_id)]
if user_data["approved"]:
application_status = locale("application_status_accepted", "message").format(await app.get_users(application["approved_by"]).first_name, datetime.fromtimestamp(application["approval_date"]).strftime("%d.%m.%Y, %H:%M")) # type: ignore
application_status = locale("application_status_accepted", "message").format((await app.get_users(application["approved_by"])).first_name, datetime.fromtimestamp(application["approval_date"]).strftime("%d.%m.%Y, %H:%M")) # type: ignore
elif application["refused"]:
application_status = locale("application_status_refused", "message").format(await app.get_users(application["refused_by"]).first_name, datetime.fromtimestamp(application["refusal_date"]).strftime("%d.%m.%Y, %H:%M")) # type: ignore
application_status = locale("application_status_refused", "message").format((await app.get_users(application["refused_by"])).first_name, datetime.fromtimestamp(application["refusal_date"]).strftime("%d.%m.%Y, %H:%M")) # type: ignore
else:
application_status = locale("application_status_on_hold", "message")
else: