danbooru-bot/commands.py
mctaylors 3242418ae6
fix: about used General because i forgor
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2025-03-02 14:28:12 +03:00

46 lines
1.7 KiB
Python

from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
from telegram.constants import ParseMode
from telegram.ext import ContextTypes
async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
await update.message.reply_text(
f"hello, i'm <b>{context.bot.first_name}</b>, an inline image grabber.\n\n"
f"to get help, use /help",
parse_mode=ParseMode.HTML
)
async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
await update.message.reply_text(
f"<b>how to use {context.bot.first_name}</b>\n\n"
f"1. open your message box and type:\n"
f"<code>@{context.bot.username} &lt;post ID&gt;</code>\n"
f"2. click on the box that has popped up\n"
f"3. ???\n"
f"4. done!",
parse_mode=ParseMode.HTML
)
async def about_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
from main import config
reply_markup = None
source_url = config.get('General', 'SourceUrl')
if source_url.startswith('http://') or source_url.startswith('https://'):
keyboard = [
[
InlineKeyboardButton(f"source code", url=source_url)
]
]
reply_markup = InlineKeyboardMarkup(keyboard)
await update.message.reply_text(
f"<b>about {context.bot.first_name}</b>\n"
f"{context.bot.first_name} is an inline image grabber written in python that grabs images from Danbooru "
f"(or other similar services).\n\n"
f"<b>currently configured instance:</b>\n"
f"<i>{config.get('Service', 'Name')}</i> ({config.get('Service', 'Domain')})",
parse_mode=ParseMode.HTML,
reply_markup=reply_markup
)