(action)
| 67 | |
| 68 | |
| 69 | def run_action(action): |
| 70 | if not action: |
| 71 | return "" |
| 72 | action = action.strip() |
| 73 | lowered = action.lower() |
| 74 | if lowered == "open_cmd": |
| 75 | os.startfile("cmd.exe") |
| 76 | return "Opening Command Prompt." |
| 77 | if lowered == "blocked" or is_dangerous_request(action): |
| 78 | return "I cannot do that for safety." |
| 79 | if lowered.startswith("open_web:"): |
| 80 | return open_web_target(action.split(":", 1)[1].strip()) |
| 81 | if lowered.startswith("search_google:"): |
| 82 | query = action.split(":", 1)[1].strip().strip("<> ") |
| 83 | if not query or is_dangerous_request(query): |
| 84 | return "I cannot search that for safety." |
| 85 | webbrowser.open(f"https://www.google.com/search?q={quote_plus(query)}") |
| 86 | return f"Searching Google for {query}." |
| 87 | if lowered.startswith("open_app:"): |
| 88 | return open_application(action.split(":", 1)[1].strip()) |
| 89 | if lowered.startswith("close_app:"): |
| 90 | return close_visible_window(action.split(":", 1)[1].strip()) |
| 91 | if lowered == "chat": |
| 92 | return "" |
| 93 | return "" |
| 94 | |
| 95 | |
| 96 | def rule_based_action(text): |
no test coverage detected