diff --git a/box/Dockerfile b/box/Dockerfile index ed78ed3..23141a5 100644 --- a/box/Dockerfile +++ b/box/Dockerfile @@ -40,6 +40,6 @@ RUN chmod +x /usr/local/bin/anybot-box-start /usr/local/bin/anybot-a11y /usr/loc # without it — no numbers at all, only a picture to guess at. GTK 3 apps ignore it. ENV DISPLAY=:1 SCREEN_SIZE=1280x800x24 GTK_MODULES=gail:atk-bridge GTK_A11Y=atspi GNOME_ACCESSIBILITY=1 NO_AT_BRIDGE=0 EXPOSE 6080 -LABEL anybot.box.version="10" +LABEL anybot.box.version="11" ENTRYPOINT ["/usr/bin/tini", "--"] CMD ["/usr/local/bin/anybot-box-start"] diff --git a/box/screen b/box/screen index c146f3f..c9c4105 100755 --- a/box/screen +++ b/box/screen @@ -107,6 +107,8 @@ up() { done as_bot "DISPLAY=:$disp xrdb -nocpp -merge /home/bot/.Xresources" 2>/dev/null as_bot "DISPLAY=:$disp DBUS_SESSION_BUS_ADDRESS=$bus setsid fluxbox >/dev/null 2>&1 & echo \$!" 8>&- >> "$d/pids" + # Copy and paste with the person's computer (as on the shared screen: start.sh). + as_bot "DISPLAY=:$disp setsid vncconfig -nowin >/dev/null 2>&1 & echo \$!" 8>&- >> "$d/pids" xsetroot -display ":$disp" -solid '#2b2f36' { echo "DISPLAY=:$disp" diff --git a/box/start.sh b/box/start.sh index 7b6ab78..6e46aa8 100644 --- a/box/start.sh +++ b/box/start.sh @@ -5,6 +5,13 @@ mkdir -p /home/bot/.fluxbox /home/bot/Desktop && cp -n /etc/anybot/fluxbox-init cp -n /etc/anybot/overlay /home/bot/.fluxbox/overlay 2>/dev/null cp -n /etc/anybot/Xresources /home/bot/.Xresources 2>/dev/null cp /etc/anybot/menu /home/bot/.fluxbox/menu 2>/dev/null +# GTK's dialogs (a web page's 上傳檔案 in Chromium, e.g. Threads' 加入相片) with 取消 and 開啟 in a +# bar at the top, as on GNOME. Without GNOME's settings service GTK put them at the bottom of a +# file window taller than the screen, under the taskbar: a picture could be found but never sent. +GTKINI=/home/bot/.config/gtk-3.0/settings.ini +mkdir -p "${GTKINI%/*}" +grep -q '^\[Settings\]' "$GTKINI" 2>/dev/null || printf '[Settings]\n' >> "$GTKINI" +grep -q '^gtk-dialogs-use-header' "$GTKINI" || sed -i '/^\[Settings\]/a gtk-dialogs-use-header=true' "$GTKINI" chown -R bot:bot /home/bot rm -f /tmp/.X1-lock /tmp/.X11-unix/X1 # One TigerVNC server is the screen and the VNC server (was Xvfb + x11vnc, which polls the @@ -39,15 +46,23 @@ for c in /usr/libexec/at-spi2-registryd /usr/lib/at-spi2-core/at-spi2-registryd; [ -x "$c" ] && { su bot -c "DISPLAY=:1 DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS $c >/tmp/atspi-registry.log 2>&1 &"; break; } done su bot -c "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS gsettings set org.gnome.desktop.interface toolkit-accessibility true" 2>/dev/null || true +# The file window opens smaller than the screen, whatever size it was left at. +SW="${GEOM%x*}"; SH="${GEOM#*x}" +su bot -c "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS gsettings set org.gtk.Settings.FileChooser window-size '($((SW * 7 / 10)), $((SH * 3 / 4)))'" 2>/dev/null || true su bot -c "DISPLAY=:1 DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS xrdb -nocpp -merge /home/bot/.Xresources" su bot -c "DISPLAY=:1 DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS fluxbox >/tmp/fluxbox.log 2>&1 &" +# Copy and paste between the person's computer and this one: Xvnc hands the viewer's clipboard to +# the X selections (and back) only while vncconfig runs (after LazyBoy2's box). +su bot -c "DISPLAY=:1 vncconfig -nowin >/tmp/vncconfig.log 2>&1 &" (sleep 1.5; xsetroot -display :1 -solid '#2b2f36') & xsetroot -display :1 -solid '#2b2f36' # One web viewer for every screen: the shared one is "main"; anybot-screen adds each bot's own # (每個 Bot 一個螢幕). A viewer picks one with ?path=websockify%3Ftoken%3D. rm -rf /tmp/anybot-screens; mkdir -p /tmp/anybot-screens && chmod 1777 /tmp/anybot-screens echo "main: localhost:5900" > /tmp/anybot-vnc-tokens && chown bot:bot /tmp/anybot-vnc-tokens -websockify --web /usr/share/novnc --token-plugin TokenFile --token-source /tmp/anybot-vnc-tokens 6080 >/tmp/novnc.log 2>&1 & +# (A ping every 30 s: a proxy on the way — Tailscale serve, Caddy — doesn't drop a viewer that is +# only watching a still screen.) +websockify --heartbeat=30 --web /usr/share/novnc --token-plugin TokenFile --token-source /tmp/anybot-vnc-tokens 6080 >/tmp/novnc.log 2>&1 & WEBSOCKIFY_PID=$! # Say ready only once the viewer's port listens: the app opens noVNC on this flag, and a too # early file meant the first viewer load 404'd. diff --git a/docs/feature-map/browser.md b/docs/feature-map/browser.md index 36bc8c7..de763ad 100644 --- a/docs/feature-map/browser.md +++ b/docs/feature-map/browser.md @@ -36,3 +36,4 @@ Bot 用 AnyBot 自己的瀏覽器上網、登入網站、點按、打字、送 - 雲端中繼資料位址永遠打不開;本機或內部網路的網址要使用者允許(直接操作模式除外)。 - 發布關卡、已送帳本、送出後確認只管 AnyBot 自己的瀏覽器;用螢幕操作送出的,只能從步驟推算。頁面看不出回哪一篇時,只擋 24 小時內同一頁一模一樣的內容。 - 送出後頁面上沒看到(例如從動態牆送出),結果寫「還沒確認」:不要因此再送一次,回原貼文看。 +- 網頁要上傳檔案(Threads、IG 加相片、表單附件):用 `upload` 直接放進頁面的檔案欄位。用螢幕去點「加入相片」會跳出 Bot 電腦的檔案視窗(「取消」「Open」在最上面),還要在裡面找檔案、按 Open。 diff --git a/docs/feature-map/computers.md b/docs/feature-map/computers.md index 388fe79..e026a5e 100644 --- a/docs/feature-map/computers.md +++ b/docs/feature-map/computers.md @@ -32,6 +32,8 @@ - Bot 不能自己換電腦:工具指定了別台,但使用者最近三則訊息沒提到那台,這一步會被移回使用者選的那台,結果裡會說。真的要別台先問使用者。 - 使用者選的那台沒開機、或那台的 AnyBot 沒開沒登入,就不在清單上:Bot 先待在自己的電腦,`list_computers` 會寫那台「現在沒有連線」。 - 在 Bot 自己的電腦上做事不用問,但它看不到使用者的檔案;檔案工具只碰得到自己的資料夾(大家共用同一台)。 +- Bot 的電腦是精簡的 Linux 桌面(Debian + fluxbox):檔案視窗的「取消」「Open」在視窗最上面(第 11 版以前在最下面、被螢幕切掉,網頁上傳圖片選得到檔案卻送不出去——設定 › 電腦「更新 Bot 的電腦」換新版)。看畫面時可以跟自己的電腦互相複製貼上。 +- 從帳號看 Bot 電腦的畫面,只要開著就不會斷;之前靜止畫面一分鐘、或看超過十分鐘會被帳號伺服器切掉,要更新帳號伺服器(make update-server)。 - 「在這台電腦上執行」設成永不允許(或被管理員鎖住)時,這台的檔案也不能傳出去、打開或發佈。 - SSH 電腦上的檔案不能直接傳到聊天、打開給使用者看或發佈網站,要先複製到 Bot 自己的電腦。 - 帳號裡的其他電腦:看畫面、操作畫面各自要使用者允許(可以一律允許);改檔案和指令照 SSH 電腦的規則問。 diff --git a/src/cloudbox.rs b/src/cloudbox.rs index 3d85d8f..ce2e96f 100644 --- a/src/cloudbox.rs +++ b/src/cloudbox.rs @@ -3423,7 +3423,7 @@ mod tests { use chrono::TimeZone; let at = chrono::Utc.with_ymd_and_hms(2026, 11, 6, 19, 0, 0).unwrap().with_timezone(&chrono_tz::Asia::Taipei); assert!(in_schedule_window("03:00", at.time())); - assert_eq!(wanted_version(), "10"); + assert_eq!(wanted_version(), "11"); // Every file the Dockerfile copies is one this app carries (build_image writes them). let carried = ["start.sh", "fluxbox-init", "overlay", "Xresources", "menu", "a11y", "browser", "screen"]; for l in DOCKERFILE.lines().filter_map(|l| l.trim().strip_prefix("COPY ")) {