From 8a86cf154ce362dd3ce532f1c7dc4162cd35c71f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A9=E6=9A=97?= Date: Fri, 13 Dec 2024 12:51:13 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20=E4=BC=98=E5=8C=96=20DING?= =?UTF-8?q?TALK=5FOPENAPI=5FENDPOINT=20=E5=8F=98=E9=87=8F,=20=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E8=AE=BE=E7=BD=AE=E4=BA=86=20DINGTALK=5FOPENAPI=5FEND?= =?UTF-8?q?POINT=20=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=20chatbox=20=E5=92=8C=20card=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E6=B6=88=E8=B4=B9=E5=88=B0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dingtalk_stream/card_replier.py | 2 +- dingtalk_stream/stream.py | 6 +++--- dingtalk_stream/utils.py | 9 +++------ dingtalk_stream/version.py | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/dingtalk_stream/card_replier.py b/dingtalk_stream/card_replier.py index d33eb61..1f95094 100644 --- a/dingtalk_stream/card_replier.py +++ b/dingtalk_stream/card_replier.py @@ -686,7 +686,7 @@ def finish(self, card_instance_id: str, card_data: dict): card_data_with_status["flowStatus"] = AICardStatus.FINISHED self.put_card_data(card_instance_id, card_data_with_status) - async def finish(self, card_instance_id: str, card_data: dict): + async def async_finish(self, card_instance_id: str, card_data: dict): """ AI卡片执行完成的接口,整体更新 :param card_instance_id: diff --git a/dingtalk_stream/stream.py b/dingtalk_stream/stream.py index e8fddc9..58306d4 100644 --- a/dingtalk_stream/stream.py +++ b/dingtalk_stream/stream.py @@ -22,12 +22,12 @@ from .frames import EventMessage from .frames import CallbackMessage from .log import setup_default_logger -from .utils import get_dingtalk_endpoint +from .utils import DINGTALK_OPENAPI_ENDPOINT from .version import VERSION_STRING class DingTalkStreamClient(object): - OPEN_CONNECTION_API = get_dingtalk_endpoint() + '/v1.0/gateway/connections/open' + OPEN_CONNECTION_API = DINGTALK_OPENAPI_ENDPOINT + '/v1.0/gateway/connections/open' TAG_DISCONNECT = 'disconnect' def __init__(self, credential: Credential, logger: logging.Logger = None): @@ -198,7 +198,7 @@ def get_access_token(self): 'appSecret': self.credential.client_secret, } try: - url = get_dingtalk_endpoint() + '/v1.0/oauth2/accessToken' + url = DINGTALK_OPENAPI_ENDPOINT + '/v1.0/oauth2/accessToken' response_text = '' response = requests.post(url, headers=request_headers, diff --git a/dingtalk_stream/utils.py b/dingtalk_stream/utils.py index 82bcdd4..e7e3935 100644 --- a/dingtalk_stream/utils.py +++ b/dingtalk_stream/utils.py @@ -2,10 +2,7 @@ import os -DINGTALK_OPENAPI_ENDPOINT = "https://api.dingtalk.com" +DINGTALK_OPENAPI_ENDPOINT = os.getenv( + "DINGTALK_OPENAPI_ENDPOINT", "https://api.dingtalk.com" +) -def get_dingtalk_endpoint(): - endpoint_env = os.getenv('DINGTALK_OPENAPI_ENDPOINT') - if endpoint_env: - return endpoint_env - return DINGTALK_OPENAPI_ENDPOINT diff --git a/dingtalk_stream/version.py b/dingtalk_stream/version.py index 9524922..804fead 100644 --- a/dingtalk_stream/version.py +++ b/dingtalk_stream/version.py @@ -1 +1 @@ -VERSION_STRING = '0.22.0' +VERSION_STRING = '0.22.1'