Skip to main content

Call the system command in NoneBot2

Project description

NoneBotPluginLogo

NoneBotPluginText

nonebot-plugin-system-command

✨ Call the system command in NoneBot2 ✨

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

💿 安装

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

使用 nb-cli 安装

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

nb plugin install nonebot-plugin-system-command
使用包管理器安装

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

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

pip
pip install nonebot-plugin-system-command
pdm
pdm add nonebot-plugin-system-command
poetry
poetry add nonebot-plugin-system-command
conda
conda install nonebot-plugin-system-command

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

在其 plugins 里加入 nonebot_plugin_system_command

plugins = ["nonebot_plugin_system_command"]

🎉 使用

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

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

SYS_CMD_SH="/sh"
SYS_CMD_CMD="/cmd"

指令表

指令 权限 需要@ 范围 说明
/sh 主人 私聊 | 群聊 Windows环境无法正常使用
/cmd 主人 私聊 | 群聊 通用

语法

命令行语法与Bot运行环境相关, linux-shell运行即使用linux-shell语法, cmd运行即使用cmd语法, powershell运行即使用powershell语法

⚠️ ATTENTION!!

自定义指令前请三思而后行, 确保本插件不会因为响应了不相干的消息, 导致设备遭受灾难性的损坏!

示例

/sh echo "hello world"
/cmd echo "hello world"

TODO

  • 使用异步管道
  • 命令行交互

⚠️ ATTENTION!!!

Don't drink and root!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_plugin_system_command-0.1.1.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page