bot rafactor and bugfix

This commit is contained in:
2025-08-19 04:45:16 +09:00
parent 43dda889f8
commit a8d860ed87
31 changed files with 4396 additions and 613 deletions

View 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