nonebot-plugin-morep-finder


Namenonebot-plugin-morep-finder JSON
Version 1.0.0 PyPI version JSON
download
home_page
SummaryNonebot2 plugin. (only for kaheila adaptor)
upload_time2023-10-08 15:37:08
maintainer
docs_urlNone
author
requires_python>=3.8
licenseGPL-3.0-only
keywords nonebot2 kook kaiheila
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
<div align="center">

# nonebot-plugin-morep-finder

_✨ Extend from [op finder](https://github.com/ninthseason/nonebot-plugin-morep-finder) ✨_

<a href="./LICENSE">
    <img src="https://img.shields.io/github/license/ninthseason/nonebot-plugin-morep-finder" alt="license">
</a>
<a href="https://pypi.python.org/pypi/nonebot-plugin-morep-finder">
    <img src="https://img.shields.io/pypi/v/nonebot-plugin-morep-finder.svg" alt="pypi">
</a>
<img src="https://img.shields.io/badge/python-3.8+-blue.svg" alt="python">

</div>

## 📖 介绍

显示服务器中当前正在玩指定游戏的玩家,效果图见下文。

## 💿 安装

<details open>
<summary>使用 nb-cli 安装</summary>
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装

    nb plugin install nonebot-plugin-morep-finder

</details>

<details>
<summary>使用包管理器安装</summary>
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令

<details>
<summary>pip</summary>

    pip install nonebot-plugin-morep-finder
</details>
<details>
<summary>pdm</summary>

    pdm add nonebot-plugin-morep-finder
</details>
<details>
<summary>poetry</summary>

    poetry add nonebot-plugin-morep-finder
</details>
<details>
<summary>conda</summary>

    conda install nonebot-plugin-morep-finder
</details>

打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分追加写入

    plugins = ["nonebot_plugin_morep_finder"]

</details>

## ⚙️ 配置

kaiheila adaptor 相关配置请见[kaiheila adaptor 使用指南](https://github.com/Tian-que/nonebot-adapter-kaiheila/blob/master/MANUAL.md)

本插件需要在 nonebot2 项目的`.env`文件中添加下表中的配置

|      配置项      | 必填 | 默认值 |        说明         |
|:-------------:|:----:|:---:|:-----------------:|
| kook_auth_key | 是 |  无  | 自己账号的kook鉴权cookie |
| morep_config  | 是 | [] |    插件配置(详见下文)     |

1. kook_auth_key

   因为目前KOOK v3 api中没有获得玩家在玩状态的接口,本插件通过v2 api获取玩家在玩状态。
   
   由于v2 api不受官方支持,需要手动抓包获取一个账号的鉴权cookie,用以调用api。

   1. 登录网页版KOOK,随便进入一个服务器,打开浏览器控制台
   2. 控制台切换到Network(网络)选项卡
   3. KOOK中随意点击一个用户的头像,打开资料面板
   4. 此时Network选项卡中应会抓到若干请求,随意选择一个v2api的请求查看,如 `https://www.kookapp.cn/api/v2/users/<用户id>?guild_id=<服务器id>`
   5. 查看请求的Headers选项卡中的Request Headers(请求头),找到Cookie键,形如
   
      ```
      Cookie: auth=<kook_auth_key>; PHPSESSID=<something>; _csrf_chuanyu=<something>
      ```

   6. 其中<kook_auth_key>即为我们需要的配置项

   > **此实在是不得已而为之的下策,若v3 api有获取在玩状态的方法,或更方便获取v2 api auth key的方法,敬请告知。**

2. morep_config
   
   一个**元素为字典**的**列表**,字典格式为:
   ```json
   {
        "name": "对此类玩家的称呼",
        "color": "称呼颜色",
        "game": ["游戏名称1", "游戏名称2", ...],
        "command": ["触发指令1", "触发指令2", ...]
   }
   ```
   
   例如下面的字典:
   ```json
   {
        "name": "塔批",
        "color": "warning",
        "game": ["逃离塔科夫", "逃离唐科夫", "进入孤儿院", "逃离提瓦特大陆"],
        "command": ["tkf", "tp", "寻找塔批"]
   }
   ```
   机器人在收到`tkf | tp | 寻找塔批`指令时,会列出服务器中所有在玩状态为`"逃离塔科夫" | "逃离唐科夫" | "进入孤儿院" | "逃离提瓦特大陆"`的玩家。
3. color目前已知的可选值为primary, success, danger, warning, info, secondary, body, tips, pink, purple

一个morep_config示例:
```python
morep_config = [{"name": "原批","color": "purple","game": ["原神"],"command": ["op", "寻找原批", "查找原批", "原批"]},{"name": "塔批","color": "warning","game": ["逃离塔科夫", "逃离唐科夫", "进入孤儿院", "逃离提瓦特大陆"],"command": ["tkf", "tp", "寻找塔批", "查找塔批", "塔批"]},{"name": "瓦批","color": "pink","game": ["瓦洛兰特", "无畏契约"],"command": ["wp", "瓦批", "瓦洛兰特", "无畏契约"]}, {"name": "穹批", "color": "purple", "game": ["崩坏:星穹铁道", "崩坏: 星穹铁道", "星穹铁道"], "command": ["qp", "穹批", "寻找穹批", "查找穹批"]}]
```
> 注意:为保证正常解析,请将morep_config保持在一行内,不要换行
## 🎉 使用
### 指令表
|         指令         | 权限 | 需要@ | 范围 | 说明 |
|:------------------:|:----:|:----:|:----:|:----:|
| 在morep_config中指定 | 所有人 | 否 | 群聊 | 触发插件 |


### 效果图
![](./rendering.png)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "nonebot-plugin-morep-finder",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "nonebot2,kook,kaiheila",
    "author": "",
    "author_email": "Kl1nge5 <ninthseason@qq.com>",
    "download_url": "https://files.pythonhosted.org/packages/db/2c/59b39625bfe77832b0246a0e744c0a9f52cfec8e41da52bdc49e4c7892dd/nonebot-plugin-morep-finder-1.0.0.tar.gz",
    "platform": null,
    "description": "\n<div align=\"center\">\n\n# nonebot-plugin-morep-finder\n\n_\u2728 Extend from [op finder](https://github.com/ninthseason/nonebot-plugin-morep-finder) \u2728_\n\n<a href=\"./LICENSE\">\n    <img src=\"https://img.shields.io/github/license/ninthseason/nonebot-plugin-morep-finder\" alt=\"license\">\n</a>\n<a href=\"https://pypi.python.org/pypi/nonebot-plugin-morep-finder\">\n    <img src=\"https://img.shields.io/pypi/v/nonebot-plugin-morep-finder.svg\" alt=\"pypi\">\n</a>\n<img src=\"https://img.shields.io/badge/python-3.8+-blue.svg\" alt=\"python\">\n\n</div>\n\n## \ud83d\udcd6 \u4ecb\u7ecd\n\n\u663e\u793a\u670d\u52a1\u5668\u4e2d\u5f53\u524d\u6b63\u5728\u73a9\u6307\u5b9a\u6e38\u620f\u7684\u73a9\u5bb6\uff0c\u6548\u679c\u56fe\u89c1\u4e0b\u6587\u3002\n\n## \ud83d\udcbf \u5b89\u88c5\n\n<details open>\n<summary>\u4f7f\u7528 nb-cli \u5b89\u88c5</summary>\n\u5728 nonebot2 \u9879\u76ee\u7684\u6839\u76ee\u5f55\u4e0b\u6253\u5f00\u547d\u4ee4\u884c, \u8f93\u5165\u4ee5\u4e0b\u6307\u4ee4\u5373\u53ef\u5b89\u88c5\n\n    nb plugin install nonebot-plugin-morep-finder\n\n</details>\n\n<details>\n<summary>\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5b89\u88c5</summary>\n\u5728 nonebot2 \u9879\u76ee\u7684\u63d2\u4ef6\u76ee\u5f55\u4e0b, \u6253\u5f00\u547d\u4ee4\u884c, \u6839\u636e\u4f60\u4f7f\u7528\u7684\u5305\u7ba1\u7406\u5668, \u8f93\u5165\u76f8\u5e94\u7684\u5b89\u88c5\u547d\u4ee4\n\n<details>\n<summary>pip</summary>\n\n    pip install nonebot-plugin-morep-finder\n</details>\n<details>\n<summary>pdm</summary>\n\n    pdm add nonebot-plugin-morep-finder\n</details>\n<details>\n<summary>poetry</summary>\n\n    poetry add nonebot-plugin-morep-finder\n</details>\n<details>\n<summary>conda</summary>\n\n    conda install nonebot-plugin-morep-finder\n</details>\n\n\u6253\u5f00 nonebot2 \u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u7684 `pyproject.toml` \u6587\u4ef6, \u5728 `[tool.nonebot]` \u90e8\u5206\u8ffd\u52a0\u5199\u5165\n\n    plugins = [\"nonebot_plugin_morep_finder\"]\n\n</details>\n\n## \u2699\ufe0f \u914d\u7f6e\n\nkaiheila adaptor \u76f8\u5173\u914d\u7f6e\u8bf7\u89c1[kaiheila adaptor \u4f7f\u7528\u6307\u5357](https://github.com/Tian-que/nonebot-adapter-kaiheila/blob/master/MANUAL.md)\n\n\u672c\u63d2\u4ef6\u9700\u8981\u5728 nonebot2 \u9879\u76ee\u7684`.env`\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e0b\u8868\u4e2d\u7684\u914d\u7f6e\n\n|      \u914d\u7f6e\u9879      | \u5fc5\u586b | \u9ed8\u8ba4\u503c |        \u8bf4\u660e         |\n|:-------------:|:----:|:---:|:-----------------:|\n| kook_auth_key | \u662f |  \u65e0  | \u81ea\u5df1\u8d26\u53f7\u7684kook\u9274\u6743cookie |\n| morep_config  | \u662f | [] |    \u63d2\u4ef6\u914d\u7f6e\uff08\u8be6\u89c1\u4e0b\u6587\uff09     |\n\n1. kook_auth_key\n\n   \u56e0\u4e3a\u76ee\u524dKOOK v3 api\u4e2d\u6ca1\u6709\u83b7\u5f97\u73a9\u5bb6\u5728\u73a9\u72b6\u6001\u7684\u63a5\u53e3\uff0c\u672c\u63d2\u4ef6\u901a\u8fc7v2 api\u83b7\u53d6\u73a9\u5bb6\u5728\u73a9\u72b6\u6001\u3002\n   \n   \u7531\u4e8ev2 api\u4e0d\u53d7\u5b98\u65b9\u652f\u6301\uff0c\u9700\u8981\u624b\u52a8\u6293\u5305\u83b7\u53d6\u4e00\u4e2a\u8d26\u53f7\u7684\u9274\u6743cookie\uff0c\u7528\u4ee5\u8c03\u7528api\u3002\n\n   1. \u767b\u5f55\u7f51\u9875\u7248KOOK\uff0c\u968f\u4fbf\u8fdb\u5165\u4e00\u4e2a\u670d\u52a1\u5668\uff0c\u6253\u5f00\u6d4f\u89c8\u5668\u63a7\u5236\u53f0\n   2. \u63a7\u5236\u53f0\u5207\u6362\u5230Network(\u7f51\u7edc)\u9009\u9879\u5361\n   3. KOOK\u4e2d\u968f\u610f\u70b9\u51fb\u4e00\u4e2a\u7528\u6237\u7684\u5934\u50cf\uff0c\u6253\u5f00\u8d44\u6599\u9762\u677f\n   4. \u6b64\u65f6Network\u9009\u9879\u5361\u4e2d\u5e94\u4f1a\u6293\u5230\u82e5\u5e72\u8bf7\u6c42\uff0c\u968f\u610f\u9009\u62e9\u4e00\u4e2av2api\u7684\u8bf7\u6c42\u67e5\u770b\uff0c\u5982 `https://www.kookapp.cn/api/v2/users/<\u7528\u6237id>?guild_id=<\u670d\u52a1\u5668id>`\n   5. \u67e5\u770b\u8bf7\u6c42\u7684Headers\u9009\u9879\u5361\u4e2d\u7684Request Headers(\u8bf7\u6c42\u5934)\uff0c\u627e\u5230Cookie\u952e\uff0c\u5f62\u5982\n   \n      ```\n      Cookie: auth=<kook_auth_key>; PHPSESSID=<something>; _csrf_chuanyu=<something>\n      ```\n\n   6. \u5176\u4e2d<kook_auth_key>\u5373\u4e3a\u6211\u4eec\u9700\u8981\u7684\u914d\u7f6e\u9879\n\n   > **\u6b64\u5b9e\u5728\u662f\u4e0d\u5f97\u5df2\u800c\u4e3a\u4e4b\u7684\u4e0b\u7b56\uff0c\u82e5v3 api\u6709\u83b7\u53d6\u5728\u73a9\u72b6\u6001\u7684\u65b9\u6cd5\uff0c\u6216\u66f4\u65b9\u4fbf\u83b7\u53d6v2 api auth key\u7684\u65b9\u6cd5\uff0c\u656c\u8bf7\u544a\u77e5\u3002**\n\n2. morep_config\n   \n   \u4e00\u4e2a**\u5143\u7d20\u4e3a\u5b57\u5178**\u7684**\u5217\u8868**\uff0c\u5b57\u5178\u683c\u5f0f\u4e3a:\n   ```json\n   {\n        \"name\": \"\u5bf9\u6b64\u7c7b\u73a9\u5bb6\u7684\u79f0\u547c\",\n        \"color\": \"\u79f0\u547c\u989c\u8272\",\n        \"game\": [\"\u6e38\u620f\u540d\u79f01\", \"\u6e38\u620f\u540d\u79f02\", ...],\n        \"command\": [\"\u89e6\u53d1\u6307\u4ee41\", \"\u89e6\u53d1\u6307\u4ee42\", ...]\n   }\n   ```\n   \n   \u4f8b\u5982\u4e0b\u9762\u7684\u5b57\u5178:\n   ```json\n   {\n        \"name\": \"\u5854\u6279\",\n        \"color\": \"warning\",\n        \"game\": [\"\u9003\u79bb\u5854\u79d1\u592b\", \"\u9003\u79bb\u5510\u79d1\u592b\", \"\u8fdb\u5165\u5b64\u513f\u9662\", \"\u9003\u79bb\u63d0\u74e6\u7279\u5927\u9646\"],\n        \"command\": [\"tkf\", \"tp\", \"\u5bfb\u627e\u5854\u6279\"]\n   }\n   ```\n   \u673a\u5668\u4eba\u5728\u6536\u5230`tkf | tp | \u5bfb\u627e\u5854\u6279`\u6307\u4ee4\u65f6\uff0c\u4f1a\u5217\u51fa\u670d\u52a1\u5668\u4e2d\u6240\u6709\u5728\u73a9\u72b6\u6001\u4e3a`\"\u9003\u79bb\u5854\u79d1\u592b\" | \"\u9003\u79bb\u5510\u79d1\u592b\" | \"\u8fdb\u5165\u5b64\u513f\u9662\" | \"\u9003\u79bb\u63d0\u74e6\u7279\u5927\u9646\"`\u7684\u73a9\u5bb6\u3002\n3. color\u76ee\u524d\u5df2\u77e5\u7684\u53ef\u9009\u503c\u4e3aprimary, success, danger, warning, info, secondary, body, tips, pink, purple\n\n\u4e00\u4e2amorep_config\u793a\u4f8b\uff1a\n```python\nmorep_config = [{\"name\": \"\u539f\u6279\",\"color\": \"purple\",\"game\": [\"\u539f\u795e\"],\"command\": [\"op\", \"\u5bfb\u627e\u539f\u6279\", \"\u67e5\u627e\u539f\u6279\", \"\u539f\u6279\"]},{\"name\": \"\u5854\u6279\",\"color\": \"warning\",\"game\": [\"\u9003\u79bb\u5854\u79d1\u592b\", \"\u9003\u79bb\u5510\u79d1\u592b\", \"\u8fdb\u5165\u5b64\u513f\u9662\", \"\u9003\u79bb\u63d0\u74e6\u7279\u5927\u9646\"],\"command\": [\"tkf\", \"tp\", \"\u5bfb\u627e\u5854\u6279\", \"\u67e5\u627e\u5854\u6279\", \"\u5854\u6279\"]},{\"name\": \"\u74e6\u6279\",\"color\": \"pink\",\"game\": [\"\u74e6\u6d1b\u5170\u7279\", \"\u65e0\u754f\u5951\u7ea6\"],\"command\": [\"wp\", \"\u74e6\u6279\", \"\u74e6\u6d1b\u5170\u7279\", \"\u65e0\u754f\u5951\u7ea6\"]}, {\"name\": \"\u7a79\u6279\", \"color\": \"purple\", \"game\": [\"\u5d29\u574f\uff1a\u661f\u7a79\u94c1\u9053\", \"\u5d29\u574f: \u661f\u7a79\u94c1\u9053\", \"\u661f\u7a79\u94c1\u9053\"], \"command\": [\"qp\", \"\u7a79\u6279\", \"\u5bfb\u627e\u7a79\u6279\", \"\u67e5\u627e\u7a79\u6279\"]}]\n```\n> \u6ce8\u610f\uff1a\u4e3a\u4fdd\u8bc1\u6b63\u5e38\u89e3\u6790\uff0c\u8bf7\u5c06morep_config\u4fdd\u6301\u5728\u4e00\u884c\u5185\uff0c\u4e0d\u8981\u6362\u884c\n## \ud83c\udf89 \u4f7f\u7528\n### \u6307\u4ee4\u8868\n|         \u6307\u4ee4         | \u6743\u9650 | \u9700\u8981@ | \u8303\u56f4 | \u8bf4\u660e |\n|:------------------:|:----:|:----:|:----:|:----:|\n| \u5728morep_config\u4e2d\u6307\u5b9a | \u6240\u6709\u4eba | \u5426 | \u7fa4\u804a | \u89e6\u53d1\u63d2\u4ef6 |\n\n\n### \u6548\u679c\u56fe\n![](./rendering.png)\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-only",
    "summary": "Nonebot2 plugin. (only for kaheila adaptor)",
    "version": "1.0.0",
    "project_urls": null,
    "split_keywords": [
        "nonebot2",
        "kook",
        "kaiheila"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7f917a270b1f8cd29d38b36be68698d25ab3d1a8b39ae8e3f3a59bd6232eafdd",
                "md5": "bfe1d7c3e940f41586c6a856f0bf658f",
                "sha256": "7052e3a43895f8b396a8a59bb9df90569acd9c859750d764f0a2114753595d25"
            },
            "downloads": -1,
            "filename": "nonebot_plugin_morep_finder-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bfe1d7c3e940f41586c6a856f0bf658f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 19335,
            "upload_time": "2023-10-08T15:37:06",
            "upload_time_iso_8601": "2023-10-08T15:37:06.959012Z",
            "url": "https://files.pythonhosted.org/packages/7f/91/7a270b1f8cd29d38b36be68698d25ab3d1a8b39ae8e3f3a59bd6232eafdd/nonebot_plugin_morep_finder-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "db2c59b39625bfe77832b0246a0e744c0a9f52cfec8e41da52bdc49e4c7892dd",
                "md5": "cf7c02913893622c62f83018dfcb7cae",
                "sha256": "95c0f7fc983cbc4a80d4c787aa3875efdff9313489a506b0b79fe521b10a8108"
            },
            "downloads": -1,
            "filename": "nonebot-plugin-morep-finder-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "cf7c02913893622c62f83018dfcb7cae",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 412703,
            "upload_time": "2023-10-08T15:37:08",
            "upload_time_iso_8601": "2023-10-08T15:37:08.753094Z",
            "url": "https://files.pythonhosted.org/packages/db/2c/59b39625bfe77832b0246a0e744c0a9f52cfec8e41da52bdc49e4c7892dd/nonebot-plugin-morep-finder-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-08 15:37:08",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "nonebot-plugin-morep-finder"
}
        
Elapsed time: 0.14242s