merge branch 'main' into security
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:
@@ -106,43 +106,6 @@ async def select_media(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
return SELECT_TEXT
|
||||
|
||||
async def select_text(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
<<<<<<< HEAD
|
||||
if update.message:
|
||||
if context.user_data is None:
|
||||
context.user_data = {}
|
||||
context.user_data['text'] = getattr(update.message, 'text', None) or getattr(update.message, 'caption', None)
|
||||
from sqlalchemy import select
|
||||
session = AsyncSessionLocal()
|
||||
user_id = update.effective_user.id if update.effective_user else None
|
||||
try:
|
||||
# Ограничиваем каналы и группы только теми, где пользователь — админ
|
||||
channels_result = await session.execute(
|
||||
select(Channel).join(Button, isouter=True).join(Group, isouter=True)
|
||||
.join(Admin, Channel.id == Admin.channel_id)
|
||||
.where(Admin.tg_id == user_id)
|
||||
)
|
||||
channels = channels_result.scalars().all()
|
||||
groups_result = await session.execute(
|
||||
select(Group).join(Button, isouter=True)
|
||||
.join(Admin, Group.id == Admin.channel_id)
|
||||
.where(Admin.tg_id == user_id)
|
||||
)
|
||||
groups = groups_result.scalars().all()
|
||||
keyboard = []
|
||||
for c in channels:
|
||||
keyboard.append([InlineKeyboardButton(f'Канал: {getattr(c, "name", str(c.name))}', callback_data=f'channel_{getattr(c, "id", str(c.id))}')])
|
||||
for g in groups:
|
||||
keyboard.append([InlineKeyboardButton(f'Группа: {getattr(g, "name", str(g.name))}', callback_data=f'group_{getattr(g, "id", str(g.id))}')])
|
||||
reply_markup = InlineKeyboardMarkup(keyboard)
|
||||
await update.message.reply_text('Выберите, куда отправить пост:', reply_markup=reply_markup)
|
||||
# Сохраняем id исходного сообщения для пересылки
|
||||
context.user_data['forward_message_id'] = update.message.message_id
|
||||
context.user_data['forward_chat_id'] = update.message.chat_id
|
||||
return SELECT_TARGET
|
||||
finally:
|
||||
await session.close()
|
||||
return ConversationHandler.END
|
||||
=======
|
||||
if not update.message:
|
||||
return ConversationHandler.END
|
||||
if context.user_data is None:
|
||||
@@ -180,7 +143,6 @@ async def select_text(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
|
||||
await update.message.reply_text('Выберите, куда отправить пост:', reply_markup=InlineKeyboardMarkup(keyboard))
|
||||
return SELECT_TARGET
|
||||
>>>>>>> main
|
||||
|
||||
async def select_target(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
query = update.callback_query
|
||||
@@ -320,22 +282,6 @@ async def select_target(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
# Страховка: если вдруг Telegram проглотил клаву — доклеим её
|
||||
if markup and getattr(sent_msg, "message_id", None):
|
||||
try:
|
||||
<<<<<<< HEAD
|
||||
# Пересылка исходного сообщения
|
||||
await context.bot.forward_message(
|
||||
chat_id=chat_id,
|
||||
from_chat_id=context.user_data.get('forward_chat_id'),
|
||||
message_id=context.user_data.get('forward_message_id')
|
||||
)
|
||||
from db import log_action
|
||||
user_id = update.effective_user.id if update.effective_user else None
|
||||
log_action(user_id, "forward_post", f"chat_id={chat_id}, from_chat_id={context.user_data.get('forward_chat_id')}, message_id={context.user_data.get('forward_message_id')}")
|
||||
await query.edit_message_text('Пост переслан!')
|
||||
except Exception as e:
|
||||
await query.edit_message_text(f'Ошибка пересылки поста: {e}')
|
||||
finally:
|
||||
await session.close()
|
||||
=======
|
||||
await context.bot.edit_message_reply_markup(
|
||||
chat_id=chat_id,
|
||||
message_id=sent_msg.message_id,
|
||||
@@ -348,7 +294,6 @@ async def select_target(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
except BadRequest as e:
|
||||
await query.edit_message_text(f'Ошибка отправки поста: {e}')
|
||||
|
||||
>>>>>>> main
|
||||
return ConversationHandler.END
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user