This commit is contained in:
2024-12-09 17:42:23 +09:00
parent e33ca362fe
commit 7889117d6e
5 changed files with 99 additions and 5 deletions

View File

@@ -0,0 +1,16 @@
from telegram import Bot
async def notify_fraud(hotel, fraud_logs):
"""
Уведомляет о FRAUD-действиях через Telegram.
:param hotel: Отель, для которого обнаружены FRAUD-действия.
:param fraud_logs: Список записей о FRAUD.
"""
bot = Bot(token="TELEGRAM_BOT_TOKEN")
admin_chat_id = "ADMIN_CHAT_ID"
message = f"🚨 FRAUD обнаружен для отеля {hotel.name}:\n"
for log in fraud_logs:
message += f"- Гость: {log.guest_name}, Дата заезда: {log.check_in_date}\n"
await bot.send_message(chat_id=admin_chat_id, text=message)

View File

@@ -3,7 +3,7 @@ from asgiref.sync import sync_to_async
from hotels.models import Hotel, UserHotel
from users.models import User
from pms_integration.manager import PMSIntegrationManager
from bot.utils.froud_check import detect_fraud
async def manage_hotels(update: Update, context):
"""Отображение списка отелей, связанных с пользователем."""
query = update.callback_query
@@ -45,6 +45,7 @@ async def hotel_actions(update: Update, context):
keyboard = [
[InlineKeyboardButton("🗑️ Удалить отель", callback_data=f"delete_hotel_{hotel_id}")],
[InlineKeyboardButton("Проверить на FRAUD", callback_data=f"check_fraud_{hotel_id}")],
[InlineKeyboardButton("🔗 Проверить интеграцию с PMS", callback_data=f"check_pms_{hotel_id}")],
[InlineKeyboardButton("🛏️ Настроить номера", callback_data=f"setup_rooms_{hotel_id}")],
[InlineKeyboardButton("🏠 Главная", callback_data="main_menu")],
@@ -53,7 +54,12 @@ async def hotel_actions(update: Update, context):
reply_markup = InlineKeyboardMarkup(keyboard)
await query.edit_message_text(f"Управление отелем: {hotel.name}", reply_markup=reply_markup)
async def handle_fraud_check(update, context):
query = update.callback_query
hotel_id = int(query.data.split("_")[2])
await detect_fraud(hotel_id)
await query.edit_message_text("Проверка на FRAUD завершена. Администратор уведомлен.")
async def delete_hotel(update: Update, context):
"""Удаление отеля."""
query = update.callback_query