Improved avatars
This commit is contained in:
@@ -38,6 +38,59 @@ async def inline_answer(client, inline_query):
|
||||
results = []
|
||||
|
||||
for match in list_of_users:
|
||||
|
||||
try:
|
||||
user_data = jsonLoad(f"{configGet('data', 'locations')}{sep}users{sep}{match.user.id}.json")
|
||||
application_content = []
|
||||
i = 1
|
||||
for question in configGet("application", file=str(match.user.id)):
|
||||
if i == 2:
|
||||
age = relativedelta(datetime.now(), datetime.strptime(configGet('application', file=str(match.user.id))['2'], '%d.%m.%Y'))
|
||||
application_content.append(f"{locale('question'+str(i), 'message', 'question_titles')} {configGet('application', file=str(match.user.id))['2']} ({age.years} р.)")
|
||||
else:
|
||||
application_content.append(f"{locale('question'+str(i), 'message', 'question_titles')} {configGet('application', file=str(match.user.id))[question]}")
|
||||
i += 1
|
||||
except FileNotFoundError:
|
||||
continue
|
||||
except TypeError:
|
||||
continue
|
||||
|
||||
if match.user.photo != None:
|
||||
try:
|
||||
await app.download_media(match.user.photo.big_file_id, file_name=f'{configGet("cache", "locations")}{sep}avatars{sep}{match.user.photo.big_file_id}')
|
||||
results.append(
|
||||
InlineQueryResultArticle(
|
||||
title=str(match.user.first_name),
|
||||
input_message_content=InputTextMessageContent(
|
||||
locale("message_content", "inline", "user").format(match.user.first_name, match.user.username, "\n".join(application_content))
|
||||
),
|
||||
description=locale("description", "inline", "user").format(match.user.first_name, match.user.username),
|
||||
thumb_url=f'{configGet("api")}/?avatar_id={match.user.photo.big_file_id}',
|
||||
# thumb_height=640,
|
||||
# thumb_width=640
|
||||
)
|
||||
)
|
||||
print(f'{configGet("api")}/?avatar_id={match.user.photo.big_file_id}', flush=True)
|
||||
except ValueError:
|
||||
results.append(
|
||||
InlineQueryResultArticle(
|
||||
title=str(match.user.first_name),
|
||||
input_message_content=InputTextMessageContent(
|
||||
locale("message_content", "inline", "user").format(match.user.first_name, match.user.username, "\n".join(application_content))
|
||||
),
|
||||
description=locale("description", "inline", "user").format(match.user.first_name, match.user.username)
|
||||
)
|
||||
)
|
||||
else:
|
||||
results.append(
|
||||
InlineQueryResultArticle(
|
||||
title=str(match.user.first_name),
|
||||
input_message_content=InputTextMessageContent(
|
||||
locale("message_content", "inline", "user").format(match.user.first_name, match.user.username, "\n".join(application_content))
|
||||
),
|
||||
description=locale("description", "inline", "user").format(match.user.first_name, match.user.username)
|
||||
)
|
||||
)
|
||||
# if match.user.photo != None:
|
||||
# results.append(
|
||||
# InlineQueryResultArticle(
|
||||
@@ -53,31 +106,6 @@ async def inline_answer(client, inline_query):
|
||||
# )
|
||||
# else:
|
||||
|
||||
try:
|
||||
user_data = jsonLoad(f"{configGet('data', 'locations')}{sep}users{sep}{match.user.id}.json")
|
||||
application_content = []
|
||||
i = 1
|
||||
for question in configGet("application", file=str(match.user.id)):
|
||||
if i == 2:
|
||||
age = relativedelta(datetime.now(), datetime.strptime(configGet('application', file=str(match.user.id))['2'], '%d.%m.%Y'))
|
||||
application_content.append(f"{locale('question'+str(i), 'message', 'question_titles')} {configGet('application', file=str(match.user.id))['2']} ({age.years} р.)")
|
||||
else:
|
||||
application_content.append(f"{locale('question'+str(i), 'message', 'question_titles')} {configGet('application', file=str(match.user.id))[question]}")
|
||||
i += 1
|
||||
results.append(
|
||||
InlineQueryResultArticle(
|
||||
title=str(match.user.first_name),
|
||||
input_message_content=InputTextMessageContent(
|
||||
locale("message_content", "inline", "user").format(match.user.first_name, match.user.username, "\n".join(application_content))
|
||||
),
|
||||
description=locale("description", "inline", "user").format(match.user.first_name, match.user.username)
|
||||
)
|
||||
)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
await inline_query.answer(
|
||||
results=results,
|
||||
cache_time=10
|
||||
|
Reference in New Issue
Block a user