XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/gpt4free

Improce check key

526292c4
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

1 个文件 +5 -1
Modified g4f/api/__init__.py +5 -1
@@ -250,10 +250,14 @@ class Api:
250 250 data = json.loads(decrypt_data(session_key, user_g4f_api_key))
251 251 expires = int(decrypt_data(private_key, data["data"])) + 86400
252 252 user = data.get("user", user)
253 if not user:
254 raise ValueError("User not found")
253 255 except:
254 256 return ErrorResponse.from_message(f"Invalid G4F API key", HTTP_401_UNAUTHORIZED)
255 257 expires = int(expires) - int(time.time())
256 debug.log(f"User: '{user}' G4F API key expires in {expires} seconds")
258 hours, remainder = divmod(expires, 3600)
259 minutes, seconds = divmod(remainder, 60)
260 debug.log(f"User: '{user}' G4F API key expires in {hours}h {minutes}m {seconds}s")
257 261 if expires < 0:
258 262 return ErrorResponse.from_message("G4F API key expired", HTTP_401_UNAUTHORIZED)
259 263 else: