diff --git a/handlers/add_channel.py b/handlers/add_channel.py index 904f19d..f39cb39 100644 --- a/handlers/add_channel.py +++ b/handlers/add_channel.py @@ -10,28 +10,26 @@ async def add_channel_start(update: Update, context: ContextTypes.DEFAULT_TYPE): if context.user_data is None: context.user_data = {} if update.message: - await update.message.reply_text('Введите название канала (или "название ссылка" через пробел):') + await update.message.reply_text('Введите имя канала:') return INPUT_NAME async def input_channel_name(update: Update, context: ContextTypes.DEFAULT_TYPE): if context.user_data is None: context.user_data = {} text = update.message.text.strip() if update.message and update.message.text else '' - if ' ' in text: - name, link = text.split(' ', 1) - context.user_data['channel_name'] = name - context.user_data['channel_link'] = link - return await save_channel(update, context) - else: - context.user_data['channel_name'] = text - if update.message: - await update.message.reply_text('Теперь отправьте ссылку на канал:') - return INPUT_LINK + context.user_data['channel_name'] = text + if update.message: + await update.message.reply_text('Теперь отправьте ссылку на канал (должна начинаться с @):') + return INPUT_LINK async def input_channel_link(update: Update, context: ContextTypes.DEFAULT_TYPE): if context.user_data is None: context.user_data = {} link = update.message.text.strip() if update.message and update.message.text else '' + if not link.startswith('@'): + if update.message: + await update.message.reply_text('Ошибка: ссылка на канал должна начинаться с @. Попробуйте снова.') + return INPUT_LINK context.user_data['channel_link'] = link return await save_channel(update, context) diff --git a/handlers/add_group.py b/handlers/add_group.py index 2ca7649..4f9459f 100644 --- a/handlers/add_group.py +++ b/handlers/add_group.py @@ -10,28 +10,26 @@ async def add_group_start(update: Update, context: ContextTypes.DEFAULT_TYPE): if context.user_data is None: context.user_data = {} if update.message: - await update.message.reply_text('Введите название группы (или "название ссылка" через пробел):') + await update.message.reply_text('Введите имя группы:') return INPUT_NAME async def input_group_name(update: Update, context: ContextTypes.DEFAULT_TYPE): if context.user_data is None: context.user_data = {} text = update.message.text.strip() if update.message and update.message.text else '' - if ' ' in text: - name, link = text.split(' ', 1) - context.user_data['group_name'] = name - context.user_data['group_link'] = link - return await save_group(update, context) - else: - context.user_data['group_name'] = text - if update.message: - await update.message.reply_text('Теперь отправьте ссылку на группу:') - return INPUT_LINK + context.user_data['group_name'] = text + if update.message: + await update.message.reply_text('Теперь отправьте chat_id группы (например, -1001234567890):') + return INPUT_LINK async def input_group_link(update: Update, context: ContextTypes.DEFAULT_TYPE): if context.user_data is None: context.user_data = {} link = update.message.text.strip() if update.message and update.message.text else '' + if not link.startswith('-100'): + if update.message: + await update.message.reply_text('Ошибка: chat_id группы должен начинаться с -100. Попробуйте снова.') + return INPUT_LINK context.user_data['group_link'] = link return await save_group(update, context)