Compare commits

..

No commits in common. "main" and "v0.4.0" have entirely different histories.
main ... v0.4.0

5 changed files with 13 additions and 66 deletions

View file

@ -2,23 +2,23 @@ open_browser:
phrases: phrases:
- открой браузер - открой браузер
- запусти браузер - запусти браузер
- открой яндекс - открой гугл хром
- яндекс браузер - гугл хром
action: {type: url, href: "about:blank", browser: "yandex"} action: {type: exe, file: "Run browser.exe"}
open_youtube: open_youtube:
phrases: phrases:
- открой ютуб - открой ютуб
- ютуб - ютуб
- запусти ютуб - запусти ютуб
action: {type: url, href: "https://www.youtube.com", browser: "yandex"} action: {type: exe, file: "Run youtube.exe"}
open_google: open_google:
phrases: phrases:
- открой гугл - открой гугл
- гугл - гугл
- запусти гугл - запусти гугл
action: {type: url, href: "https://www.google.com", browser: "yandex"} action: {type: exe, file: "Run google.exe"}
music: music:
phrases: phrases:

View file

@ -6,7 +6,7 @@ load_dotenv("dev.env")
# Конфигурация # Конфигурация
VA_NAME = 'Jarvis' VA_NAME = 'Jarvis'
VA_VER = "0.4.1" VA_VER = "0.4.0"
VA_ALIAS = ('джарвис',) VA_ALIAS = ('джарвис',)
VA_TBR = ('скажи', 'покажи', 'ответь', 'произнеси', 'расскажи', 'сколько', 'слушай') VA_TBR = ('скажи', 'покажи', 'ответь', 'произнеси', 'расскажи', 'сколько', 'слушай')
@ -19,12 +19,8 @@ WAKE_WORDS = ('jarvis', 'джарвис')
# -1 это стандартное записывающее устройство # -1 это стандартное записывающее устройство
MICROPHONE_INDEX = -1 MICROPHONE_INDEX = -1
BROWSER_PATHS = { # Путь к браузеру Google Chrome
'yandex': 'C:/Program Files/Yandex/YandexBrowser/Application/browser.exe', CHROME_PATH = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
'chrome': 'C:/Program Files/Google/Chrome/Application/chrome.exe',
'firefox': 'C:/Program Files/Mozilla Firefox/firefox.exe',
'edge': 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe',
}
# Токен Groq # Токен Groq
GROQ_TOKEN = os.getenv('GROQ_TOKEN') GROQ_TOKEN = os.getenv('GROQ_TOKEN')

View file

@ -252,12 +252,6 @@ def run_action(action):
else: else:
subprocess.Popen(action['cmd'], shell=True) subprocess.Popen(action['cmd'], shell=True)
elif t == 'url': elif t == 'url':
browser = action.get('browser')
if browser:
exe = config.BROWSER_PATHS.get(browser)
if exe and os.path.isfile(exe):
subprocess.Popen([exe, action['href']])
return
webbrowser.open(action['href']) webbrowser.open(action['href'])
elif t == 'keys': elif t == 'keys':
import pyautogui import pyautogui

View file

@ -65,20 +65,13 @@ class ShellAction:
return out return out
KNOWN_BROWSERS = ("yandex", "chrome", "firefox", "edge")
@dataclass @dataclass
class UrlAction: class UrlAction:
href: str href: str
browser: Optional[str] = None
type: str = "url" type: str = "url"
def to_dict(self) -> dict: def to_dict(self) -> dict:
out: dict = {"type": "url", "href": self.href} return {"type": "url", "href": self.href}
if self.browser:
out["browser"] = self.browser
return out
@dataclass @dataclass
@ -164,10 +157,7 @@ def action_from_dict(data: Any) -> Action:
href = data.get("href") href = data.get("href")
if not href or not isinstance(href, str): if not href or not isinstance(href, str):
raise SchemaError("url action requires non-empty 'href' string") raise SchemaError("url action requires non-empty 'href' string")
browser = data.get("browser") return UrlAction(href=href)
if browser is not None and browser not in KNOWN_BROWSERS:
raise SchemaError(f"url.browser must be one of {KNOWN_BROWSERS} or omitted")
return UrlAction(href=href, browser=browser)
if t == "keys": if t == "keys":
sequence = data.get("sequence") sequence = data.get("sequence")
text = data.get("text") text = data.get("text")

View file

@ -191,25 +191,10 @@
<label>URL</label> <label>URL</label>
<input type="text" id="url-href" placeholder="https://example.com"> <input type="text" id="url-href" placeholder="https://example.com">
</div> </div>
<div class="field">
<label>Браузер</label>
<select id="url-browser">
<option value="">по умолчанию (системный)</option>
<option value="yandex">Yandex Browser</option>
<option value="chrome">Google Chrome</option>
<option value="firefox">Mozilla Firefox</option>
<option value="edge">Microsoft Edge</option>
</select>
</div>
`; `;
const inp = f.querySelector("#url-href"); const inp = f.querySelector("#url-href");
const sel = f.querySelector("#url-browser"); if (state.action) inp.value = state.action.href || "";
if (state.action) {
inp.value = state.action.href || "";
sel.value = state.action.browser || "";
}
inp.addEventListener("input", () => updateAction()); inp.addEventListener("input", () => updateAction());
sel.addEventListener("change", () => updateAction());
return; return;
} }
@ -496,23 +481,8 @@
inp.type = "text"; inp.type = "text";
inp.value = step.href || ""; inp.value = step.href || "";
inp.placeholder = "https://..."; inp.placeholder = "https://...";
const sel = document.createElement("select"); inp.addEventListener("input", () => onChange({ type: "url", href: inp.value }));
sel.innerHTML = `
<option value="">по умолчанию (системный)</option>
<option value="yandex">Yandex Browser</option>
<option value="chrome">Google Chrome</option>
<option value="firefox">Mozilla Firefox</option>
<option value="edge">Microsoft Edge</option>`;
sel.value = step.browser || "";
const apply = () => {
const next = { type: "url", href: inp.value };
if (sel.value) next.browser = sel.value;
onChange(next);
};
inp.addEventListener("input", apply);
sel.addEventListener("change", apply);
body.appendChild(wrapField("URL", inp)); body.appendChild(wrapField("URL", inp));
body.appendChild(wrapField("Браузер", sel));
} else if (t === "keys") { } else if (t === "keys") {
const inp = document.createElement("input"); const inp = document.createElement("input");
inp.type = "text"; inp.type = "text";
@ -599,10 +569,7 @@
if (delay && delay.value) a.delay_ms = parseInt(delay.value, 10); if (delay && delay.value) a.delay_ms = parseInt(delay.value, 10);
state.action = a; state.action = a;
} else if (t === "url") { } else if (t === "url") {
const a = { type: "url", href: (document.getElementById("url-href")||{}).value || "" }; state.action = { type: "url", href: (document.getElementById("url-href")||{}).value || "" };
const b = (document.getElementById("url-browser")||{}).value;
if (b) a.browser = b;
state.action = a;
} else if (t === "keys") { } else if (t === "keys") {
const mode = (document.getElementById("keys-mode")||{}).value; const mode = (document.getElementById("keys-mode")||{}).value;
if (mode === "text") { if (mode === "text") {