22# -*- coding: utf-8 -*-
33# Repo: https://github.com/Cp0204/ChinaTelecomMonitor
44# ConfigFile: telecom_config.json
5- # Modify: 2024-05-11
5+ # Modify: 2025-07-08
66
77"""
88任务名称
2929CONFIG_DATA = {}
3030NOTIFYS = []
3131CONFIG_PATH = sys .argv [1 ] if len (sys .argv ) > 1 else "telecom_config.json"
32+ TELECOM_FLUX_PACKAGE = os .environ .get ("TELECOM_FLUX_PACKAGE" , "true" ).lower () != "false"
3233
3334
3435# 发送通知消息
@@ -167,26 +168,28 @@ def auto_login():
167168 CONFIG_DATA ["summary" ] = summary
168169
169170 # 获取流量包明细
170- flux_package_str = ""
171- user_flux_package = telecom .user_flux_package ()
172- if user_flux_package :
173- print ("获取流量包明细:成功" )
174- packages = user_flux_package ["responseData" ]["data" ]["productOFFRatable" ][
175- "ratableResourcePackages"
176- ]
177- for package in packages :
178- package_icon = (
179- "🇨🇳"
180- if "国内" in package ["title" ]
181- else "📺" if "专用" in package ["title" ] else "🌎"
182- )
183- flux_package_str += f"\n { package_icon } { package ['title' ]} \n "
184- for product in package ["productInfos" ]:
185- if product ["infiniteTitle" ]:
186- # 无限流量
187- flux_package_str += f"""🔹[{ product ['title' ]} ]{ product ['infiniteTitle' ]} { product ['infiniteValue' ]} { product ['infiniteUnit' ]} /无限\n """
188- else :
189- flux_package_str += f"""🔹[{ product ['title' ]} ]{ product ['leftTitle' ]} { product ['leftHighlight' ]} { product ['rightCommon' ]} \n """
171+ if TELECOM_FLUX_PACKAGE :
172+ flux_package_str = ""
173+ user_flux_package = telecom .user_flux_package ()
174+ if user_flux_package :
175+ print ("获取流量包明细:成功" )
176+ packages = user_flux_package ["responseData" ]["data" ]["productOFFRatable" ][
177+ "ratableResourcePackages"
178+ ]
179+ for package in packages :
180+ package_icon = (
181+ "🇨🇳"
182+ if "国内" in package ["title" ]
183+ else "📺" if "专用" in package ["title" ] else "🌎"
184+ )
185+ flux_package_str += f"\n { package_icon } { package ['title' ]} \n "
186+ for product in package ["productInfos" ]:
187+ if product ["infiniteTitle" ]:
188+ # 无限流量
189+ flux_package_str += f"""🔹[{ product ['title' ]} ]{ product ['infiniteTitle' ]} { product ['infiniteValue' ]} { product ['infiniteUnit' ]} /无限\n """
190+ else :
191+ flux_package_str += f"""🔹[{ product ['title' ]} ]{ product ['leftTitle' ]} { product ['leftHighlight' ]} { product ['rightCommon' ]} \n """
192+
190193 # 流量字符串
191194 common_str = (
192195 f"{ telecom .convert_flow (summary ['commonUse' ],'GB' ,2 )} / { telecom .convert_flow (summary ['commonTotal' ],'GB' ,2 )} GB"
@@ -211,7 +214,7 @@ def auto_login():
211214 - 通用:{ common_str } { f'{ chr (10 )} - 专用:{ special_str } ' if special_str else '' } """
212215
213216 # 流量包明细
214- if os . environ . get ( " TELECOM_FLUX_PACKAGE" , "true" ). lower () != "false" :
217+ if TELECOM_FLUX_PACKAGE :
215218 notify_str += f"\n \n 【流量包明细】\n \n { flux_package_str .strip ()} "
216219
217220 notify_str += f"\n \n 查询时间:{ summary ['createTime' ]} "
0 commit comments