сделай чтобы файл для первого админа сохранялся в filedir =…
- User
сделай чтобы файл для первого админа сохранялся в file_dir = r'C:\Users\Administrator\Desktop\1' file_path = None, для второго админа file_dir2 = r"C:\Users\Administrator\Desktop\2" file_path2 = None, еще чтобы админу1 отправлял уведомления для этих групп "first_corpus", а для админ2 отправлял уведомления для этих групп "second_corpus", вот код : @dp.message_handler(user_id=ADMIN_ID, content_types=['document']) async def handle_file(message: types.Message): global file_path
code# Save file to disk file_name = message.document.file_name file_path = f"{file_dir}/{file_name}" await message.document.download(file_path) # Inform user about successful save await message.answer(f"Файл '{file_name}' успешно сохранен.") # Create inline button for sending notifications to all users send_notification_button = InlineKeyboardButton( text="Отправить уведомление", callback_data="send_notification" ) inline_keyboard = InlineKeyboardMarkup().add(send_notification_button) # Send message with inline button to admin await bot.send_message( chat_id=ADMIN_ID, text="Файл успешно загружен. Хотите отправить уведомление о новом расписании всем пользователям?", reply_markup=inline_keyboard )@dp.callback_query_handler(lambda callback_query: True) async def process_callback_send_notification(callback_query: types.CallbackQuery): # Load list of user IDs to send notification to with open(id_file_path, "r") as f: user_ids = [line.strip() for line in f]
code# Send notification to each user, except the admin for user_id in user_ids: if user_id != str(ADMIN_ID): try: await bot.send_message( chat_id=user_id, text="Появилось новое расписание!", ) except: pass # Send notification to admin that notifications have been sent await bot.send_message( chat_id=ADMIN_ID, text="Уведомление отправлено всем пользователям." ) # Answer callback query await bot.answer_callback_query(callback_query.id, text="Уведомление отправлено всем пользователям.") - Assistant