Skip to content

Commit e8796b6

Browse files
committed
feat: 启动超时时间设定项
1 parent d0c94bf commit e8796b6

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

telegram_chat/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class Config(Serializable):
1515

1616
telegram: Dict[str, Any] = {
1717
"token": None,
18-
"api": None
18+
"api": None,
19+
"startup_timeout": 60,
1920
}
2021

2122
whitelist: Dict[str, Any] = {

telegram_chat/telegram_manager.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import time
55
from typing import Callable
66

7+
from .config import ConfigManager
8+
79
from telegram import Bot, Update
810
from telegram.ext import Application, ApplicationBuilder, filters, MessageHandler
911

@@ -45,7 +47,7 @@ def start(self, wait_until_connected: bool = False):
4547
while True:
4648
if self.application.running:
4749
break
48-
if time.time() - start_time > 5:
50+
if time.time() - start_time > ConfigManager.config.telegram["startup_timeout"]:
4951
raise Exception("Unable to start Telegram bot.")
5052
time.sleep(0.5)
5153
self.logger.info("Telegram bot started.")

0 commit comments

Comments
 (0)