Fix Telegram forum topic routing

This commit is contained in:
2569718930@qq.com
2026-06-14 05:45:07 +08:00
parent e783f35a4f
commit e6a5fd2dda
4 changed files with 66 additions and 32 deletions
+1
View File
@@ -9,6 +9,7 @@ data/*.db
data/*.db-*
data/*.db.*
data/*.json
!data/city_thread_ids.json
data/*backtest*.csv
data/logs/
data/historical/
+33
View File
@@ -0,0 +1,33 @@
{
"amsterdam": 116398,
"ankara": 116394,
"atlanta": 13115,
"austin": 13120,
"beijing": 116383,
"busan": 116381,
"chengdu": 116388,
"chicago": 13113,
"chongqing": 116389,
"dallas": 13119,
"denver": 13114,
"guangzhou": 116385,
"helsinki": 116397,
"hong kong": 116391,
"houston": 13118,
"istanbul": 116395,
"los angeles": 13112,
"miami": 13116,
"new york": 13111,
"paris": 116399,
"qingdao": 116387,
"san francisco": 13117,
"seattle": 13122,
"seoul": 116380,
"shanghai": 116384,
"shenzhen": 116386,
"singapore": 116393,
"taipei": 116392,
"tel aviv": 116396,
"tokyo": 116382,
"wuhan": 116390
}
+31 -31
View File
@@ -41,37 +41,37 @@ BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN", "").strip()
CHAT_ID = -1003927451869
CITIES: list[tuple[str, str]] = [
("🇰🇷 Seoul", "seoul"),
("🇰🇷 Busan", "busan"),
("🇯🇵 Tokyo", "tokyo"),
("🇨🇳 Beijing", "beijing"),
("🇨🇳 Shanghai", "shanghai"),
("🇨🇳 Guangzhou", "guangzhou"),
("🇨🇳 Shenzhen / Lau Fau Shan", "shenzhen"),
("🇨🇳 Qingdao", "qingdao"),
("🇨🇳 Chengdu", "chengdu"),
("🇨🇳 Chongqing", "chongqing"),
("🇨🇳 Wuhan", "wuhan"),
("🇭🇰 Hong Kong", "hong kong"),
("🇹🇼 Taipei", "taipei"),
("🇸🇬 Singapore", "singapore"),
("🇹🇷 Istanbul", "istanbul"),
("🇹🇷 Ankara", "ankara"),
("🇮🇱 Tel Aviv", "tel aviv"),
("🇫🇮 Helsinki", "helsinki"),
("🇳🇱 Amsterdam", "amsterdam"),
("🇫🇷 Paris", "paris"),
("🇺🇸 New York", "new york"),
("🇺🇸 Los Angeles", "los angeles"),
("🇺🇸 Chicago", "chicago"),
("🇺🇸 Denver", "denver"),
("🇺🇸 Atlanta", "atlanta"),
("🇺🇸 Miami", "miami"),
("🇺🇸 San Francisco", "san francisco"),
("🇺🇸 Houston", "houston"),
("🇺🇸 Dallas", "dallas"),
("🇺🇸 Austin", "austin"),
("🇺🇸 Seattle", "seattle"),
("#seoul", "seoul"),
("#busan", "busan"),
("#tokyo", "tokyo"),
("#beijing", "beijing"),
("#shanghai", "shanghai"),
("#guangzhou", "guangzhou"),
("#shenzhen #LauFauShan", "shenzhen"),
("#qingdao", "qingdao"),
("#chengdu", "chengdu"),
("#chongqing", "chongqing"),
("#wuhan", "wuhan"),
("#HongKong", "hong kong"),
("#taipei", "taipei"),
("#singapore", "singapore"),
("#istanbul", "istanbul"),
("#ankara", "ankara"),
("#TelAviv", "tel aviv"),
("#helsinki", "helsinki"),
("#amsterdam", "amsterdam"),
("#paris", "paris"),
("#NewYork", "new york"),
("#LosAngeles", "los angeles"),
("#chicago", "chicago"),
("#denver", "denver"),
("#atlanta", "atlanta"),
("#miami", "miami"),
("#SanFrancisco", "san francisco"),
("#houston", "houston"),
("#dallas", "dallas"),
("#austin", "austin"),
("#seattle", "seattle"),
]
URL = f"https://api.telegram.org/bot{BOT_TOKEN}/createForumTopic"
+1 -1
View File
@@ -45,7 +45,7 @@ _HTTP_SESSION_LOCK = threading.Lock()
# Bot send_message rate limiter: max N messages per second across all threads
_SEND_MSG_LOCK = threading.Lock()
_SEND_MSG_LAST_TS: float = 0.0
_SEND_MSG_MIN_INTERVAL_SEC = float(os.getenv("TELEGRAM_SEND_RATE_LIMIT_SEC", "0.05"))
_SEND_MSG_MIN_INTERVAL_SEC = float(os.getenv("TELEGRAM_SEND_RATE_LIMIT_SEC", "1.1"))
def _get_http_session() -> requests_lib.Session: