import os from datetime import datetime LOG_FILE = "bot_actions.log" def log_action(user_id: int, command: str, status: str): timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") entry = f"[{timestamp}] UID: {user_id} | Cmd: {command} | Status: {status}\n" with open(LOG_FILE, "a", encoding="utf-8") as f: f.write(entry) def get_last_logs(limit: int = 10) -> str: if not os.path.exists(LOG_FILE): return "No logs found." with open(LOG_FILE, "r", encoding="utf-8") as f: lines = f.readlines() return "".join(lines[-limit:])