Some checks failed
Release / semantic-release (push) Successful in 59s
tests / Unit tests (Linux, Python 3.11) (push) Successful in 13m45s
Release / build-linux (push) Failing after 7m47s
Release / build-windows (push) Has been cancelled
Release / build-macos (arm64, macos-latest) (push) Has been cancelled
Release / build-macos (x64, macos-15-intel) (push) Has been cancelled
Release / release-main (push) Has been cancelled
Release / release-develop (push) Has been cancelled
Transform isair/jarvis into a Discord-controlled voice assistant running on the Ubuntu VNC desktop, keeping the mature ~39k-line Python brain intact. - bot/ (Node + bun, discord.js): /자비스 slash commands (ephemeral), voice channel join + voice receive/playback, pluggable VNC screen broadcast (selfbot live / noVNC / screenshot) - bridge/ (Python, Flask): wraps jarvis STT + run_reply_engine + Piper TTS behind a thin localhost HTTP API - .env.example, scripts/ (start_bridge/start_bot/dev), README rewrite, docs/language-comparison.md and docs/vnc-xfce-setup.md Language decision: hybrid (Python brain + Node/bun Discord layer) because Discord blocks bot video; native screen broadcast only works via a Node selfbot library.
63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
/**
|
|
* Screenshot backend (safe, no ban risk, not real-time).
|
|
*
|
|
* Periodically grabs a frame from the VNC X display with ffmpeg's x11grab and
|
|
* posts it to the invoking text channel. Low FPS, but works with a normal bot
|
|
* account and never touches Discord's selfbot surface.
|
|
*/
|
|
import { spawn } from "node:child_process";
|
|
import type { AppConfig } from "../config.ts";
|
|
import type { ScreenStreamer, StreamContext } from "./index.ts";
|
|
|
|
function grabFrame(display: string, size: string): Promise<Buffer> {
|
|
return new Promise((resolve, reject) => {
|
|
const ff = spawn("ffmpeg", [
|
|
"-loglevel", "error",
|
|
"-f", "x11grab",
|
|
"-video_size", size,
|
|
"-i", display,
|
|
"-frames:v", "1",
|
|
"-f", "image2pipe",
|
|
"-vcodec", "png",
|
|
"pipe:1",
|
|
]);
|
|
const chunks: Buffer[] = [];
|
|
ff.stdout.on("data", (c) => chunks.push(c));
|
|
ff.on("error", reject);
|
|
ff.on("close", (code) =>
|
|
code === 0 ? resolve(Buffer.concat(chunks)) : reject(new Error(`ffmpeg exited ${code}`)),
|
|
);
|
|
});
|
|
}
|
|
|
|
export class ScreenshotStreamer implements ScreenStreamer {
|
|
readonly kind = "screenshot" as const;
|
|
private timer: ReturnType<typeof setInterval> | null = null;
|
|
constructor(private config: AppConfig) {}
|
|
|
|
isActive() {
|
|
return this.timer !== null;
|
|
}
|
|
|
|
async start(ctx: StreamContext): Promise<string> {
|
|
if (!ctx.postImage) return "스크린샷을 올릴 텍스트 채널 컨텍스트가 없습니다.";
|
|
if (this.timer) return "이미 스크린샷 송출 중입니다.";
|
|
const tick = async () => {
|
|
try {
|
|
const png = await grabFrame(this.config.vncDisplay, this.config.vncResolution);
|
|
await ctx.postImage!(png, "vnc.png");
|
|
} catch (e) {
|
|
console.error("[screenshot] grab failed:", e);
|
|
}
|
|
};
|
|
this.timer = setInterval(tick, this.config.screenshotIntervalSec * 1000);
|
|
void tick();
|
|
return `📸 ${this.config.screenshotIntervalSec}초마다 VNC 스크린샷을 이 채널에 올립니다.`;
|
|
}
|
|
|
|
async stop(): Promise<void> {
|
|
if (this.timer) clearInterval(this.timer);
|
|
this.timer = null;
|
|
}
|
|
}
|