feat: add /info command, pt. 3
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
parent
270e1630d4
commit
1054299ed7
2 changed files with 18 additions and 3 deletions
12
commands.py
12
commands.py
|
@ -3,8 +3,9 @@ from telegram.constants import ParseMode
|
|||
from telegram.ext import ContextTypes
|
||||
|
||||
import html_parser
|
||||
from datetime import datetime
|
||||
from config import *
|
||||
from extensions import get_json, format_rating, format_status
|
||||
from extensions import get_json, format_rating, format_status, humanize_filesize
|
||||
|
||||
|
||||
async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
|
@ -78,13 +79,18 @@ async def info_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
|||
m.append(f"Uploader: {html_parser.hyperlink(uploader_data['name'],
|
||||
f"http://{app.host}/users/{post_data['uploader_id']}")} "
|
||||
f"{html_parser.hyperlink("»", f"http://{app.host}/posts?tags=user:{uploader_data['name']}")}")
|
||||
m.append(f"Date: {post_data['created_at']}")
|
||||
created_at = datetime.fromisoformat(post_data['created_at'])
|
||||
m.append(f"Date: {html_parser.hyperlink(
|
||||
f"{created_at.strftime("%Y-%m-%d %X (%z)")}",
|
||||
f"http://{app.host}/posts?tags=date:{created_at.strftime("%Y-%m-%d")}")}")
|
||||
if post_data['approver_id'] is not None:
|
||||
approver_data = get_json(f"users/{post_data['approver_id']}")
|
||||
m.append(f"Approver: {html_parser.hyperlink(approver_data['name'],
|
||||
f"http://{app.host}/users/{post_data['approver_id']}")} "
|
||||
f"{html_parser.hyperlink("»", f"http://{app.host}/posts?tags=approver:{approver_data['name']}")}")
|
||||
m.append(f"Size: {post_data['media_asset']['file_size']} .{post_data['media_asset']['file_ext']} "
|
||||
m.append(f"Size: {html_parser.hyperlink(
|
||||
f"{humanize_filesize(post_data['media_asset']['file_size'])} .{post_data['media_asset']['file_ext']}",
|
||||
post_data['file_url'])} "
|
||||
f"({post_data['media_asset']['image_width']}x{post_data['media_asset']['image_height']}) "
|
||||
f"{html_parser.hyperlink("»", f"http://{app.host}/media_assets/{post_data['media_asset']['id']}")}")
|
||||
m.append(f"Source: {post_data['source'] if post_data['source'] != "" else "🚫"}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue