nonebot-plugin-sudo


Namenonebot-plugin-sudo JSON
Version 1.0.6 PyPI version JSON
download
home_page
SummaryXDbot2 SUDO 插件独立版
upload_time2023-09-08 14:15:09
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT-License
keywords nonebot2 onebot
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
  <a href="https://v2.nonebot.dev/store"><img src="https://github.com/A-kirami/nonebot-plugin-template/blob/resources/nbp_logo.png" width="180" height="180" alt="NoneBotPluginLogo"></a>
  <br>
  <p><img src="https://github.com/A-kirami/nonebot-plugin-template/blob/resources/NoneBotPlugin.svg" width="240" alt="NoneBotPluginText"></p>
</div>

<div align="center">

# nonebot-plugin-sudo

_✨ 使用其他用户身份执行命令 ✨_


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

</div>

<!--

这是一个 nonebot2 插件项目的模板库, 你可以直接使用本模板创建你的 nonebot2 插件项目的仓库

模板库使用方法:
1. 点击仓库中的 "Use this template" 按钮, 输入仓库名与描述, 点击 "  Create repository from template" 创建仓库
2. 在创建好的新仓库中, 在 "Add file" 菜单中选择 "Create new file", 在新文件名处输入`LICENSE`, 此时在右侧会出现一个 "Choose a license template" 按钮, 点击此按钮选择开源协议模板, 然后在最下方提交新文件到主分支
3. 全局替换`This-is-XiaoDeng`为仓库所有者ID; 全局替换`nonebot-plugin-sudo`为插件名; 全局替换`nonebot_plugin_sudo`为包名; 修改 python 徽标中的版本为你插件的运行所需版本
4. 修改 README 中的插件名和插件描述, 并在下方填充相应的内容

配置发布工作流:
1. 前往 https://pypi.org/manage/account/#api-tokens 并创建一个新的 API 令牌。创建成功后不要关闭页面,不然你将无法再次查看此令牌。
2. 在单独的浏览器选项卡或窗口中,[打开 Actions secrets and variables 页面](./settings/secrets/actions)。你也可以在 Settings - Secrets and variables - Actions 中找到此页面。
3. 点击 New repository secret 按钮,创建一个名为 `PYPI_API_TOKEN` 的新令牌,并从第一步复制粘贴令牌。

触发发布工作流:
推送任意 tag 即可触发。

创建 tag:

    git tag <tag_name>

推送本地所有 tag:

    git push origin --tags

-->

## 📖 介绍

XDbot2 SUDO 插件独立版,允许使用其他用户身份执行命令

## 💿 安装

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

    nb plugin install nonebot-plugin-sudo

</details>

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

<details>
<summary>pip</summary>

    pip install nonebot-plugin-sudo
</details>
<details>
<summary>pdm</summary>

    pdm add nonebot-plugin-sudo
</details>
<details>
<summary>poetry</summary>

    poetry add nonebot-plugin-sudo
</details>
<details>
<summary>conda</summary>

    conda install nonebot-plugin-sudo
</details>

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

    plugins = ["nonebot_plugin_sudo"]

</details>

## ⚙️ 配置

在 nonebot2 项目的`.env`文件中添加下表中的必填配置

|             配置项             | 必填 | 默认值 |                说明                |
|:---------------------------:|:--:|:---:|:--------------------------------:|
|          `SUDOERS`          | 是  |  无  |         可以使用 sudo 指令的用户          |
|   `SUDO_INSERT_CMDSTART`    | 否  | `0` |            是否自动插入指令前缀            |
| `SUDO_REPLACE_SENDER_DATA`  | 否  | `1` | 是否修改`event.sender`的信息(可能会拖慢运行速度) |  

## 🎉 使用

> 仅在 Onebot V11 适配器下测试可用,暂不支持 sudo 嵌套

### 指令表

|          指令          |   权限   | 需要@ | 范围  |            说明            |
|:--------------------:|:------:|:---:|:---:|:------------------------:|
| `sudo <uin> <消息...>` | SUDOER |  否  | 无限制 | 以用户`<uin>`的身份执行`<消息...>` |

### 效果图

