Files
postbot/app/bots/editor/handlers/base.py

44 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Базовые обработчики."""
from telegram import Update
from telegram.ext import ContextTypes, ConversationHandler
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
"""Обработчик команды /start."""
if not update.message:
return ConversationHandler.END
await update.message.reply_text(
"Привет! Я бот для управления постами.\n"
"Для создания шаблона используйте /newtemplate\n"
"Для создания поста используйте /newpost\n"
"Для просмотра шаблонов /templates\n"
"Для помощи /help"
)
return ConversationHandler.END
async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
"""Обработчик команды /help."""
if not update.message:
return ConversationHandler.END
await update.message.reply_text(
"Доступные команды:\n"
"/start - начать работу с ботом\n"
"/newtemplate - создать новый шаблон\n"
"/templates - просмотреть существующие шаблоны\n"
"/newpost - создать новый пост\n"
"/cancel - отменить текущую операцию"
)
return ConversationHandler.END
async def cancel(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
"""Отмена текущей операции."""
if not update.message:
return ConversationHandler.END
await update.message.reply_text(
"Операция отменена.",
reply_markup=None
)
return ConversationHandler.END