adding channels and groups fixing
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -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:
|
|
||||||
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
|
context.user_data['channel_name'] = text
|
||||||
if update.message:
|
if update.message:
|
||||||
await update.message.reply_text('Теперь отправьте ссылку на канал:')
|
await update.message.reply_text('Теперь отправьте ссылку на канал (должна начинаться с @):')
|
||||||
return INPUT_LINK
|
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)
|
||||||
|
|
||||||
|
|||||||
@@ -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:
|
|
||||||
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
|
context.user_data['group_name'] = text
|
||||||
if update.message:
|
if update.message:
|
||||||
await update.message.reply_text('Теперь отправьте ссылку на группу:')
|
await update.message.reply_text('Теперь отправьте chat_id группы (например, -1001234567890):')
|
||||||
return INPUT_LINK
|
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)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user