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:
parent
c70d7fe3be
commit
6141d674a9
4 changed files with 115 additions and 7 deletions
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue