feat: add /info command, pt. 1

This commit is contained in:
Macintxsh 2025-05-18 01:44:46 +03:00
parent 93e3ca4f96
commit 89f5b35395
4 changed files with 79 additions and 6 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)