Initial commit
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
commit
6ec797a387
7 changed files with 198 additions and 0 deletions
46
commands.py
Normal file
46
commands.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
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} <post ID></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('Source', 'Url')
|
||||
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('General', 'Name')}</i> ({config.get('General', 'Domain')})",
|
||||
parse_mode=ParseMode.HTML,
|
||||
reply_markup=reply_markup
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue