you don’t need to write the code completely, just show where to change or add something…
- User
you don’t need to write the code completely, just show where to change or add something else, make the user, after selecting the case, no longer show the choice of the case at startup by checking the id if his id is from one case, if he wants to change the case, then enters the /edit command, which allows you to change the case and deletes its id from the file and transfers it to another from selection corps
import logging import pandas as pd import re import io import asyncio import sqlite3 from aiogram import Bot, Dispatcher, types from aiogram.contrib.middlewares.logging import LoggingMiddleware from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup from aiogram.utils import executor from aiogram.types import CallbackQuery@dp.message_handler(commands=['start']) async def send_welcome(message: types.Message): keyboard = InlineKeyboardMarkup() keyboard.add(InlineKeyboardButton(text="Первый корпус", callback_data="first_corpus")) keyboard.add(InlineKeyboardButton(text="Второй корпус", callback_data="second_corpus")) await message.answer("Выберите корпус:", reply_markup=keyboard)
async def save_user_id(selected_corp: str, user_id: int): if selected_corp == "first_corpus": id_file_path = r"C:\Users\Administrator\Desktop\id_klient1.txt" elif selected_corp == "second_corpus": id_file_path = r"C:\Users\Administrator\Desktop\id_klient2.txt" id_set = set() # Сохранение ID в файл with open(id_file_path, "r") as f: for line in f: if line.strip(): id_set.add(int(line.strip()))
id_set.add(user_id) with open(id_file_path, "w") as f: for user_id in id_set: f.write(str(user_id) + "\n")@dp.callback_query_handler(lambda c: c.data in ['first_corpus', 'second_corpus']) async def process_callback_corp_query(callback_query: CallbackQuery): selected_corp = callback_query.data # Дальнейшая обработка выбранного корпуса, например, сохранение в базу данных или использование в других функциях await callback_query.answer(text=f"Выбран {selected_corp} корпус") message = callback_query.message user_id = message.from_user.id await save_user_id(selected_corp, user_id)
if selected_corp == "first_corpus": group_list = ["АОЭ/21", "АОКС/21", "АОИС1/21", "АОРТ/21", "АОМЦ/21", "АОМЦ3/22", "АОЮ1/21", "АОЮ2/21", "АОЭ/20", "АОМТ/20", "АОКС/20", "АОРТ/20", "АОМЦ/20", "АОПИ/20", "АОИС2/21", "АОЮ1/20", "АОЮ2/20", "АОЭ/19", "АОКС/19", "АОМТ/19", "АОРТ/19", "АОПИ/19", "АОМЦ/19"] elif selected_corp == "second_corpus": group_list = ["АОЭ/34", "АОКС/35", "АОИС1/36"] markup = create_group_buttons(group_list) if callback_query.from_user.id == ADMIN_ID: markup.add(InlineKeyboardButton(text="🔧Изменить расписание", callback_data="change_path")) await message.reply("📃Выберите группу", reply_markup=markup)@dp.callback_query_handler(lambda c: c.data.startswith('group:')) async def process_callback_group(callback_query: types.CallbackQuery): global file_path group = callback_query.data[6:] schedule = get_schedule1(file_path, group) await bot.answer_callback_query(callback_query.id) await bot.send_message(chat_id=callback_query.from_user.id, text=f"Расписание для группы {group}:\n\n{schedule}")
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.