bot rafactor and bugfix
This commit is contained in:
43
app/bots/editor/handlers/base.py
Normal file
43
app/bots/editor/handlers/base.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""Базовые обработчики."""
|
||||
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
|
||||
Reference in New Issue
Block a user