mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
Add server/channel passwords, connection autofill, and client status icons
Server/channel passwords are now optional connect fields (hidden behind a lock toggle so the normal flow stays uncluttered). The last successfully used server/nickname is remembered via localStorage and autofilled on load. The channel tree now shows per-client status badges (channel commander, away, mic muted, deafened) sourced directly from tsclientlib's existing client data. Also credits Claude Code in the README, since it wrote the vast majority of this project's code. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4306da474b
commit
76cb90360c
6 files changed
+151
-13
No files matched your search
@@ -9,8 +9,11 @@ reimagined.
|
||||
|
||||
## Features
|
||||
|
||||
- Connect to a real TeamSpeak (3/6) server
|
||||
- Connect to a real TeamSpeak (3/6) server, with optional server and
|
||||
default-channel passwords
|
||||
- Remembers the last server/nickname you connected with
|
||||
- Channel/client tree with correct ordering, click to switch channels
|
||||
- Per-client status icons (channel commander, away, mic muted, deafened)
|
||||
- Text chat: channel, server-wide, and private (1:1) — each in its own tab
|
||||
- Voice with voice activation ("Sprachaktivierung", not push-to-talk),
|
||||
adjustable sensitivity, and per-client speaking indicators
|
||||
@@ -44,3 +47,7 @@ Browser (web/) <--WebSocket--> Gateway (gateway/) <--stdin/stdout JSON--> Ru
|
||||
## Installation
|
||||
|
||||
See [INSTALL.md](INSTALL.md).
|
||||
|
||||
## Credits
|
||||
|
||||
The vast majority of this project's code was written by [Claude Code](https://claude.com/claude-code) (Anthropic's Claude), working iteratively with the repo owner one feature at a time.
|
||||
+28
-2
@@ -33,6 +33,12 @@ struct Args {
|
||||
/// Nickname to use on the server
|
||||
#[arg(short, long, default_value = "Browser User")]
|
||||
nickname: String,
|
||||
/// Server password, if the server requires one
|
||||
#[arg(long)]
|
||||
server_password: Option<String>,
|
||||
/// Password for the default channel to join, if it's password-protected
|
||||
#[arg(long)]
|
||||
channel_password: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
@@ -48,6 +54,11 @@ struct ClientInfo {
|
||||
id: u16,
|
||||
channel: u64,
|
||||
name: String,
|
||||
input_muted: bool,
|
||||
output_muted: bool,
|
||||
input_hardware_enabled: bool,
|
||||
away: bool,
|
||||
is_channel_commander: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
@@ -134,7 +145,16 @@ fn snapshot(con: &data::Connection) -> Event {
|
||||
let clients = con
|
||||
.clients
|
||||
.values()
|
||||
.map(|c| ClientInfo { id: c.id.0, channel: c.channel.0, name: c.name.clone() })
|
||||
.map(|c| ClientInfo {
|
||||
id: c.id.0,
|
||||
channel: c.channel.0,
|
||||
name: c.name.clone(),
|
||||
input_muted: c.input_muted,
|
||||
output_muted: c.output_muted,
|
||||
input_hardware_enabled: c.input_hardware_enabled,
|
||||
away: c.away_message.is_some(),
|
||||
is_channel_commander: c.is_channel_commander,
|
||||
})
|
||||
.collect();
|
||||
Event::Channels { channels, clients }
|
||||
}
|
||||
@@ -172,7 +192,13 @@ async fn run(args: Args) -> Result<()> {
|
||||
tracing_subscriber::fmt().with_env_filter("warn").with_writer(std::io::stderr).init();
|
||||
|
||||
let address = args.address.clone();
|
||||
let con_config = Connection::build(args.address).name(args.nickname);
|
||||
let mut con_config = Connection::build(args.address).name(args.nickname);
|
||||
if let Some(pwd) = args.server_password {
|
||||
con_config = con_config.password(pwd);
|
||||
}
|
||||
if let Some(pwd) = args.channel_password {
|
||||
con_config = con_config.channel_password(pwd);
|
||||
}
|
||||
|
||||
let mut con = con_config.connect().map_err(|e| friendly_connect_error(&address, e))?;
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ wss.on("connection", (socket: WebSocket) => {
|
||||
const options: Ts3ConnectOptions = {
|
||||
host: msg.host,
|
||||
nickname: msg.nickname,
|
||||
serverPassword: msg.serverPassword,
|
||||
channelPassword: msg.channelPassword,
|
||||
};
|
||||
connection = new Ts3Connection(options);
|
||||
connection.onEvent((event) => socket.send(JSON.stringify(event)));
|
||||
|
||||
@@ -21,6 +21,11 @@ export interface ClientInfo {
|
||||
id: number;
|
||||
channel: number;
|
||||
name: string;
|
||||
inputMuted: boolean;
|
||||
outputMuted: boolean;
|
||||
inputHardwareEnabled: boolean;
|
||||
away: boolean;
|
||||
isChannelCommander: boolean;
|
||||
}
|
||||
|
||||
export type Ts3ConnectionEvent =
|
||||
@@ -37,6 +42,8 @@ export type Ts3ConnectionEvent =
|
||||
export interface Ts3ConnectOptions {
|
||||
host: string;
|
||||
nickname: string;
|
||||
serverPassword?: string;
|
||||
channelPassword?: string;
|
||||
}
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
@@ -61,18 +68,27 @@ export class Ts3Connection {
|
||||
}
|
||||
|
||||
async connect(): Promise<void> {
|
||||
this.child = spawn(CONNECTOR_BIN, [
|
||||
"--address",
|
||||
this.options.host,
|
||||
"--nickname",
|
||||
this.options.nickname,
|
||||
]);
|
||||
const args = ["--address", this.options.host, "--nickname", this.options.nickname];
|
||||
if (this.options.serverPassword) args.push("--server-password", this.options.serverPassword);
|
||||
if (this.options.channelPassword) args.push("--channel-password", this.options.channelPassword);
|
||||
this.child = spawn(CONNECTOR_BIN, args);
|
||||
|
||||
createInterface({ input: this.child.stdout }).on("line", (line) => {
|
||||
try {
|
||||
interface RawClientInfo {
|
||||
id: number;
|
||||
channel: number;
|
||||
name: string;
|
||||
input_muted: boolean;
|
||||
output_muted: boolean;
|
||||
input_hardware_enabled: boolean;
|
||||
away: boolean;
|
||||
is_channel_commander: boolean;
|
||||
}
|
||||
|
||||
const event = JSON.parse(line) as
|
||||
| { type: "connected"; welcome_message: string }
|
||||
| { type: "channels"; channels: ChannelInfo[]; clients: ClientInfo[] }
|
||||
| { type: "channels"; channels: ChannelInfo[]; clients: RawClientInfo[] }
|
||||
| { type: "chatMessage"; from: string; message: string }
|
||||
| { type: "serverMessage"; from: string; message: string }
|
||||
| { type: "privateMessage"; partner_id: number; partner_name: string; from_self: boolean; message: string }
|
||||
@@ -83,6 +99,21 @@ export class Ts3Connection {
|
||||
|
||||
if (event.type === "connected") {
|
||||
this.emit({ type: "connected", welcomeMessage: event.welcome_message });
|
||||
} else if (event.type === "channels") {
|
||||
this.emit({
|
||||
type: "channels",
|
||||
channels: event.channels,
|
||||
clients: event.clients.map((c) => ({
|
||||
id: c.id,
|
||||
channel: c.channel,
|
||||
name: c.name,
|
||||
inputMuted: c.input_muted,
|
||||
outputMuted: c.output_muted,
|
||||
inputHardwareEnabled: c.input_hardware_enabled,
|
||||
away: c.away,
|
||||
isChannelCommander: c.is_channel_commander,
|
||||
})),
|
||||
});
|
||||
} else if (event.type === "privateMessage") {
|
||||
this.emit({
|
||||
type: "privateMessage",
|
||||
|
||||
@@ -211,6 +211,13 @@
|
||||
background: color-mix(in srgb, #4caf50 15%, transparent);
|
||||
}
|
||||
|
||||
.ts-status-icons {
|
||||
display: inline-flex;
|
||||
gap: 0.15rem;
|
||||
font-size: 11px;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.ts-mic-on {
|
||||
background: color-mix(in srgb, #4caf50 30%, var(--button-bg-1)) !important;
|
||||
}
|
||||
|
||||
+68
-3
@@ -11,6 +11,9 @@ import {
|
||||
|
||||
const GATEWAY_URL = "ws://localhost:8080";
|
||||
|
||||
const LAST_HOST_KEY = "ts-web-client:last-host";
|
||||
const LAST_NICKNAME_KEY = "ts-web-client:last-nickname";
|
||||
|
||||
type LogEntry = { text: string; kind: "info" | "error" };
|
||||
|
||||
interface ChannelInfo {
|
||||
@@ -24,6 +27,11 @@ interface ClientInfo {
|
||||
id: number;
|
||||
channel: number;
|
||||
name: string;
|
||||
inputMuted: boolean;
|
||||
outputMuted: boolean;
|
||||
inputHardwareEnabled: boolean;
|
||||
away: boolean;
|
||||
isChannelCommander: boolean;
|
||||
}
|
||||
|
||||
function ChannelIcon() {
|
||||
@@ -49,6 +57,17 @@ function ClientIcon() {
|
||||
);
|
||||
}
|
||||
|
||||
function ClientStatusIcons({ client }: { client: ClientInfo }) {
|
||||
return (
|
||||
<span className="ts-status-icons">
|
||||
{client.isChannelCommander && <span title="Channel commander">⭐</span>}
|
||||
{client.away && <span title="Away">💤</span>}
|
||||
{(client.inputMuted || !client.inputHardwareEnabled) && <span title="Microphone muted">🔇</span>}
|
||||
{client.outputMuted && <span title="Sound muted (deafened)">🔕</span>}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function ServerIcon() {
|
||||
return (
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true">
|
||||
@@ -102,6 +121,7 @@ function ChannelTree({
|
||||
>
|
||||
<ClientIcon />
|
||||
<span>{c.name}</span>
|
||||
<ClientStatusIcons client={c} />
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
@@ -141,8 +161,11 @@ interface PmThread {
|
||||
type ActiveTab = "channel" | "server" | number;
|
||||
|
||||
function App() {
|
||||
const [host, setHost] = useState("localhost");
|
||||
const [nickname, setNickname] = useState("Claude Code");
|
||||
const [host, setHost] = useState(() => localStorage.getItem(LAST_HOST_KEY) ?? "localhost");
|
||||
const [nickname, setNickname] = useState(() => localStorage.getItem(LAST_NICKNAME_KEY) ?? "Claude Code");
|
||||
const [serverPassword, setServerPassword] = useState("");
|
||||
const [channelPassword, setChannelPassword] = useState("");
|
||||
const [showPasswordFields, setShowPasswordFields] = useState(false);
|
||||
const [log, setLog] = useState<LogEntry[]>([]);
|
||||
const [connected, setConnected] = useState(false);
|
||||
const [connecting, setConnecting] = useState(false);
|
||||
@@ -231,7 +254,15 @@ function App() {
|
||||
socketRef.current = socket;
|
||||
|
||||
socket.onopen = () => {
|
||||
socket.send(JSON.stringify({ type: "connect", host, nickname }));
|
||||
socket.send(
|
||||
JSON.stringify({
|
||||
type: "connect",
|
||||
host,
|
||||
nickname,
|
||||
serverPassword: serverPassword || undefined,
|
||||
channelPassword: channelPassword || undefined,
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
socket.onmessage = (event) => {
|
||||
@@ -242,6 +273,8 @@ function App() {
|
||||
setConnecting(false);
|
||||
setConnectError(null);
|
||||
setConnected(true);
|
||||
localStorage.setItem(LAST_HOST_KEY, host);
|
||||
localStorage.setItem(LAST_NICKNAME_KEY, nickname);
|
||||
setServerChat((prev) => [...prev, { from: "Server", message: data.welcomeMessage }]);
|
||||
break;
|
||||
case "channels":
|
||||
@@ -422,6 +455,38 @@ function App() {
|
||||
disabled={connected || connecting}
|
||||
/>
|
||||
</label>
|
||||
{!connected && (
|
||||
<button
|
||||
className={showPasswordFields ? "ts-mic-on" : undefined}
|
||||
onClick={() => setShowPasswordFields((v) => !v)}
|
||||
disabled={connecting}
|
||||
title="Server/channel password"
|
||||
>
|
||||
🔒
|
||||
</button>
|
||||
)}
|
||||
{!connected && showPasswordFields && (
|
||||
<>
|
||||
<label>
|
||||
Server password
|
||||
<input
|
||||
type="password"
|
||||
value={serverPassword}
|
||||
onChange={(e) => setServerPassword(e.target.value)}
|
||||
disabled={connecting}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Channel password
|
||||
<input
|
||||
type="password"
|
||||
value={channelPassword}
|
||||
onChange={(e) => setChannelPassword(e.target.value)}
|
||||
disabled={connecting}
|
||||
/>
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
{!connected ? (
|
||||
<button onClick={handleConnect} disabled={connecting}>
|
||||
{connecting ? "Connecting…" : "Connect"}
|
||||
|
||||
Reference in new issue
Block a user