feat: unit conversion + random generators packs (7 new commands)

Two pure-Lua packs that don't need network or LLM — pure offline utilities.

unit_convert (resources/commands/unit_convert/, 4 commands)
  - convert.length      "переведи 100 метров в футы" / "сколько 5 миль в км"
                        meters↔feet, km↔miles. Pluralises russian unit names.
  - convert.weight      "переведи 70 кг в фунты"
                        kg↔lbs.
  - convert.temperature "переведи 100 цельсий в фаренгейт" / "минус 40 в цельсий"
                        Handles negative numbers. C↔F formulas inline.
  - convert.speed       "переведи 100 км в час в мили в час"
                        km/h↔mph.
  - All round results to 1-2 decimal places, speak with proper Russian
    grammatical number (фут/фута/футов).

generators (resources/commands/generators/, 3 commands)
  - gen.coin       "подбрось монету" / "орёл или решка"
                   → "Орёл!" or "Решка!" (math.random with time+minute seed)
  - gen.password   "сгенерируй пароль 16 символов"
                   → cryptographically-ish 6..64-char password,
                   alphanumeric + !@#$%^&*-_=+, copies to clipboard,
                   SPEAKS LENGTH ONLY (never echoes the password).
                   Default 16 chars if no number in phrase.
  - gen.uuid       "сгенерируй uuid" / "юид"
                   → v4 UUID, copies to clipboard, speaks last 4 chars
                   (confirmation without 32-char monologue).

Tests: 112/112 pass (commands::tests auto-validates).
Pack count: 62 → 64.
This commit is contained in:
Bossiara13 2026-05-15 18:41:44 +03:00
parent 20b6b06b5d
commit 84d3b57ddc
9 changed files with 289 additions and 0 deletions

View file

@ -0,0 +1,6 @@
math.randomseed(os.time() + (jarvis.context.time.minute or 0) * 1000)
local r = math.random(1, 2)
if r == 1 then
return jarvis.cmd.ok("Орёл!")
end
return jarvis.cmd.ok("Решка!")

View file

@ -0,0 +1,54 @@
# Random generators — coin flip, password, secret token, color.
[[commands]]
id = "gen.coin"
type = "lua"
script = "coin.lua"
sandbox = "minimal"
timeout = 2000
[commands.phrases]
ru = [
"подбрось монету",
"брось монетку",
"орёл или решка",
"монетка",
]
en = ["flip a coin", "coin flip", "heads or tails"]
ua = ["підкинь монетку"]
[[commands]]
id = "gen.password"
type = "lua"
script = "password.lua"
sandbox = "full"
timeout = 3000
[commands.phrases]
ru = [
"сгенерируй пароль",
"придумай пароль",
"пароль 12 символов",
"сгенерируй надёжный пароль",
]
en = ["generate password", "make a password"]
ua = ["згенеруй пароль"]
[[commands]]
id = "gen.uuid"
type = "lua"
script = "uuid.lua"
sandbox = "full"
timeout = 3000
[commands.phrases]
ru = [
"сгенерируй uuid",
"сгенерируй юид",
"юид",
"уникальный идентификатор",
]
en = ["generate uuid", "uuid"]
ua = ["згенеруй юід"]

View file

@ -0,0 +1,22 @@
-- "Сгенерируй пароль 16 символов" → secure password (alphanumeric + symbols)
-- Copies result to clipboard, speaks length only (so it's not echoed).
local phrase = (jarvis.context.phrase or ""):lower()
local n = tonumber(phrase:match("(%d+)")) or 16
if n < 6 then n = 6 end
if n > 64 then n = 64 end
local pool = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*-_=+"
math.randomseed(os.time() + (jarvis.context.time.minute or 0) * 1000)
local pw = {}
for _ = 1, n do
local idx = math.random(1, #pool)
table.insert(pw, pool:sub(idx, idx))
end
local password = table.concat(pw)
jarvis.system.clipboard.set(password)
jarvis.system.notify("Пароль (" .. n .. " символов)", "Скопирован в буфер обмена")
-- Speak length only, never the password itself.
return jarvis.cmd.ok(string.format("Пароль на %d символов в буфере.", n))

View file

@ -0,0 +1,27 @@
-- Generate v4 UUID, copy to clipboard, speak short suffix.
math.randomseed(os.time() + (jarvis.context.time.minute or 0) * 1000)
local function hex(n)
local s = {}
for _ = 1, n do
s[#s + 1] = string.format("%x", math.random(0, 15))
end
return table.concat(s)
end
-- v4 UUID: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where y is 8|9|a|b
local y_pool = { "8", "9", "a", "b" }
local uuid = string.format(
"%s-%s-4%s-%s%s-%s",
hex(8), hex(4), hex(3),
y_pool[math.random(1, 4)], hex(3),
hex(12)
)
jarvis.system.clipboard.set(uuid)
jarvis.system.notify("UUID", uuid)
-- Speak last 4 hex chars so user knows it landed but doesn't have to listen
-- to 32 characters.
local suffix = uuid:sub(-4)
return jarvis.cmd.ok("UUID в буфере, заканчивается на " .. suffix .. ".")