From 7b98cb2d7c24147d093511d527a5558f86efd867 Mon Sep 17 00:00:00 2001 From: Moepchi Date: Fri, 23 Oct 2026 19:01:53 +0000 Subject: [PATCH] Whisper settings: incoming whisper rights, sound, history auto-open/cleanup Options -> Whispern like TS3: allow/block by default with per-contact overrides (new Whisper field in contacts) or block all. The connector drops blocked whispers before decoding (whisperpolicy stdin command) and reports accepted ones as whisperReceived, which logs them in the whisper history, plays the new whisper sound and can open the history. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU --- connector/src/main.rs | 29 +++++- gateway/src/index.ts | 4 + gateway/src/ts3/connection.ts | 8 ++ web/src/App.tsx | 163 +++++++++++++++++++++++++++++++++- web/src/locales/cs-CZ.json | 17 ++++ web/src/locales/de.json | 17 ++++ web/src/locales/en.json | 17 ++++ web/src/locales/fa.json | 17 ++++ web/src/locales/zh-CN.json | 17 ++++ web/src/soundpack.ts | 1 + web/src/sounds.ts | 11 ++- 11 files changed, 295 insertions(+), 6 deletions(-) diff --git a/connector/src/main.rs b/connector/src/main.rs index 1541c98..3a1fa95 100644 --- a/connector/src/main.rs +++ b/connector/src/main.rs @@ -301,6 +301,12 @@ enum Event { /// Ids of clients currently detected as talking. #[serde(rename = "talkers")] Talkers { clients: Vec }, + /// Someone started whispering to us and the whisper settings let it through. + #[serde(rename = "whisperReceived")] + WhisperReceived { + #[serde(rename = "clientId")] + client_id: u16, + }, #[serde(rename = "disconnected")] Disconnected { reason: String }, /// Lost the server (timeout, server restart); tsclientlib is reconnecting @@ -1069,6 +1075,10 @@ async fn run(args: Args) -> Result<()> { // stdin command, cleared via "unwhisper". let mut whisper_channels: Vec = Vec::new(); let mut whisper_clients: Vec = Vec::new(); + // Incoming whispers, set via "whisperpolicy allow|block;": the + // ids are exceptions to the mode. Blocked whispers are dropped undecoded. + let mut whisper_block_default = false; + let mut whisper_exceptions: HashSet = HashSet::new(); // Set by "clientconninfo"/"serverconninfo" while waiting for the server's // reply to land in book state (it arrives async as a later BookEvents // batch, not as a direct command result) - checked and emitted below. @@ -1431,6 +1441,10 @@ async fn run(args: Args) -> Result<()> { let clients_part = parts.next().unwrap_or(""); whisper_channels = channels_part.split(',').filter_map(|s| s.trim().parse().ok()).collect(); whisper_clients = clients_part.split(',').filter_map(|s| s.trim().parse().ok()).collect(); + } else if let Some(rest) = l.strip_prefix("whisperpolicy ") { + let (mode, ids) = rest.split_once(';').unwrap_or((rest, "")); + whisper_block_default = mode.trim() == "block"; + whisper_exceptions = ids.split(',').filter_map(|s| s.trim().parse().ok()).collect(); } else if l == "unwhisper" { whisper_channels.clear(); whisper_clients.clear(); @@ -2656,11 +2670,15 @@ async fn run(args: Args) -> Result<()> { emit(&snapshot(con.get_state()?)); } Some(Ok(StreamItem::Audio(packet))) => { - let from = match packet.data().data() { - AudioData::S2C { from, .. } => Some(ClientId(*from)), - AudioData::S2CWhisper { from, .. } => Some(ClientId(*from)), - _ => None, + let (from, whisper) = match packet.data().data() { + AudioData::S2C { from, .. } => (Some(ClientId(*from)), false), + AudioData::S2CWhisper { from, .. } => (Some(ClientId(*from)), true), + _ => (None, false), }; + // A whisper gets through when its sender isn't an exception to a + // blocking mode, or is one to an allowing mode. + let from = + from.filter(|f| !whisper || whisper_block_default == whisper_exceptions.contains(&f.0)); if let Some(from) = from { if let Ok(Some(new_talker)) = audio_handler.handle_packet(from, packet) { if let (Some(&volume), Some(queue)) = ( @@ -2671,6 +2689,9 @@ async fn run(args: Args) -> Result<()> { } if talking.insert(new_talker.0) { emit(&Event::Talkers { clients: talking.iter().copied().collect() }); + if whisper { + emit(&Event::WhisperReceived { client_id: new_talker.0 }); + } } } } diff --git a/gateway/src/index.ts b/gateway/src/index.ts index 8ca018e..7e540be 100644 --- a/gateway/src/index.ts +++ b/gateway/src/index.ts @@ -882,6 +882,10 @@ wss.on("connection", (socket: WebSocket, req: IncomingMessage) => { await connection?.setNickname(msg.nickname); break; } + case "setWhisperPolicy": { + connection?.setWhisperPolicy(msg.block === true, Array.isArray(msg.exceptions) ? msg.exceptions : []); + break; + } case "setWhisperTargets": { await connection?.setWhisperTargets(msg.channelIds ?? [], msg.clientIds ?? []); break; diff --git a/gateway/src/ts3/connection.ts b/gateway/src/ts3/connection.ts index dac75bc..3e6264e 100644 --- a/gateway/src/ts3/connection.ts +++ b/gateway/src/ts3/connection.ts @@ -153,6 +153,7 @@ export type Ts3ConnectionEvent = | { type: "poke"; from: string; message: string } | { type: "audioOut"; pcm: string } | { type: "talkers"; clients: number[] } + | { type: "whisperReceived"; clientId: number } | { type: "disconnected"; reason: string } | { type: "reconnecting"; reason: string } | { type: "reconnected" } @@ -363,6 +364,7 @@ export class Ts3Connection { | { type: "poke"; from: string; message: string } | { type: "audioOut"; pcm: string } | { type: "talkers"; clients: number[] } + | { type: "whisperReceived"; clientId: number } | { type: "disconnected"; reason: string } | { type: "reconnecting"; reason: string } | { type: "reconnected" } @@ -959,6 +961,12 @@ export class Ts3Connection { if (sanitized) this.writeLine(`nickname ${sanitized}`); } + /** Incoming whispers: allowed or blocked by default; `exceptions` (client ids) get the opposite. */ + setWhisperPolicy(block: boolean, exceptions: unknown[]): void { + const ids = exceptions.map(Number).filter(Number.isInteger); + this.writeLine(`whisperpolicy ${block ? "block" : "allow"};${ids.join(",")}`); + } + /** Empty channelIds/clientIds clears whisper mode, returning outgoing * voice to the normal current-channel broadcast. */ async setWhisperTargets(channelIds: number[], clientIds: number[]): Promise { diff --git a/web/src/App.tsx b/web/src/App.tsx index 24ad207..eb6b074 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -618,6 +618,28 @@ const SERVER_BANNER_KEY = "webspeak3:server-banner"; const IDE_PIXEL_FONT_KEY = "webspeak3:ide-pixel-font"; // Off by default: an inline chat image loads from whatever host the sender picked. const CHAT_IMAGES_KEY = "webspeak3:chat-images"; +const WHISPER_SETTINGS_KEY = "webspeak3:whisper-settings"; + +/** Options -> Whispern (TS3's "Whispereinstellungen"). */ +interface WhisperSettings { + /** allow/block: what applies to contacts without their own whisper setting. */ + mode: "allow" | "block" | "blockAll"; + sound: boolean; + openHistory: boolean; + /** Incoming entries leave the whisper history after this many minutes; 0 = never. */ + clearAfterMin: number; +} + +const DEFAULT_WHISPER_SETTINGS: WhisperSettings = { mode: "allow", sound: true, openHistory: true, clearAfterMin: 5 }; + +function loadWhisperSettings(): WhisperSettings { + try { + return { ...DEFAULT_WHISPER_SETTINGS, ...JSON.parse(localStorage.getItem(WHISPER_SETTINGS_KEY) ?? "{}") }; + } catch { + return DEFAULT_WHISPER_SETTINGS; + } +} + const TREE_OPTIONS_KEY = "webspeak3:tree-options"; /** Design tab -> "Channel Baum" and "GIF Animation" (TS3's options). */ @@ -664,6 +686,8 @@ const DisplayPrefsContext = createContext<{ iconPackId: string; setIconPackId: (id: string) => void; saveIconPacks: (packs: IconPack[]) => void; + whisper: WhisperSettings; + setWhisper: (next: WhisperSettings) => void; }>({ tree: DEFAULT_TREE_OPTIONS, setTree: () => {}, @@ -671,6 +695,8 @@ const DisplayPrefsContext = createContext<{ iconPackId: "", setIconPackId: () => {}, saveIconPacks: () => {}, + whisper: DEFAULT_WHISPER_SETTINGS, + setWhisper: () => {}, }); const DISCONNECT_MESSAGE_KEY = "webspeak3:disconnect-message"; const COLLECTED_URLS_KEY = "webspeak3:collected-urls"; @@ -708,6 +734,8 @@ interface WhisperLogEntry { id: number; timestamp: number; description: string; + /** Someone whispered to us (as opposed to our own whisper target changes). */ + incoming?: boolean; } interface BanListEntry { @@ -748,6 +776,8 @@ interface Contact { category: ContactCategory; phoneticName: string; ignored: boolean; + /** Incoming whispers from this contact; unset follows Options -> Whispern. */ + whisper?: "allow" | "block"; } const CONTACTS_KEY = "webspeak3:contacts"; @@ -5507,6 +5537,18 @@ function ContactsDialog({ onChange={(e) => updateSelected({ phoneticName: e.target.value })} /> +
+
+ + + ); +} + function DesignPanel({ designSelection, onSelectionChange, @@ -7034,6 +7129,7 @@ function OptionsDialog({ onShowServerBannerChange, chatImages, onChatImagesChange, + onOpenWhisperLists, }: { section: string; onSectionChange: (id: string) => void; @@ -7050,6 +7146,7 @@ function OptionsDialog({ onShowServerBannerChange: (on: boolean) => void; chatImages: boolean; onChatImagesChange: (on: boolean) => void; + onOpenWhisperLists: () => void; }) { const t = useT(); const active = OPTIONS_SECTIONS.find((s) => s.id === section) ?? OPTIONS_SECTIONS[0]; @@ -7104,6 +7201,8 @@ function OptionsDialog({ /> ) : active.id === "nachrichten" ? ( + ) : active.id === "whispern" ? ( + ) : ( <>

{t(`options.section.${active.id}`)}

@@ -7584,6 +7683,9 @@ function AppInner() { const [treeOptions, setTreeOptions] = useState(loadTreeOptions); const [iconPacks, setIconPacks] = useState(loadIconPacks); const [iconPackId, setIconPackId] = useState(loadSelectedIconPack); + const [whisperSettings, setWhisperSettings] = useState(loadWhisperSettings); + const whisperSettingsRef = useRef(whisperSettings); + whisperSettingsRef.current = whisperSettings; const displayPrefs = useMemo( () => ({ tree: treeOptions, @@ -7601,8 +7703,13 @@ function AppInner() { saveIconPacks(packs); // throws when storage is full - before the state changes setIconPacks(packs); }, + whisper: whisperSettings, + setWhisper: (next: WhisperSettings) => { + setWhisperSettings(next); + localStorage.setItem(WHISPER_SETTINGS_KEY, JSON.stringify(next)); + }, }), - [treeOptions, iconPacks, iconPackId] + [treeOptions, iconPacks, iconPackId, whisperSettings] ); const iconPackStyle = iconPackCss(iconPacks.find((p) => p.id === iconPackId)); const [micOn, setMicOn] = useState(false); @@ -8589,6 +8696,21 @@ function AppInner() { setTalkers(next); break; } + case "whisperReceived": { + const name = previousClientsRef.current?.find((c) => c.id === data.clientId)?.name ?? `#${data.clientId}`; + setWhisperLog((prevLog) => [ + ...prevLog, + { + id: ++whisperLogIdRef.current, + timestamp: Date.now(), + description: t("whisperHistory.received", { name }), + incoming: true, + }, + ]); + if (whisperSettingsRef.current.sound && !outputMutedRef.current) void playSound("whisper"); + if (whisperSettingsRef.current.openHistory) setWhisperHistoryOpen(true); + break; + } case "reconnecting": // The gateway lost the TS server and is reconnecting by itself. appendLog({ text: t("log.serverReconnecting"), kind: "error" }); @@ -9520,6 +9642,44 @@ function AppInner() { // eslint-disable-next-line react-hooks/exhaustive-deps }, [whisperChannelIds, whisperClientIds, connected]); + // Tell the connector whose whispers to let through: the mode's default plus + // the online clients whose contact entry says otherwise. Resent whenever + // that changes or the socket is new (the connector forgets it on reconnect). + const sentWhisperPolicyRef = useRef<{ socket: WebSocket | DemoSocket | null; payload: string }>({ socket: null, payload: "" }); + useEffect(() => { + const socket = socketRef.current; + if (!connected || !socket) return; + const block = whisperSettings.mode !== "allow"; + const exceptionMode = block ? "allow" : "block"; + const exceptions = + whisperSettings.mode === "blockAll" + ? [] + : clients + .filter((c) => contacts.find((k) => k.uid === c.uid)?.whisper === exceptionMode) + .map((c) => c.id) + .sort((a, b) => a - b); + const payload = JSON.stringify({ type: "setWhisperPolicy", block, exceptions }); + const sent = sentWhisperPolicyRef.current; + if (sent.socket === socket && sent.payload === payload) return; + socket.send(payload); + sentWhisperPolicyRef.current = { socket, payload }; + }, [connected, clients, contacts, whisperSettings.mode]); + + // "Clients in Whisper Verlauf löschen nach": drop old incoming entries. + useEffect(() => { + const minutes = whisperSettings.clearAfterMin; + if (!minutes) return; + const prune = () => + setWhisperLog((prev) => { + const cutoff = Date.now() - minutes * 60_000; + const next = prev.filter((e) => !e.incoming || e.timestamp >= cutoff); + return next.length === prev.length ? prev : next; + }); + prune(); + const timer = setInterval(prune, 15_000); + return () => clearInterval(timer); + }, [whisperSettings.clearAfterMin]); + useEffect(() => { if (!whisperMenuOpen) return; const onPointerDown = (e: MouseEvent) => { @@ -11973,6 +12133,7 @@ function AppInner() { {optionsDialogOpen && ( setWhisperListsOpen(true)} section={optionsSection} onSectionChange={setOptionsSection} onClose={() => setOptionsDialogOpen(false)} diff --git a/web/src/locales/cs-CZ.json b/web/src/locales/cs-CZ.json index 3e4e710..3fdb4ce 100644 --- a/web/src/locales/cs-CZ.json +++ b/web/src/locales/cs-CZ.json @@ -165,6 +165,18 @@ "whisperHistory.title": "Historie šeptání – {server}", "whisperHistory.empty": "Zatím žádná historie šeptání.", "whisperHistory.started": "Šeptání pro: {targets}", + "whisperSettings.subtitle": "Nastavení šeptání", + "whisperSettings.rights": "Oprávnění pro příchozí šeptání", + "whisperSettings.mode.allow": "Použít nastavení kontaktů, jinak povolit", + "whisperSettings.mode.block": "Použít nastavení kontaktů, jinak zakázat", + "whisperSettings.mode.blockAll": "Zakázat vše", + "whisperSettings.incoming": "Nastavení příchozího šeptání", + "whisperSettings.sound": "Přehrát zvuk, když vám někdo šeptá", + "whisperSettings.openHistory": "Vždy otevřít historii šeptání, když vám někdo šeptá", + "whisperSettings.clearAfter": "Odebrat klienty z historie šeptání po", + "whisperSettings.never": "Nikdy", + "whisperSettings.minutes": "{count} min", + "whisperHistory.received": "{name} vám šeptal(a)", "whisperHistory.stopped": "Šeptání zastaveno", "whisperHistory.clear": "Vymazat", "whisperHistory.options": "Možnosti", @@ -241,6 +253,10 @@ "contacts.category.blocked": "Blokovaný", "contacts.category.friend": "Přítel", "contacts.phoneticName": "Fonetické jméno:", + "contacts.whisperSetting": "Šeptání:", + "contacts.whisperSetting.default": "Výchozí", + "contacts.whisperSetting.allow": "Povolit", + "contacts.whisperSetting.block": "Zakázat", "contacts.show": "Zobrazit", "contacts.ignore": "Ignorovat", "contacts.unignore": "Přestat ignorovat", @@ -696,6 +712,7 @@ "sounds.event.mute": "Přepnutí ztlumení", "sounds.event.micClickOn": "Kliknutí mikrofonu zap.", "sounds.event.micClickOff": "Kliknutí mikrofonu vyp.", + "sounds.event.whisper": "Přijato šeptání", "sounds.default": "Výchozí", "sounds.custom": "Vlastní soubor: {name}", "sounds.test": "▶ Test", diff --git a/web/src/locales/de.json b/web/src/locales/de.json index 140eaea..ae79942 100644 --- a/web/src/locales/de.json +++ b/web/src/locales/de.json @@ -165,6 +165,18 @@ "whisperHistory.title": "Whisper Verlauf - {server}", "whisperHistory.empty": "Kein Whisper-Verlauf vorhanden.", "whisperHistory.started": "Whispern an: {targets}", + "whisperSettings.subtitle": "Whispereinstellungen", + "whisperSettings.rights": "Rechte für eingehende Whisper", + "whisperSettings.mode.allow": "Individuelle Einstellungen in Kontakten benutzen, ansonsten erlauben", + "whisperSettings.mode.block": "Individuelle Einstellungen in Kontakten benutzen, ansonsten verbieten", + "whisperSettings.mode.blockAll": "Alle verbieten", + "whisperSettings.incoming": "Einstellungen für eingehende Whisper", + "whisperSettings.sound": "Sound abspielen, wenn Sie angewhispert werden", + "whisperSettings.openHistory": "Whisper Verlauf immer öffnen, wenn Sie angewhispert werden", + "whisperSettings.clearAfter": "Clients in Whisper Verlauf löschen nach", + "whisperSettings.never": "Nie", + "whisperSettings.minutes": "{count} Min.", + "whisperHistory.received": "{name} hat dir zugewhispert", "whisperHistory.stopped": "Whispern beendet", "whisperHistory.clear": "Löschen", "whisperHistory.options": "Optionen", @@ -241,6 +253,10 @@ "contacts.category.blocked": "Blockiert", "contacts.category.friend": "Freund", "contacts.phoneticName": "Phonetischer Name:", + "contacts.whisperSetting": "Whisper:", + "contacts.whisperSetting.default": "Standard", + "contacts.whisperSetting.allow": "Erlauben", + "contacts.whisperSetting.block": "Verbieten", "contacts.show": "Anzeige", "contacts.ignore": "Ignorieren", "contacts.unignore": "Nicht mehr ignorieren", @@ -696,6 +712,7 @@ "sounds.event.mute": "Stummschaltung umgeschaltet", "sounds.event.micClickOn": "Mikro Klick an", "sounds.event.micClickOff": "Mikro Klick aus", + "sounds.event.whisper": "Whisper empfangen", "sounds.default": "Standard", "sounds.custom": "Eigene Datei: {name}", "sounds.test": "▶ Testen", diff --git a/web/src/locales/en.json b/web/src/locales/en.json index c0930a3..7956d80 100644 --- a/web/src/locales/en.json +++ b/web/src/locales/en.json @@ -165,6 +165,18 @@ "whisperHistory.title": "Whisper History - {server}", "whisperHistory.empty": "No whisper history yet.", "whisperHistory.started": "Whispering to: {targets}", + "whisperSettings.subtitle": "Whisper settings", + "whisperSettings.rights": "Permissions for incoming whispers", + "whisperSettings.mode.allow": "Use individual contact settings, otherwise allow", + "whisperSettings.mode.block": "Use individual contact settings, otherwise block", + "whisperSettings.mode.blockAll": "Block all", + "whisperSettings.incoming": "Incoming whisper settings", + "whisperSettings.sound": "Play a sound when someone whispers to you", + "whisperSettings.openHistory": "Always open the whisper history when someone whispers to you", + "whisperSettings.clearAfter": "Remove clients from the whisper history after", + "whisperSettings.never": "Never", + "whisperSettings.minutes": "{count} min", + "whisperHistory.received": "{name} whispered to you", "whisperHistory.stopped": "Stopped whispering", "whisperHistory.clear": "Clear", "whisperHistory.options": "Options", @@ -241,6 +253,10 @@ "contacts.category.blocked": "Blocked", "contacts.category.friend": "Friend", "contacts.phoneticName": "Phonetic Name:", + "contacts.whisperSetting": "Whisper:", + "contacts.whisperSetting.default": "Default", + "contacts.whisperSetting.allow": "Allow", + "contacts.whisperSetting.block": "Block", "contacts.show": "Show", "contacts.ignore": "Ignore", "contacts.unignore": "Unignore", @@ -696,6 +712,7 @@ "sounds.event.mute": "Mute toggled", "sounds.event.micClickOn": "Mic click on", "sounds.event.micClickOff": "Mic click off", + "sounds.event.whisper": "Whisper received", "sounds.default": "Default", "sounds.custom": "Custom file: {name}", "sounds.test": "▶ Test", diff --git a/web/src/locales/fa.json b/web/src/locales/fa.json index 01c81ee..a4a5fc8 100644 --- a/web/src/locales/fa.json +++ b/web/src/locales/fa.json @@ -165,6 +165,18 @@ "whisperHistory.title": "تاریخچه نجوا - {server}", "whisperHistory.empty": "هنوز تاریخچه نجوایی وجود ندارد.", "whisperHistory.started": "در حال نجوا با: {targets}", + "whisperSettings.subtitle": "تنظیمات نجوا", + "whisperSettings.rights": "مجوز نجواهای ورودی", + "whisperSettings.mode.allow": "استفاده از تنظیمات مخاطبین، در غیر این صورت اجازه", + "whisperSettings.mode.block": "استفاده از تنظیمات مخاطبین، در غیر این صورت مسدود", + "whisperSettings.mode.blockAll": "مسدود کردن همه", + "whisperSettings.incoming": "تنظیمات نجواهای ورودی", + "whisperSettings.sound": "پخش صدا هنگام دریافت نجوا", + "whisperSettings.openHistory": "باز کردن تاریخچهٔ نجوا هنگام دریافت نجوا", + "whisperSettings.clearAfter": "حذف کاربران از تاریخچهٔ نجوا پس از", + "whisperSettings.never": "هرگز", + "whisperSettings.minutes": "{count} دقیقه", + "whisperHistory.received": "{name} با شما نجوا کرد", "whisperHistory.stopped": "نجوا متوقف شد", "whisperHistory.clear": "پاک کردن", "whisperHistory.options": "گزینه‌ها", @@ -241,6 +253,10 @@ "contacts.category.blocked": "مسدود", "contacts.category.friend": "دوست", "contacts.phoneticName": "تلفظ نام:", + "contacts.whisperSetting": "نجوا:", + "contacts.whisperSetting.default": "پیش‌فرض", + "contacts.whisperSetting.allow": "اجازه", + "contacts.whisperSetting.block": "مسدود", "contacts.show": "نمایش", "contacts.ignore": "نادیده گرفتن", "contacts.unignore": "لغو نادیده گرفتن", @@ -695,6 +711,7 @@ "sounds.event.mute": "تغییر حالت بی‌صدا", "sounds.event.micClickOn": "کلیک میکروفون روشن", "sounds.event.micClickOff": "کلیک میکروفون خاموش", + "sounds.event.whisper": "نجوا دریافت شد", "sounds.default": "پیش‌فرض", "sounds.custom": "فایل سفارشی: {name}", "sounds.test": "▶ آزمایش", diff --git a/web/src/locales/zh-CN.json b/web/src/locales/zh-CN.json index 3f2b19b..7951772 100644 --- a/web/src/locales/zh-CN.json +++ b/web/src/locales/zh-CN.json @@ -104,6 +104,18 @@ "whisperHistory.title": "悄悄话历史 - {server}", "whisperHistory.empty": "暂无悄悄话历史。", "whisperHistory.started": "正在向以下目标发送悄悄话:{targets}", + "whisperSettings.subtitle": "悄悄话设置", + "whisperSettings.rights": "传入悄悄话权限", + "whisperSettings.mode.allow": "使用联系人单独设置,否则允许", + "whisperSettings.mode.block": "使用联系人单独设置,否则禁止", + "whisperSettings.mode.blockAll": "全部禁止", + "whisperSettings.incoming": "传入悄悄话设置", + "whisperSettings.sound": "有人对你悄悄话时播放声音", + "whisperSettings.openHistory": "有人对你悄悄话时总是打开悄悄话记录", + "whisperSettings.clearAfter": "从悄悄话记录中移除客户端的时间", + "whisperSettings.never": "从不", + "whisperSettings.minutes": "{count} 分钟", + "whisperHistory.received": "{name} 对你说了悄悄话", "whisperHistory.stopped": "已停止悄悄话", "whisperHistory.clear": "清除", "whisperHistory.options": "选项", @@ -180,6 +192,10 @@ "contacts.category.blocked": "已屏蔽", "contacts.category.friend": "好友", "contacts.phoneticName": "名称读音:", + "contacts.whisperSetting": "悄悄话:", + "contacts.whisperSetting.default": "默认", + "contacts.whisperSetting.allow": "允许", + "contacts.whisperSetting.block": "禁止", "contacts.show": "显示", "contacts.ignore": "忽略", "contacts.unignore": "取消忽略", @@ -541,6 +557,7 @@ "sounds.event.mute": "切换静音", "sounds.event.micClickOn": "麦克风开启提示音", "sounds.event.micClickOff": "麦克风关闭提示音", + "sounds.event.whisper": "收到悄悄话", "sounds.default": "默认", "sounds.custom": "自定义文件:{name}", "sounds.test": "▶ 测试", diff --git a/web/src/soundpack.ts b/web/src/soundpack.ts index 80ccedf..f3d158f 100644 --- a/web/src/soundpack.ts +++ b/web/src/soundpack.ts @@ -26,6 +26,7 @@ const EVENT_KEYWORDS: Record = { mute: ["micmuted", "microphonemuted", "micactivated", "microphoneactivated"], micClickOn: ["micclickon"], micClickOff: ["micclickoff"], + whisper: ["whisperreceived", "whisper"], }; function normalize(filename: string): string { diff --git a/web/src/sounds.ts b/web/src/sounds.ts index 4e6378b..38e47ba 100644 --- a/web/src/sounds.ts +++ b/web/src/sounds.ts @@ -7,7 +7,8 @@ export type SoundEventId = | "poke" | "mute" | "micClickOn" - | "micClickOff"; + | "micClickOff" + | "whisper"; export const SOUND_EVENTS: SoundEventId[] = [ "connect", @@ -19,6 +20,7 @@ export const SOUND_EVENTS: SoundEventId[] = [ "mute", "micClickOn", "micClickOff", + "whisper", ]; /** "ide" swaps the default chimes for synthetic terminal blips (Command Center layout). */ @@ -238,6 +240,11 @@ function synthNotes(event: SoundEventId): SynthNote[] { return [{ delay: 0, freq: 1400, duration: 0.03, gain: 0.15 }]; case "micClickOff": return [{ delay: 0, freq: 900, duration: 0.03, gain: 0.15 }]; + case "whisper": + return [ + { delay: 0, freq: 783.99, duration: 0.12, gain: 0.2 }, + { delay: 0.1, freq: 659.25, duration: 0.16, gain: 0.18 }, + ]; } } @@ -274,6 +281,8 @@ function ideNotes(event: SoundEventId): SynthNote[] { return [{ delay: 0, freq: 1600, duration: 0.02, gain: 0.08, type: "square" }]; case "micClickOff": return [{ delay: 0, freq: 1000, duration: 0.02, gain: 0.08, type: "square" }]; + case "whisper": + return [{ delay: 0, freq: 900, endFreq: 700, duration: 0.08, gain: 0.1, type: "triangle" }]; } }