Files
tg_python/tg_bridge/__main__.py
2026-04-23 22:06:19 +08:00

26 lines
628 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""启动 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()