From 18c6bea4517bc86f6f4d82cc929a210697eb7650 Mon Sep 17 00:00:00 2001 From: mri-moe <87687313+mri-moe@users.noreply.github.com> Date: Sat, 14 Aug 2021 13:04:15 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20add=20switcher=20for=20lar?= =?UTF-8?q?k?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/api/adapters/feishu.md | 3 +++ packages/nonebot-adapter-feishu/nonebot/adapters/feishu/bot.py | 3 +++ .../nonebot-adapter-feishu/nonebot/adapters/feishu/config.py | 3 +++ 3 files changed, 9 insertions(+) diff --git a/docs/api/adapters/feishu.md b/docs/api/adapters/feishu.md index 0da2dc15..0e618f18 100644 --- a/docs/api/adapters/feishu.md +++ b/docs/api/adapters/feishu.md @@ -31,6 +31,9 @@ sidebarDepth: 0 * `tenant_access_token` / `feishu_tenant_access_token`: 请求飞书 API 后返回的租户密钥 + * `reigon` / `feishu_or_lark`: 设置后端使用飞书服务器还是Lark服务器 + + # NoneBot.adapters.feishu.exception 模块 diff --git a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/bot.py b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/bot.py index d513fb8c..6b527c09 100644 --- a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/bot.py +++ b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/bot.py @@ -136,6 +136,9 @@ class Bot(BaseBot): @property def api_root(self) -> str: + if self.feishu_config.region == "Lark" : + return "https://open.larksuite.com/open-apis/" + else: return "https://open.feishu.cn/open-apis/" @classmethod diff --git a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/config.py b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/config.py index 853f553e..07843d2b 100644 --- a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/config.py +++ b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/config.py @@ -14,6 +14,8 @@ class Config(BaseModel): - ``encrypt_key`` / ``feishu_encrypt_key``: 飞书开放平台后台“事件订阅”处设置的 Encrypt Key - ``verification_token`` / ``feishu_verification_token``: 飞书开放平台后台“事件订阅”处设置的 Verification Token - ``tenant_access_token`` / ``feishu_tenant_access_token``: 请求飞书 API 后返回的租户密钥 + - ``region`` / ``feishu_or_lark``: 选择飞书服务器还是Lark服务器,如留空则默认为飞书服务器 + """ app_id: Optional[str] = Field(default=None, alias="feishu_app_id") app_secret: Optional[str] = Field(default=None, alias="feishu_app_secret") @@ -22,6 +24,7 @@ class Config(BaseModel): alias="feishu_verification_token") tenant_access_token: Optional[str] = Field( default=None, alias="feishu_tenant_access_token") + region: Optional[str] = Field(default=None, alias="feishu_or_lark") class Config: extra = "ignore"