@@ -68,8 +68,8 @@ async def rate_command(message: types.Message, bot=None):
68
68
# Get the URL from environment variable
69
69
url = settings .BOC_URL
70
70
71
- # Fetch exchange rate data directly with cache info
72
- data , is_cached , next_update = await fetch_and_parse_rate_data (url )
71
+ # Fetch exchange rate data directly
72
+ data = await fetch_and_parse_rate_data (url )
73
73
74
74
if not data or "currencies" not in data or not data ["currencies" ]:
75
75
await bot_to_use .send_message (
@@ -81,15 +81,9 @@ async def rate_command(message: types.Message, bot=None):
81
81
# Get the last updated time
82
82
last_updated = data .get ("last_updated" , "未知" )
83
83
84
- # Add cache status and next update time
85
- cache_status = "✅ 数据来源: 缓存" if is_cached else "🔄 数据来源: 实时获取"
86
- next_update_str = next_update .strftime ("%Y-%m-%d %H:%M:%S" )
87
-
88
84
# Start response with update time header including the timestamp
89
85
response_lines = [
90
- f"汇率更新时间\n { last_updated } \n " ,
91
- f"{ cache_status } " ,
92
- f"下次更新时间: { next_update_str } \n "
86
+ f"汇率更新时间\n { last_updated } \n "
93
87
]
94
88
95
89
# Get supported currencies and their Chinese names
@@ -160,31 +154,24 @@ async def convert_command(message: types.Message, bot=None):
160
154
)
161
155
return
162
156
163
- rate_info = await get_exchange_rate (from_currency , to_currency )
164
- rate , is_cached , next_update = rate_info
157
+ rate = await get_exchange_rate (from_currency , to_currency )
165
158
166
159
if rate :
167
160
# Get the last updated time
168
161
from app .services .exchange_rate import fetch_and_parse_rate_data
169
162
from app .core .config import settings
170
163
171
164
# Fetch data to get the update time
172
- data , _ , _ = await fetch_and_parse_rate_data (settings .BOC_URL )
165
+ data = await fetch_and_parse_rate_data (settings .BOC_URL )
173
166
last_updated = data .get ("last_updated" , "未知" )
174
167
175
- # Add cache status and next update time
176
- cache_status = "✅ 数据来源: 缓存" if is_cached else "🔄 数据来源: 实时获取"
177
- next_update_str = next_update .strftime ("%Y-%m-%d %H:%M:%S" )
178
-
179
168
converted_amount = amount * rate
180
169
await bot_to_use .send_message (
181
170
chat_id = message .chat .id ,
182
171
text = f"💱 货币转换结果:\n "
183
172
f"{ amount :.2f} { from_currency } = { converted_amount :.2f} { to_currency } \n "
184
173
f"(汇率: 1 { from_currency } = { rate :.4f} { to_currency } )\n \n "
185
- f"汇率更新时间\n { last_updated } \n "
186
- f"{ cache_status } \n "
187
- f"下次更新时间: { next_update_str } "
174
+ f"汇率更新时间\n { last_updated } "
188
175
)
189
176
else :
190
177
await bot_to_use .send_message (
@@ -230,20 +217,14 @@ async def currency_command(message: types.Message, bot=None):
230
217
from app .core .config import settings
231
218
232
219
# Fetch data to get the update time
233
- data , is_cached , next_update = await fetch_and_parse_rate_data (settings .BOC_URL )
220
+ data = await fetch_and_parse_rate_data (settings .BOC_URL )
234
221
last_updated = data .get ("last_updated" , "未知" )
235
222
236
- # Add cache status and next update time
237
- cache_status = "✅ 数据来源: 缓存" if is_cached else "🔄 数据来源: 实时获取"
238
- next_update_str = next_update .strftime ("%Y-%m-%d %H:%M:%S" )
239
-
240
223
await bot_to_use .send_message (
241
224
chat_id = message .chat .id ,
242
225
text = f"💰 支持的货币列表:\n { currency_list } \n \n "
243
226
f"使用 /rate 或 /convert 或 /cny_convert 获取汇率和转换货币。\n \n "
244
- f"汇率更新时间\n { last_updated } \n "
245
- f"{ cache_status } \n "
246
- f"下次更新时间: { next_update_str } "
227
+ f"汇率更新时间\n { last_updated } "
247
228
)
248
229
249
230
async def cny_convert_command (message : types .Message , bot = None ):
@@ -267,31 +248,24 @@ async def cny_convert_command(message: types.Message, bot=None):
267
248
amount = float (args [2 ])
268
249
to_currency = "CNY"
269
250
270
- rate_info = await get_exchange_rate (from_currency , to_currency )
271
- rate , is_cached , next_update = rate_info
251
+ rate = await get_exchange_rate (from_currency , to_currency )
272
252
273
253
if rate :
274
254
# Get the last updated time
275
255
from app .services .exchange_rate import fetch_and_parse_rate_data
276
256
from app .core .config import settings
277
257
278
258
# Fetch data to get the update time
279
- data , _ , _ = await fetch_and_parse_rate_data (settings .BOC_URL )
259
+ data = await fetch_and_parse_rate_data (settings .BOC_URL )
280
260
last_updated = data .get ("last_updated" , "未知" )
281
261
282
- # Add cache status and next update time
283
- cache_status = "✅ 数据来源: 缓存" if is_cached else "🔄 数据来源: 实时获取"
284
- next_update_str = next_update .strftime ("%Y-%m-%d %H:%M:%S" )
285
-
286
262
converted_amount = amount * rate
287
263
await bot_to_use .send_message (
288
264
chat_id = message .chat .id ,
289
265
text = f"💱 转换为人民币结果:\n "
290
266
f"{ amount :.2f} { from_currency } = { converted_amount :.2f} { to_currency } \n "
291
267
f"(汇率: 1 { from_currency } = { rate :.4f} { to_currency } )\n \n "
292
- f"汇率更新时间\n { last_updated } \n "
293
- f"{ cache_status } \n "
294
- f"下次更新时间: { next_update_str } "
268
+ f"汇率更新时间\n { last_updated } "
295
269
)
296
270
else :
297
271
await bot_to_use .send_message (
0 commit comments