初始化

This commit is contained in:
van
2026-04-23 22:06:19 +08:00
commit e9823c2261
26 changed files with 840 additions and 0 deletions

25
tg_bridge/__main__.py Normal file
View File

@@ -0,0 +1,25 @@
"""启动 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()