From a54994fe8837916b225287b4957c110ca08ba887 Mon Sep 17 00:00:00 2001 From: profitroll Date: Tue, 22 Nov 2022 15:26:34 +0100 Subject: [PATCH] Inline mode number of suggestions decreased --- config_example.json | 1 + modules/inline.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config_example.json b/config_example.json index f0048c9..b0f7e4a 100644 --- a/config_example.json +++ b/config_example.json @@ -6,6 +6,7 @@ "birthdays_notify": true, "birthdays_time": "09:00", "api": "http://example.com", + "inline_preview_count": 7, "admin_group": 0, "destination_group": 0, "admins": [], diff --git a/modules/inline.py b/modules/inline.py index 5a0dca7..97e1309 100644 --- a/modules/inline.py +++ b/modules/inline.py @@ -28,7 +28,7 @@ async def inline_answer(client, inline_query): if (path.exists(f"{configGet('data', 'locations')}{sep}users{sep}{inline_query.from_user.id}.json") and jsonLoad(f"{configGet('data', 'locations')}{sep}users{sep}{inline_query.from_user.id}.json")["approved"]) or (await isAnAdmin(inline_query.from_user.id)): list_of_users = [] - async for m in app.get_chat_members(configGet("destination_group"), filter=ChatMembersFilter.SEARCH, query=inline_query.query): + async for m in app.get_chat_members(configGet("destination_group"), limit=configGet("inline_preview_count"), filter=ChatMembersFilter.SEARCH, query=inline_query.query): list_of_users.append(m) results = [] @@ -75,6 +75,16 @@ async def inline_answer(client, inline_query): description=locale("description", "inline", "user").format(match.user.first_name, match.user.username) ) ) + except FileNotFoundError: + 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(