nonebot-plugin-system-command


Namenonebot-plugin-system-command JSON
Version 0.1.5 PyPI version JSON
download
home_pagehttps://github.com/tkgs0/nonebot-plugin-system-command
SummaryCall the system command in NoneBot2
upload_time2024-11-29 14:38:35
maintainerNone
docs_urlNone
author月ヶ瀬
requires_python<4.0,>=3.9
licenseMIT
keywords nonebot nonebot2 nonebot_plugin system shell cmd powershell
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://raw.githubusercontent.com/tkgs0/nbpt/resources/nbp_logo.png" width="180" height="180" alt="NoneBotPluginLogo"></a>
  <br>
  <p><img src="https://raw.githubusercontent.com/tkgs0/nbpt/resources/NoneBotPlugin.svg" width="240" alt="NoneBotPluginText"></p>
</div>

<div align="center">

# nonebot-plugin-system-command

_✨ Call the system command-line in NoneBot2 ✨_

<a href="./LICENSE">
    <img src="https://img.shields.io/github/license/tkgs0/nonebot-plugin-system-command.svg" alt="license">
</a>
<a href="https://pypi.python.org/pypi/nonebot-plugin-system-command">
    <img src="https://img.shields.io/pypi/v/nonebot-plugin-system-command.svg" alt="pypi">
</a>
<a href="https://www.python.org">
    <img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="python">
</a>
<a href="https://nonebot.dev">
    <img src="https://img.shields.io/badge/nonebot-2.3.1+-red.svg" alt="nonebot">
</a>

</div>

- 以发送消息的方式操作Bot所在环境的系统命令行
- 甚至可以通过此插件 `rm` 整个服务器
- 限超级用户使用

## 💿 安装

**nb-cli安装, 包管理器安装  二选一**

<details>
<summary>使用 nb-cli 安装</summary>

在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装

    nb plugin install nonebot-plugin-system-command

</details>

<details>
<summary>使用包管理器安装</summary>

在 nonebot2 项目的插件目录下, 打开命令行,

**根据你使用的包管理器, 输入相应的安装命令**

<details>
<summary>pip</summary>

    pip install nonebot-plugin-system-command

</details>
<details>
<summary>pdm</summary>

    pdm add nonebot-plugin-system-command

</details>
<details>
<summary>poetry</summary>

    poetry add nonebot-plugin-system-command

</details>
<details>
<summary>conda</summary>

    conda install nonebot-plugin-system-command

</details>

打开 bot项目下的 `pyproject.toml` 文件,

在其 `plugins` 里加入 `nonebot_plugin_system_command`

    plugins = ["nonebot_plugin_system_command"]

</details>
</details>

## 🎉 使用

- 可在 Bot项目的 `.env*` 中自定义调用命令行的指令,
  默认值为 `/sh` 和 `/cmd`

- 如果 `.env*` 中 `COMMAND_START` 变量值为 `["/"]`
  那么指令应该为 `//sh` `//cmd`

```env
SYS_CMD_SH="/sh"
SYS_CMD_CMD="/cmd"
```

### 指令表

<table> 
  <tr align="center">
    <th> 指令 </th>
    <th> 权限 </th>
    <th> 需要@ </th>
    <th> 范围 </th>
    <th> 特性 </th>
    <th> 说明 </th>
  </tr>
  <tr align="center">
    <td> /sh </td>
    <td> 主人 </td>
    <td> 否 </td>
    <td> 私聊 | 群聊 </td>
    <td> 异步管道 </td>
    <td> Windows环境无法正常使用 </td>
  </tr>
  <tr align="center">
    <td> /cmd </td>
    <td> 主人 </td>
    <td> 否 </td>
    <td> 私聊 | 群聊 </td>
    <td> 同步管道 </td>
    <td> 通用 </td>
  </tr>
</table>

### 语法

命令行语法与Bot运行环境相关, 与插件指令无关

- `bash` 运行即使用 `bash` 语法
- `zsh` 运行即使用 `zsh` 语法
- `powershell` 运行即使用 `powershell` 语法
- `cmd` 运行即使用 `cmd` 语法

其他shell同理

### ⚠️ ATTENTION

