-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
460a3e7
commit 127e4c2
Showing
14 changed files
with
2,322 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
110 changes: 110 additions & 0 deletions
110
website/versioned_docs/version-2.0.0-beta.1/api/adapter.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# nonebot.adapters.feishu.adapter | ||
|
||
## _class_ `Adapter(driver, **kwargs)` {#Adapter} | ||
|
||
- **参数** | ||
|
||
- `driver` (nonebot.internal.driver.driver.Driver) | ||
|
||
- `**kwargs` (Any) | ||
|
||
### _property_ `api_root` {#Adapter-api_root} | ||
|
||
- **类型:** str | ||
|
||
### _class-var_ `event_models` {#Adapter-event_models} | ||
|
||
- **类型:** pygtrie.StringTrie | ||
|
||
- **说明:** 所有事件模型索引 | ||
|
||
### _classmethod_ `add_custom_model(cls, model)` {#Adapter-add_custom_model} | ||
|
||
- **说明** | ||
|
||
插入或覆盖一个自定义的 Event 类型。 | ||
需提供 `__event__` 属性,进行事件模型索引, | ||
格式为 `{post_type}[.{sub_type}]`,如: `message.private`。 | ||
|
||
- **参数** | ||
|
||
- `model` (Type[[Event](./event.md#Event)]): 自定义的 Event 类型 | ||
|
||
- **返回** | ||
|
||
- None | ||
|
||
### _classmethod_ `custom_send(cls, send_func)` {#Adapter-custom_send} | ||
|
||
- **说明** | ||
|
||
自定义 Bot 的回复函数。 | ||
|
||
- **参数** | ||
|
||
- `send_func` (([Bot](./bot.md#Bot), [Event](./event.md#Event), str | [Message](./message.md#Message) | [MessageSegment](./message.md#MessageSegment)) -> Any) | ||
|
||
- **返回** | ||
|
||
- Unknown | ||
|
||
### _classmethod_ `get_event_model(cls, event_name)` {#Adapter-get_event_model} | ||
|
||
- **说明** | ||
|
||
根据事件名获取对应 `Event Model` 及 `FallBack Event Model` 列表,不包括基类 `Event`。 | ||
|
||
- **参数** | ||
|
||
- `event_name` (str) | ||
|
||
- **返回** | ||
|
||
- list[Type[[Event](./event.md#Event)]] | ||
|
||
### _classmethod_ `get_name(cls)` {#Adapter-get_name} | ||
|
||
- **说明** | ||
|
||
适配器名称: `Feishu` | ||
|
||
- **返回** | ||
|
||
- str | ||
|
||
### _classmethod_ `json_to_event(cls, json_data)` {#Adapter-json_to_event} | ||
|
||
- **说明** | ||
|
||
将 json 数据转换为 Event 对象。 | ||
|
||
- **参数** | ||
|
||
- `json_data` (Any): json 数据 | ||
|
||
- `self_id`: 当前 Event 对应的 Bot | ||
|
||
- **返回** | ||
|
||
- [Event](./event.md#Event) | None: Event 对象,如果解析失败则返回 None | ||
|
||
### _method_ `model(_func=None, *, pre=False, allow_reuse=False, skip_on_failure=False)` {#Adapter-model} | ||
|
||
- **说明** | ||
|
||
Decorate methods on a model indicating that they should be used to validate (and perhaps modify) data either | ||
before or after standard model parsing/validation is performed. | ||
|
||
- **参数** | ||
|
||
- `_func` ((\*Any, \*\*Any) -> Any | None) | ||
|
||
- `pre` (bool) | ||
|
||
- `allow_reuse` (bool) | ||
|
||
- `skip_on_failure` (bool) | ||
|
||
- **返回** | ||
|
||
- AnyClassMethod | ((\*Any, \*\*Any) -> Any) -> AnyClassMethod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# nonebot.adapters.feishu.bot | ||
|
||
## _async def_ `send(bot, event, message, at_sender=False, **kwargs)` {#send} | ||
|
||
- **说明** | ||
|
||
默认回复消息处理函数。 | ||
|
||
- **参数** | ||
|
||
- `bot` (Bot) | ||
|
||
- `event` ([Event](./event.md#Event)) | ||
|
||
- `message` (str | [Message](./message.md#Message) | [MessageSegment](./message.md#MessageSegment)) | ||
|
||
- `at_sender` (bool) | ||
|
||
- `**kwargs` (Any) | ||
|
||
- **返回** | ||
|
||
- Any | ||
|
||
## _class_ `Bot(adapter, self_id)` {#Bot} | ||
|
||
- **说明** | ||
|
||
飞书 协议 Bot 适配。继承属性参考 `BaseBot <./#class-basebot>`\_ 。 | ||
|
||
- **参数** | ||
|
||
- `adapter` (Adapter) | ||
|
||
- `self_id` (str) | ||
|
||
### _property_ `type` {#Bot-type} | ||
|
||
- **类型:** str | ||
|
||
### _async method_ `call_api(self, api, **data)` {#Bot-call_api} | ||
|
||
- **说明** | ||
|
||
:说明: | ||
调用 OneBot 协议 API | ||
:参数: | ||
|
||
- `api: str`: API 名称 | ||
- `**data: Any`: API 参数 | ||
:返回: | ||
|
||
* `Any`: API 调用返回数据 | ||
:异常: | ||
* `NetworkError`: 网络错误 | ||
* `ActionFailed`: API 调用失败 | ||
|
||
- **参数** | ||
|
||
- `api` (str) | ||
|
||
- `**data` | ||
|
||
- **返回** | ||
|
||
- Any | ||
|
||
### _async method_ `handle_event(self, event)` {#Bot-handle_event} | ||
|
||
- **参数** | ||
|
||
- `event` ([Event](./event.md#Event)) | ||
|
||
- **返回** | ||
|
||
- None | ||
|
||
### _async method_ `send(self, event, message, **kwargs)` {#Bot-send} | ||
|
||
- **说明** | ||
|
||
根据 `event` 向触发事件的主体回复消息。 | ||
|
||
- **参数** | ||
|
||
- `event` ([Event](./event.md#Event)): Event 对象 | ||
|
||
- `message` (str | [Message](./message.md#Message) | [MessageSegment](./message.md#MessageSegment)): 要发送的消息 | ||
|
||
- `**kwargs` (Any): 其他参数,可以与 [Adapter.custom_send](./adapter.md#Adapter-custom_send) 配合使用 | ||
|
||
- `at_sender` (bool): 是否 @ 事件主体 | ||
|
||
- **返回** | ||
|
||
- Any: API 调用返回数据 | ||
|
||
- **异常** | ||
|
||
- `ValueError`: 缺少 `user_id`, `group_id` | ||
|
||
- `NetworkError`: 网络错误 | ||
|
||
- `ActionFailed`: API 调用失败 | ||
|
||
### _async method_ `send_handler(bot, event, message, at_sender=False, **kwargs)` {#Bot-send_handler} | ||
|
||
- **说明** | ||
|
||
默认回复消息处理函数。 | ||
|
||
- **参数** | ||
|
||
- `bot` (Bot) | ||
|
||
- `event` ([Event](./event.md#Event)) | ||
|
||
- `message` (str | [Message](./message.md#Message) | [MessageSegment](./message.md#MessageSegment)) | ||
|
||
- `at_sender` (bool) | ||
|
||
- `**kwargs` (Any) | ||
|
||
- **返回** | ||
|
||
- Any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# nonebot.adapters.feishu.config | ||
|
||
## _class_ `Config(*, feishu_app_id=None, feishu_app_secret=None, feishu_encrypt_key=None, feishu_verification_token=None, feishu_is_lark=False)` {#Config} | ||
|
||
- **说明** | ||
|
||
飞书配置类 | ||
|
||
:配置项: | ||
|
||
- `feishu_app_id`: 飞书开放平台后台“凭证与基础信息”处给出的 App ID | ||
- `feishu_app_secret`: 飞书开放平台后台“凭证与基础信息”处给出的 App Secret | ||
- `feishu_encrypt_key`: 飞书开放平台后台“事件订阅”处设置的 Encrypt Key | ||
- `feishu_verification_token`: 飞书开放平台后台“事件订阅”处设置的 Verification Token | ||
- `feishu_is_lark`: 是否使用 Lark(飞书海外版),默认为 false | ||
|
||
- **参数** | ||
|
||
- `feishu_app_id` (str) | ||
|
||
- `feishu_app_secret` (str) | ||
|
||
- `feishu_encrypt_key` (str) | ||
|
||
- `feishu_verification_token` (str) | ||
|
||
- `feishu_is_lark` (str) |
Oops, something went wrong.