待补充

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "nonebot-plugin-sudo",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "nonebot2,onebot",
    "author": "",
    "author_email": "This is XiaoDeng <1744793737@qq.com>",
    "download_url": "https://files.pythonhosted.org/packages/5a/4a/318230b2fc690c0f44713802e62f1dfd36f162c07be14f037ee122cef74b/nonebot_plugin_sudo-1.0.6.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n  <a href=\"https://v2.nonebot.dev/store\"><img src=\"https://github.com/A-kirami/nonebot-plugin-template/blob/resources/nbp_logo.png\" width=\"180\" height=\"180\" alt=\"NoneBotPluginLogo\"></a>\n  <br>\n  <p><img src=\"https://github.com/A-kirami/nonebot-plugin-template/blob/resources/NoneBotPlugin.svg\" width=\"240\" alt=\"NoneBotPluginText\"></p>\n</div>\n\n<div align=\"center\">\n\n# nonebot-plugin-sudo\n\n_\u2728 \u4f7f\u7528\u5176\u4ed6\u7528\u6237\u8eab\u4efd\u6267\u884c\u547d\u4ee4 \u2728_\n\n\n<a href=\"./LICENSE\">\n    <img src=\"https://img.shields.io/github/license/This-is-XiaoDeng/nonebot-plugin-sudo.svg\" alt=\"license\">\n</a>\n<a href=\"https://pypi.python.org/pypi/nonebot-plugin-sudo\">\n    <img src=\"https://img.shields.io/pypi/v/nonebot-plugin-sudo.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<!--\n\n\u8fd9\u662f\u4e00\u4e2a nonebot2 \u63d2\u4ef6\u9879\u76ee\u7684\u6a21\u677f\u5e93, \u4f60\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u672c\u6a21\u677f\u521b\u5efa\u4f60\u7684 nonebot2 \u63d2\u4ef6\u9879\u76ee\u7684\u4ed3\u5e93\n\n\u6a21\u677f\u5e93\u4f7f\u7528\u65b9\u6cd5:\n1. \u70b9\u51fb\u4ed3\u5e93\u4e2d\u7684 \"Use this template\" \u6309\u94ae, \u8f93\u5165\u4ed3\u5e93\u540d\u4e0e\u63cf\u8ff0, \u70b9\u51fb \"  Create repository from template\" \u521b\u5efa\u4ed3\u5e93\n2. \u5728\u521b\u5efa\u597d\u7684\u65b0\u4ed3\u5e93\u4e2d, \u5728 \"Add file\" \u83dc\u5355\u4e2d\u9009\u62e9 \"Create new file\", \u5728\u65b0\u6587\u4ef6\u540d\u5904\u8f93\u5165`LICENSE`, \u6b64\u65f6\u5728\u53f3\u4fa7\u4f1a\u51fa\u73b0\u4e00\u4e2a \"Choose a license template\" \u6309\u94ae, \u70b9\u51fb\u6b64\u6309\u94ae\u9009\u62e9\u5f00\u6e90\u534f\u8bae\u6a21\u677f, \u7136\u540e\u5728\u6700\u4e0b\u65b9\u63d0\u4ea4\u65b0\u6587\u4ef6\u5230\u4e3b\u5206\u652f\n3. \u5168\u5c40\u66ff\u6362`This-is-XiaoDeng`\u4e3a\u4ed3\u5e93\u6240\u6709\u8005ID; \u5168\u5c40\u66ff\u6362`nonebot-plugin-sudo`\u4e3a\u63d2\u4ef6\u540d; \u5168\u5c40\u66ff\u6362`nonebot_plugin_sudo`\u4e3a\u5305\u540d; \u4fee\u6539 python \u5fbd\u6807\u4e2d\u7684\u7248\u672c\u4e3a\u4f60\u63d2\u4ef6\u7684\u8fd0\u884c\u6240\u9700\u7248\u672c\n4. \u4fee\u6539 README \u4e2d\u7684\u63d2\u4ef6\u540d\u548c\u63d2\u4ef6\u63cf\u8ff0, \u5e76\u5728\u4e0b\u65b9\u586b\u5145\u76f8\u5e94\u7684\u5185\u5bb9\n\n\u914d\u7f6e\u53d1\u5e03\u5de5\u4f5c\u6d41:\n1. \u524d\u5f80 https://pypi.org/manage/account/#api-tokens \u5e76\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 API \u4ee4\u724c\u3002\u521b\u5efa\u6210\u529f\u540e\u4e0d\u8981\u5173\u95ed\u9875\u9762\uff0c\u4e0d\u7136\u4f60\u5c06\u65e0\u6cd5\u518d\u6b21\u67e5\u770b\u6b64\u4ee4\u724c\u3002\n2. \u5728\u5355\u72ec\u7684\u6d4f\u89c8\u5668\u9009\u9879\u5361\u6216\u7a97\u53e3\u4e2d\uff0c[\u6253\u5f00 Actions secrets and variables \u9875\u9762](./settings/secrets/actions)\u3002\u4f60\u4e5f\u53ef\u4ee5\u5728 Settings - Secrets and variables - Actions \u4e2d\u627e\u5230\u6b64\u9875\u9762\u3002\n3. \u70b9\u51fb New repository secret \u6309\u94ae\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a `PYPI_API_TOKEN` \u7684\u65b0\u4ee4\u724c\uff0c\u5e76\u4ece\u7b2c\u4e00\u6b65\u590d\u5236\u7c98\u8d34\u4ee4\u724c\u3002\n\n\u89e6\u53d1\u53d1\u5e03\u5de5\u4f5c\u6d41:\n\u63a8\u9001\u4efb\u610f tag \u5373\u53ef\u89e6\u53d1\u3002\n\n\u521b\u5efa tag:\n\n    git tag <tag_name>\n\n\u63a8\u9001\u672c\u5730\u6240\u6709 tag:\n\n    git push origin --tags\n\n-->\n\n## \ud83d\udcd6 \u4ecb\u7ecd\n\nXDbot2 SUDO \u63d2\u4ef6\u72ec\u7acb\u7248\uff0c\u5141\u8bb8\u4f7f\u7528\u5176\u4ed6\u7528\u6237\u8eab\u4efd\u6267\u884c\u547d\u4ee4\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-sudo\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-sudo\n</details>\n<details>\n<summary>pdm</summary>\n\n    pdm add nonebot-plugin-sudo\n</details>\n<details>\n<summary>poetry</summary>\n\n    poetry add nonebot-plugin-sudo\n</details>\n<details>\n<summary>conda</summary>\n\n    conda install nonebot-plugin-sudo\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_sudo\"]\n\n</details>\n\n## \u2699\ufe0f \u914d\u7f6e\n\n\u5728 nonebot2 \u9879\u76ee\u7684`.env`\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e0b\u8868\u4e2d\u7684\u5fc5\u586b\u914d\u7f6e\n\n|             \u914d\u7f6e\u9879             | \u5fc5\u586b | \u9ed8\u8ba4\u503c |                \u8bf4\u660e                |\n|:---------------------------:|:--:|:---:|:--------------------------------:|\n|          `SUDOERS`          | \u662f  |  \u65e0  |         \u53ef\u4ee5\u4f7f\u7528 sudo \u6307\u4ee4\u7684\u7528\u6237          |\n|   `SUDO_INSERT_CMDSTART`    | \u5426  | `0` |            \u662f\u5426\u81ea\u52a8\u63d2\u5165\u6307\u4ee4\u524d\u7f00            |\n| `SUDO_REPLACE_SENDER_DATA`  | \u5426  | `1` | \u662f\u5426\u4fee\u6539`event.sender`\u7684\u4fe1\u606f\uff08\u53ef\u80fd\u4f1a\u62d6\u6162\u8fd0\u884c\u901f\u5ea6\uff09 |  \n\n## \ud83c\udf89 \u4f7f\u7528\n\n> \u4ec5\u5728 Onebot V11 \u9002\u914d\u5668\u4e0b\u6d4b\u8bd5\u53ef\u7528\uff0c\u6682\u4e0d\u652f\u6301 sudo \u5d4c\u5957\n\n### \u6307\u4ee4\u8868\n\n|          \u6307\u4ee4          |   \u6743\u9650   | \u9700\u8981@ | \u8303\u56f4  |            \u8bf4\u660e            |\n|:--------------------:|:------:|:---:|:---:|:------------------------:|\n| `sudo <uin> <\u6d88\u606f...>` | SUDOER |  \u5426  | \u65e0\u9650\u5236 | \u4ee5\u7528\u6237`<uin>`\u7684\u8eab\u4efd\u6267\u884c`<\u6d88\u606f...>` |\n\n### \u6548\u679c\u56fe\n\n\u5f85\u8865\u5145\n",
    "bugtrack_url": null,
    "license": "MIT-License",
    "summary": "XDbot2 SUDO \u63d2\u4ef6\u72ec\u7acb\u7248",
    "version": "1.0.6",
    "project_urls": null,
    "split_keywords": [
        "nonebot2",
        "onebot"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3b3e77f2b434ccf780291ad77730603f492000552d6e06c6d511f44f95841cb2",
                "md5": "f6b9527a326ffd5c67097b960147394f",
                "sha256": "566845c41833c7f8df616ca06b5e103fe0b3fc17eb99804d460e8a20efa13e2b"
            },
            "downloads": -1,
            "filename": "nonebot_plugin_sudo-1.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f6b9527a326ffd5c67097b960147394f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5915,
            "upload_time": "2023-09-08T14:15:08",
            "upload_time_iso_8601": "2023-09-08T14:15:08.370605Z",
            "url": "https://files.pythonhosted.org/packages/3b/3e/77f2b434ccf780291ad77730603f492000552d6e06c6d511f44f95841cb2/nonebot_plugin_sudo-1.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5a4a318230b2fc690c0f44713802e62f1dfd36f162c07be14f037ee122cef74b",
                "md5": "5a4fcd4f019c01b831e0b94c7b972a40",
                "sha256": "5e93704e8405ea1537d398de4f51ec33a56e9e409904e4368cc1a7fef99e9141"
            },
            "downloads": -1,
            "filename": "nonebot_plugin_sudo-1.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "5a4fcd4f019c01b831e0b94c7b972a40",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 7505,
            "upload_time": "2023-09-08T14:15:09",
            "upload_time_iso_8601": "2023-09-08T14:15:09.992126Z",
            "url": "https://files.pythonhosted.org/packages/5a/4a/318230b2fc690c0f44713802e62f1dfd36f162c07be14f037ee122cef74b/nonebot_plugin_sudo-1.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-08 14:15:09",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "nonebot-plugin-sudo"
}
        
Elapsed time: 0.11000s