add message user
This commit is contained in:
@@ -72,6 +72,7 @@ class BotInterface:
|
|||||||
self._topup_confirm: Dict[int, int] = {} # user_id -> rub amount pending confirm
|
self._topup_confirm: Dict[int, int] = {} # user_id -> rub amount pending confirm
|
||||||
self._user_task_state: Dict[int, dict] = {} # шаги создания задачи пользователем
|
self._user_task_state: Dict[int, dict] = {} # шаги создания задачи пользователем
|
||||||
self._admin_balance_state: Dict[int, int] = {} # admin_id -> target_user_id
|
self._admin_balance_state: Dict[int, int] = {} # admin_id -> target_user_id
|
||||||
|
self._admin_msg_state: Dict[int, int] = {} # admin_id -> target_user_id
|
||||||
self._menu_msg: Dict[int, int] = {} # user_id -> inline keyboard message_id
|
self._menu_msg: Dict[int, int] = {} # user_id -> inline keyboard message_id
|
||||||
self._menu_top_msg: Dict[int, int] = {} # user_id -> reply keyboard message_id
|
self._menu_top_msg: Dict[int, int] = {} # user_id -> reply keyboard message_id
|
||||||
self._chat_history: Dict[int, list] = {}
|
self._chat_history: Dict[int, list] = {}
|
||||||
@@ -1239,6 +1240,28 @@ class BotInterface:
|
|||||||
await interface._show_user_detail(callback, target_uid)
|
await interface._show_user_detail(callback, target_uid)
|
||||||
await callback.answer()
|
await callback.answer()
|
||||||
|
|
||||||
|
@dp.callback_query(F.data.startswith("umsg_"))
|
||||||
|
async def cb_admin_msg(callback: CallbackQuery):
|
||||||
|
if not await require_admin(callback):
|
||||||
|
return
|
||||||
|
target_uid = int(callback.data.replace("umsg_", "", 1))
|
||||||
|
interface._admin_msg_state[callback.from_user.id] = target_uid
|
||||||
|
builder = InlineKeyboardBuilder()
|
||||||
|
builder.row(InlineKeyboardButton(text="❌ Отмена", callback_data=f"udetail_{target_uid}"))
|
||||||
|
await callback.message.edit_text(
|
||||||
|
f"✉️ Сообщение пользователю {target_uid}\n\nВведите текст:",
|
||||||
|
reply_markup=builder.as_markup()
|
||||||
|
)
|
||||||
|
await callback.answer()
|
||||||
|
|
||||||
|
@dp.callback_query(F.data == "dismiss_msg")
|
||||||
|
async def cb_dismiss_msg(callback: CallbackQuery):
|
||||||
|
try:
|
||||||
|
await callback.message.delete()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
await callback.answer()
|
||||||
|
|
||||||
@dp.callback_query(F.data.startswith("ubal_"))
|
@dp.callback_query(F.data.startswith("ubal_"))
|
||||||
async def cb_user_balance(callback: CallbackQuery):
|
async def cb_user_balance(callback: CallbackQuery):
|
||||||
if not await require_admin(callback):
|
if not await require_admin(callback):
|
||||||
@@ -1274,6 +1297,25 @@ class BotInterface:
|
|||||||
user_id = message.from_user.id
|
user_id = message.from_user.id
|
||||||
text = message.text.strip() if message.text else ""
|
text = message.text.strip() if message.text else ""
|
||||||
|
|
||||||
|
# Админ пишет сообщение пользователю
|
||||||
|
if user_id in interface._admin_msg_state:
|
||||||
|
if not text:
|
||||||
|
return
|
||||||
|
target_uid = interface._admin_msg_state.pop(user_id)
|
||||||
|
await interface._safe_delete(message.bot, message.chat.id, message.message_id)
|
||||||
|
builder = InlineKeyboardBuilder()
|
||||||
|
builder.row(InlineKeyboardButton(text="✅ Понял", callback_data="dismiss_msg"))
|
||||||
|
try:
|
||||||
|
await message.bot.send_message(
|
||||||
|
target_uid,
|
||||||
|
f"📢 Сообщение от администратора:\n\n{text}",
|
||||||
|
reply_markup=builder.as_markup()
|
||||||
|
)
|
||||||
|
await message.answer(f"✅ Сообщение отправлено пользователю {target_uid}")
|
||||||
|
except Exception as e:
|
||||||
|
await message.answer(f"❌ Не удалось отправить: {e}")
|
||||||
|
return
|
||||||
|
|
||||||
# Ввод пароля (неавторизованный пользователь ждёт пароль)
|
# Ввод пароля (неавторизованный пользователь ждёт пароль)
|
||||||
if user_id in interface._waiting_password:
|
if user_id in interface._waiting_password:
|
||||||
if not text:
|
if not text:
|
||||||
@@ -3105,6 +3147,7 @@ class BotInterface:
|
|||||||
text=f"📋 Задачи ({len(user_tasks)})",
|
text=f"📋 Задачи ({len(user_tasks)})",
|
||||||
callback_data=f"utasks_{target_user_id}",
|
callback_data=f"utasks_{target_user_id}",
|
||||||
))
|
))
|
||||||
|
builder.row(InlineKeyboardButton(text="✉️ Написать сообщение", callback_data=f"umsg_{target_user_id}"))
|
||||||
builder.row(InlineKeyboardButton(text="🔙 К списку", callback_data="menu_users"))
|
builder.row(InlineKeyboardButton(text="🔙 К списку", callback_data="menu_users"))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user