Fixed questions source for commands

This commit is contained in:
Profitroll 2022-12-04 11:37:45 +01:00
parent 40cf3cff7c
commit d0316efbdf

18
main.py
View File

@ -173,16 +173,16 @@ async def cmd_application(app, msg):
user_id = list_of_users[0].user.id user_id = list_of_users[0].user.id
try: try:
user_data = jsonLoad(f"{configGet('data', 'locations')}{sep}users{sep}{user_id}.json") user_data = jsonLoad(f"{configGet('data', 'locations')}{sep}users{sep}{user_id}.json")
application = jsonLoad(f"{configGet('data', 'locations')}{sep}applications.json")[str(user_id)]
application_content = [] application_content = []
i = 1 i = 1
for question in configGet("application", file=str(msg.from_user.id)): for question in configGet("application", file=str(msg.from_user.id)):
if i == 2: if i == 2:
age = relativedelta(datetime.now(), datetime.strptime(configGet('application', file=str(user_id))['2'], '%d.%m.%Y')) age = relativedelta(datetime.now(), datetime.strptime(application['application']['2'], '%d.%m.%Y'))
application_content.append(f"{locale('question'+str(i), 'message', 'question_titles')} {configGet('application', file=str(user_id))['2']} ({age.years} р.)") application_content.append(f"{locale('question'+str(i), 'message', 'question_titles')} {application['application']['2']} ({age.years} р.)")
else: else:
application_content.append(f"{locale('question'+str(i), 'message', 'question_titles')} {configGet('application', file=str(user_id))[question]}") application_content.append(f"{locale('question'+str(i), 'message', 'question_titles')} {application['application'][question]}")
i += 1 i += 1
application = jsonLoad(f"{configGet('data', 'locations')}{sep}applications.json")[str(user_id)]
if user_data["sent"]: if user_data["sent"]:
if user_data["approved"]: 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
@ -632,16 +632,16 @@ async def get_contact(app, msg):
if msg.contact.user_id != None: if msg.contact.user_id != None:
try: try:
user_data = jsonLoad(f"{configGet('data', 'locations')}{sep}users{sep}{msg.contact.user_id}.json") user_data = jsonLoad(f"{configGet('data', 'locations')}{sep}users{sep}{msg.contact.user_id}.json")
application = jsonLoad(f"{configGet('data', 'locations')}{sep}applications.json")[str(msg.contact.user_id)]
application_content = [] application_content = []
i = 1 i = 1
for question in configGet("application", file=str(msg.from_user.id)): for question in application["application"]:
if i == 2: if i == 2:
age = relativedelta(datetime.now(), datetime.strptime(configGet('application', file=str(msg.contact.user_id))['2'], '%d.%m.%Y')) age = relativedelta(datetime.now(), datetime.strptime(application['application']['2'], '%d.%m.%Y'))
application_content.append(f"{locale('question'+str(i), 'message', 'question_titles')} {configGet('application', file=str(msg.contact.user_id))['2']} ({age.years} р.)") application_content.append(f"{locale('question'+str(i), 'message', 'question_titles')} {application['application']['2']} ({age.years} р.)")
else: else:
application_content.append(f"{locale('question'+str(i), 'message', 'question_titles')} {configGet('application', file=str(msg.contact.user_id))[question]}") application_content.append(f"{locale('question'+str(i), 'message', 'question_titles')} {application['application'][question]}")
i += 1 i += 1
application = jsonLoad(f"{configGet('data', 'locations')}{sep}applications.json")[str(msg.contact.user_id)]
if user_data["sent"]: if user_data["sent"]:
if user_data["approved"]: 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