In this function I have the current working directory hardcoded. How can we make it…
- User
In this function I have the current working directory hardcoded. How can we make it dynamic so it just uses the cwd for the folder instead?
def toggle_script_a1(update: Update, context: CallbackContext): """Toggle the Text Send script ON/OFF.""" query = update.callback_query query.answer()
# Step 1: Retrieve Current Set current_set = get_current_token_set(context) if current_set is None: context.bot.send_message(chat_id=query.message.chat_id, text="Error: Unable to retrieve current set.") return dashboard(query, context) # Step 2: Dynamically Retrieve Script Name and Token Name script_name = get_send_script_name(current_set) token_name = get_current_token(current_set) # Corrected if token_name is None: context.bot.send_message(chat_id=query.message.chat_id, text="Error: Unable to retrieve token name.") return dashboard(query, context) # Step 3: Determine the Folder folder = "/home/sypherwork/Desktop/work_after_jail/JUNE_UPGRADE" # Step 4: Check if the script is running if is_script_running(script_name): # Step 5: Kill the script if it's running message = kill_script(script_name, token_name) # Removed 'folder' else: # Optionally, pass arguments if needed arguments = [str(current_set)] message = start_script(script_name, token_name, folder, arguments=arguments) # Step 6: Send Response Back to User context.bot.send_message(chat_id=query.message.chat_id, text=message) return dashboard(query, context) - Assistant