"""启动 HTTP 服务: python -m tg_bridge""" from __future__ import annotations import uvicorn from tg_bridge.config import Settings from tg_bridge.winloop import apply_windows_selector_policy def main() -> None: apply_windows_selector_policy() s = Settings.load() # Windows 上 Uvicorn 仍优先 Proactor,须显式 loop_factory,否则 lifespan 里 Telethon WinError 121 uvicorn.run( "tg_bridge.app:app", host=s.bridge_host, port=s.bridge_port, log_level="info", loop="tg_bridge.uvicorn_loop:selector_loop_factory", ) if __name__ == "__main__": main()