feat: add /info command (#1)

Reviewed-on: #1
Co-authored-by: mctaylors <cantsendmails@mctaylors.ru>
Co-committed-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
Macintxsh 2025-05-20 18:15:12 +03:00 committed by Forgejo
parent c70d7fe3be
commit 6141d674a9
Signed by untrusted user who does not match committer: Forgejo
GPG key ID: F2B3CB736682B201
4 changed files with 115 additions and 7 deletions

View file

@ -6,7 +6,7 @@ from telegram.constants import ParseMode
from telegram.ext import ContextTypes
from config import *
from extensions import humanize_tags_from_json, format_rating
from extensions import humanize_tags_from_json, format_rating, get_json
# noinspection PyUnusedLocal
@ -19,14 +19,11 @@ async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
if not query.isdigit():
return
response = requests.get(f"http://{app.host}/posts/{query}.json")
if response.status_code != 200:
data = get_json(f"posts/{query}")
if data is None:
await invalid_query(update, query)
return
data = response.json()
await answer_query(update, query, data)