feat: prompt for phone input
This commit is contained in:
12
src/main.py
12
src/main.py
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
import logging
|
||||
import signal
|
||||
from typing import Optional
|
||||
|
||||
from telethon import TelegramClient
|
||||
|
||||
@@ -18,6 +19,15 @@ logging.basicConfig(
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _resolve_phone(preconfigured: Optional[str]) -> str:
|
||||
if preconfigured:
|
||||
return preconfigured
|
||||
phone = input("请输入 Telegram 手机号(含国家码,如 +8613712345678):").strip()
|
||||
if not phone:
|
||||
raise RuntimeError("未提供手机号,无法完成首次登录。")
|
||||
return phone
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
config = load_config()
|
||||
|
||||
@@ -27,7 +37,7 @@ async def main() -> None:
|
||||
api_hash=config.credentials.api_hash,
|
||||
)
|
||||
|
||||
await client.start(phone=config.credentials.phone)
|
||||
await client.start(phone=_resolve_phone(config.credentials.phone))
|
||||
logger.info("User-Bot 登录完成。")
|
||||
|
||||
keyword_store = KeywordStore(config.monitor.keywords_file)
|
||||
|
||||
Reference in New Issue
Block a user