- 当您使用本插件时, 我们默认您了解命令行的基本使用, 以及在 `根环境` 运行命令的危险性;
- 在使用本插件前请先确认没有其他插件与本插件的指令发生冲突, 如有, 请在Bot项目下的 `.env*` 文件里自定义本插件的响应指令;
- 如有因为此插件响应了不相干的消息, 导致设备遭到损坏, 将由使用者自己承担相关责任.

注: 此处的 `根环境` 是指以 `root` 或者 `管理员(Administrator)` 或者其他高权限运行的终端环境

### 示例

```
/sh echo "hello world"
```

```
/cmd echo "hello world"
```

### 效果图

![01.png](https://github.com/tkgs0/nonebot-plugin-system-command/raw/resource/01.png)

## TODO

- [x] 使用异步管道
- [ ] 命令行交互

## ⚠️ ATTENTION

**Don't drink and root! 🍻**


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tkgs0/nonebot-plugin-system-command",
    "name": "nonebot-plugin-system-command",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "nonebot, nonebot2, nonebot_plugin, system, shell, cmd, powershell",
    "author": "\u6708\u30f6\u702c",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/8f/13/43bfaf18b9f88a59fae127dfc0fd54615e3f45e94c8d6e5cfd1130041618/nonebot_plugin_system_command-0.1.5.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n  <a href=\"https://v2.nonebot.dev/store\"><img src=\"https://raw.githubusercontent.com/tkgs0/nbpt/resources/nbp_logo.png\" width=\"180\" height=\"180\" alt=\"NoneBotPluginLogo\"></a>\n  <br>\n  <p><img src=\"https://raw.githubusercontent.com/tkgs0/nbpt/resources/NoneBotPlugin.svg\" width=\"240\" alt=\"NoneBotPluginText\"></p>\n</div>\n\n<div align=\"center\">\n\n# nonebot-plugin-system-command\n\n_\u2728 Call the system command-line in NoneBot2 \u2728_\n\n<a href=\"./LICENSE\">\n    <img src=\"https://img.shields.io/github/license/tkgs0/nonebot-plugin-system-command.svg\" alt=\"license\">\n</a>\n<a href=\"https://pypi.python.org/pypi/nonebot-plugin-system-command\">\n    <img src=\"https://img.shields.io/pypi/v/nonebot-plugin-system-command.svg\" alt=\"pypi\">\n</a>\n<a href=\"https://www.python.org\">\n    <img src=\"https://img.shields.io/badge/python-3.9+-blue.svg\" alt=\"python\">\n</a>\n<a href=\"https://nonebot.dev\">\n    <img src=\"https://img.shields.io/badge/nonebot-2.3.1+-red.svg\" alt=\"nonebot\">\n</a>\n\n</div>\n\n- \u4ee5\u53d1\u9001\u6d88\u606f\u7684\u65b9\u5f0f\u64cd\u4f5cBot\u6240\u5728\u73af\u5883\u7684\u7cfb\u7edf\u547d\u4ee4\u884c\n- \u751a\u81f3\u53ef\u4ee5\u901a\u8fc7\u6b64\u63d2\u4ef6 `rm` \u6574\u4e2a\u670d\u52a1\u5668\n- \u9650\u8d85\u7ea7\u7528\u6237\u4f7f\u7528\n\n## \ud83d\udcbf \u5b89\u88c5\n\n**nb-cli\u5b89\u88c5, \u5305\u7ba1\u7406\u5668\u5b89\u88c5  \u4e8c\u9009\u4e00**\n\n<details>\n<summary>\u4f7f\u7528 nb-cli \u5b89\u88c5</summary>\n\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-system-command\n\n</details>\n\n<details>\n<summary>\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5b89\u88c5</summary>\n\n\u5728 nonebot2 \u9879\u76ee\u7684\u63d2\u4ef6\u76ee\u5f55\u4e0b, \u6253\u5f00\u547d\u4ee4\u884c,\n\n**\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-system-command\n\n</details>\n<details>\n<summary>pdm</summary>\n\n    pdm add nonebot-plugin-system-command\n\n</details>\n<details>\n<summary>poetry</summary>\n\n    poetry add nonebot-plugin-system-command\n\n</details>\n<details>\n<summary>conda</summary>\n\n    conda install nonebot-plugin-system-command\n\n</details>\n\n\u6253\u5f00 bot\u9879\u76ee\u4e0b\u7684 `pyproject.toml` \u6587\u4ef6,\n\n\u5728\u5176 `plugins` \u91cc\u52a0\u5165 `nonebot_plugin_system_command`\n\n    plugins = [\"nonebot_plugin_system_command\"]\n\n</details>\n</details>\n\n## \ud83c\udf89 \u4f7f\u7528\n\n- \u53ef\u5728 Bot\u9879\u76ee\u7684 `.env*` \u4e2d\u81ea\u5b9a\u4e49\u8c03\u7528\u547d\u4ee4\u884c\u7684\u6307\u4ee4,\n  \u9ed8\u8ba4\u503c\u4e3a `/sh` \u548c `/cmd`\n\n- \u5982\u679c `.env*` \u4e2d `COMMAND_START` \u53d8\u91cf\u503c\u4e3a `[\"/\"]`\n  \u90a3\u4e48\u6307\u4ee4\u5e94\u8be5\u4e3a `//sh` `//cmd`\n\n```env\nSYS_CMD_SH=\"/sh\"\nSYS_CMD_CMD=\"/cmd\"\n```\n\n### \u6307\u4ee4\u8868\n\n<table> \n  <tr align=\"center\">\n    <th> \u6307\u4ee4 </th>\n    <th> \u6743\u9650 </th>\n    <th> \u9700\u8981@ </th>\n    <th> \u8303\u56f4 </th>\n    <th> \u7279\u6027 </th>\n    <th> \u8bf4\u660e </th>\n  </tr>\n  <tr align=\"center\">\n    <td> /sh </td>\n    <td> \u4e3b\u4eba </td>\n    <td> \u5426 </td>\n    <td> \u79c1\u804a | \u7fa4\u804a </td>\n    <td> \u5f02\u6b65\u7ba1\u9053 </td>\n    <td> Windows\u73af\u5883\u65e0\u6cd5\u6b63\u5e38\u4f7f\u7528 </td>\n  </tr>\n  <tr align=\"center\">\n    <td> /cmd </td>\n    <td> \u4e3b\u4eba </td>\n    <td> \u5426 </td>\n    <td> \u79c1\u804a | \u7fa4\u804a </td>\n    <td> \u540c\u6b65\u7ba1\u9053 </td>\n    <td> \u901a\u7528 </td>\n  </tr>\n</table>\n\n### \u8bed\u6cd5\n\n\u547d\u4ee4\u884c\u8bed\u6cd5\u4e0eBot\u8fd0\u884c\u73af\u5883\u76f8\u5173, \u4e0e\u63d2\u4ef6\u6307\u4ee4\u65e0\u5173\n\n- `bash` \u8fd0\u884c\u5373\u4f7f\u7528 `bash` \u8bed\u6cd5\n- `zsh` \u8fd0\u884c\u5373\u4f7f\u7528 `zsh` \u8bed\u6cd5\n- `powershell` \u8fd0\u884c\u5373\u4f7f\u7528 `powershell` \u8bed\u6cd5\n- `cmd` \u8fd0\u884c\u5373\u4f7f\u7528 `cmd` \u8bed\u6cd5\n\n\u5176\u4ed6shell\u540c\u7406\n\n### \u26a0\ufe0f ATTENTION\n\n- \u5f53\u60a8\u4f7f\u7528\u672c\u63d2\u4ef6\u65f6, \u6211\u4eec\u9ed8\u8ba4\u60a8\u4e86\u89e3\u547d\u4ee4\u884c\u7684\u57fa\u672c\u4f7f\u7528, \u4ee5\u53ca\u5728 `\u6839\u73af\u5883` \u8fd0\u884c\u547d\u4ee4\u7684\u5371\u9669\u6027;\n- \u5728\u4f7f\u7528\u672c\u63d2\u4ef6\u524d\u8bf7\u5148\u786e\u8ba4\u6ca1\u6709\u5176\u4ed6\u63d2\u4ef6\u4e0e\u672c\u63d2\u4ef6\u7684\u6307\u4ee4\u53d1\u751f\u51b2\u7a81, \u5982\u6709, \u8bf7\u5728Bot\u9879\u76ee\u4e0b\u7684 `.env*` \u6587\u4ef6\u91cc\u81ea\u5b9a\u4e49\u672c\u63d2\u4ef6\u7684\u54cd\u5e94\u6307\u4ee4;\n- \u5982\u6709\u56e0\u4e3a\u6b64\u63d2\u4ef6\u54cd\u5e94\u4e86\u4e0d\u76f8\u5e72\u7684\u6d88\u606f, \u5bfc\u81f4\u8bbe\u5907\u906d\u5230\u635f\u574f, \u5c06\u7531\u4f7f\u7528\u8005\u81ea\u5df1\u627f\u62c5\u76f8\u5173\u8d23\u4efb.\n\n\u6ce8: \u6b64\u5904\u7684 `\u6839\u73af\u5883` \u662f\u6307\u4ee5 `root` \u6216\u8005 `\u7ba1\u7406\u5458(Administrator)` \u6216\u8005\u5176\u4ed6\u9ad8\u6743\u9650\u8fd0\u884c\u7684\u7ec8\u7aef\u73af\u5883\n\n### \u793a\u4f8b\n\n```\n/sh echo \"hello world\"\n```\n\n```\n/cmd echo \"hello world\"\n```\n\n### \u6548\u679c\u56fe\n\n![01.png](https://github.com/tkgs0/nonebot-plugin-system-command/raw/resource/01.png)\n\n## TODO\n\n- [x] \u4f7f\u7528\u5f02\u6b65\u7ba1\u9053\n- [ ] \u547d\u4ee4\u884c\u4ea4\u4e92\n\n## \u26a0\ufe0f ATTENTION\n\n**Don't drink and root! \ud83c\udf7b**\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Call the system command in NoneBot2",
    "version": "0.1.5",
    "project_urls": {
        "Homepage": "https://github.com/tkgs0/nonebot-plugin-system-command",
        "Repository": "https://github.com/tkgs0/nonebot-plugin-system-command"
    },
    "split_keywords": [
        "nonebot",
        " nonebot2",
        " nonebot_plugin",
        " system",
        " shell",
        " cmd",
        " powershell"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d840fe8d6ee3b4177a62ea4c77cd19b65fd44fcfabe3eeb517d90ca2288cb59c",
                "md5": "b1fa30db7e8ee45dc3e19111594c0452",
                "sha256": "354b85e92e1e8eccb53c0bd32a8528063093abfca9a48c156ff4e3f005e3caa6"
            },
            "downloads": -1,
            "filename": "nonebot_plugin_system_command-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b1fa30db7e8ee45dc3e19111594c0452",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 5430,
            "upload_time": "2024-11-29T14:38:25",
            "upload_time_iso_8601": "2024-11-29T14:38:25.176138Z",
            "url": "https://files.pythonhosted.org/packages/d8/40/fe8d6ee3b4177a62ea4c77cd19b65fd44fcfabe3eeb517d90ca2288cb59c/nonebot_plugin_system_command-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8f1343bfaf18b9f88a59fae127dfc0fd54615e3f45e94c8d6e5cfd1130041618",
                "md5": "2bc42c57fe740a6d9c2e58d0928d26a0",
                "sha256": "e65ed950c2679872140c1cce67584731111ed197b1ae5e88773d617affb63080"
            },
            "downloads": -1,
            "filename": "nonebot_plugin_system_command-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "2bc42c57fe740a6d9c2e58d0928d26a0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 4592,
            "upload_time": "2024-11-29T14:38:35",
            "upload_time_iso_8601": "2024-11-29T14:38:35.459611Z",
            "url": "https://files.pythonhosted.org/packages/8f/13/43bfaf18b9f88a59fae127dfc0fd54615e3f45e94c8d6e5cfd1130041618/nonebot_plugin_system_command-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-29 14:38:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tkgs0",
    "github_project": "nonebot-plugin-system-command",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "nonebot-plugin-system-command"
}
        
Elapsed time: 0.41435s