refactor: fake room routing moved to connect-time, fully decoupled from production

- server.py / main.py no longer reference fake_room at all (no import,
  no --fake-room flag, no _apply_fake_room)
- Routing decision happens at connect time in DanmakuClient.start():
  room_id == 1 dynamically imports fake_room.py and patches blivedm;
  any other room id returns immediately without touching fake_room
- Switching back from room 1 to another room unpatches to real Bilibili
- Production (packaged, no fake_room.py) is completely unaffected for
  normal room ids; room 1 without fake_room.py raises a clear error
- Rebuild portable zip (83.9 MB)
This commit is contained in:
2026-08-08 17:59:38 +08:00
parent d4de39f294
commit 4f7168a0e3
3 changed files with 23 additions and 37 deletions
-13
View File
@@ -33,8 +33,6 @@ def parse_args() -> argparse.Namespace:
parser.add_argument("--no-numbers", action="store_true")
parser.add_argument("--list-devices", action="store_true")
parser.add_argument("--debug", "-d", action="store_true")
parser.add_argument("--fake-room", type=int, default=0, metavar="PORT",
help="connect to local fake_room.py instead of real Bilibili (dev/testing only)")
return parser.parse_args()
@@ -60,17 +58,6 @@ async def tts_worker(queue: asyncio.Queue, bridge: TTSBridge,
async def main_async(args: argparse.Namespace) -> int:
if args.fake_room:
import importlib
fake = importlib.import_module("fake_room")
fake.patch_blivedm(args.fake_room)
logger.info("[dev] connected to fake room on port %d", args.fake_room)
elif args.room_id == 1:
import importlib
fake = importlib.import_module("fake_room")
fake.patch_blivedm(8081)
logger.info("[dev] room 1 -> fake room on port 8081")
if args.list_devices:
devices = get_output_devices()
print("Available audio output devices:")