adding channels and groups fixing
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2025-09-05 15:47:09 +09:00
parent e7a40b4718
commit f079ad2cf7
2 changed files with 18 additions and 22 deletions

View File

@@ -10,28 +10,26 @@ async def add_channel_start(update: Update, context: ContextTypes.DEFAULT_TYPE):
if context.user_data is None: if context.user_data is None:
context.user_data = {} context.user_data = {}
if update.message: if update.message:
await update.message.reply_text('Введите название канала (или "название ссылка" через пробел):') await update.message.reply_text('Введите имя канала:')
return INPUT_NAME return INPUT_NAME
async def input_channel_name(update: Update, context: ContextTypes.DEFAULT_TYPE): async def input_channel_name(update: Update, context: ContextTypes.DEFAULT_TYPE):
if context.user_data is None: if context.user_data is None:
context.user_data = {} context.user_data = {}
text = update.message.text.strip() if update.message and update.message.text else '' text = update.message.text.strip() if update.message and update.message.text else ''
if ' ' in text: context.user_data['channel_name'] = text
name, link = text.split(' ', 1) if update.message:
context.user_data['channel_name'] = name await update.message.reply_text('Теперь отправьте ссылку на канал (должна начинаться с @):')
context.user_data['channel_link'] = link return INPUT_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
async def input_channel_link(update: Update, context: ContextTypes.DEFAULT_TYPE): async def input_channel_link(update: Update, context: ContextTypes.DEFAULT_TYPE):
if context.user_data is None: if context.user_data is None:
context.user_data = {} context.user_data = {}
link = update.message.text.strip() if update.message and update.message.text else '' 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 context.user_data['channel_link'] = link
return await save_channel(update, context) return await save_channel(update, context)

View File

@@ -10,28 +10,26 @@ async def add_group_start(update: Update, context: ContextTypes.DEFAULT_TYPE):
if context.user_data is None: if context.user_data is None:
context.user_data = {} context.user_data = {}
if update.message: if update.message:
await update.message.reply_text('Введите название группы (или "название ссылка" через пробел):') await update.message.reply_text('Введите имя группы:')
return INPUT_NAME return INPUT_NAME
async def input_group_name(update: Update, context: ContextTypes.DEFAULT_TYPE): async def input_group_name(update: Update, context: ContextTypes.DEFAULT_TYPE):
if context.user_data is None: if context.user_data is None:
context.user_data = {} context.user_data = {}
text = update.message.text.strip() if update.message and update.message.text else '' text = update.message.text.strip() if update.message and update.message.text else ''
if ' ' in text: context.user_data['group_name'] = text
name, link = text.split(' ', 1) if update.message:
context.user_data['group_name'] = name await update.message.reply_text('Теперь отправьте chat_id группы (например, -1001234567890):')
context.user_data['group_link'] = link return INPUT_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
async def input_group_link(update: Update, context: ContextTypes.DEFAULT_TYPE): async def input_group_link(update: Update, context: ContextTypes.DEFAULT_TYPE):
if context.user_data is None: if context.user_data is None:
context.user_data = {} context.user_data = {}
link = update.message.text.strip() if update.message and update.message.text else '' 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 context.user_data['group_link'] = link
return await save_group(update, context) return await save_group(update, context)