{"id":13762250,"url":"https://github.com/EroSagiri/QShell","last_synced_at":"2025-05-10T14:31:48.409Z","repository":{"id":45307601,"uuid":"343478774","full_name":"EroSagiri/QShell","owner":"EroSagiri","description":"A Mirai Console Plugin","archived":false,"fork":false,"pushed_at":"2022-07-28T15:23:10.000Z","size":733,"stargazers_count":23,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-09-03T17:01:36.669Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EroSagiri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-01T16:16:37.000Z","updated_at":"2024-05-02T11:57:03.000Z","dependencies_parsed_at":"2022-09-15T20:12:02.681Z","dependency_job_id":null,"html_url":"https://github.com/EroSagiri/QShell","commit_stats":null,"previous_names":["eromangame/qshell"],"tags_count":3,"template":false,"template_full_name":"project-mirai/mirai-console-plugin-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EroSagiri%2FQShell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EroSagiri%2FQShell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EroSagiri%2FQShell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EroSagiri%2FQShell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EroSagiri","download_url":"https://codeload.github.com/EroSagiri/QShell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224970216,"owners_count":17400292,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T14:00:37.452Z","updated_at":"2024-11-16T20:31:17.035Z","avatar_url":"https://github.com/EroSagiri.png","language":"Kotlin","funding_links":[],"categories":["mirai-console 插件"],"sub_categories":[],"readme":"在qq代理执行系统Shell命令\n每次执行一条命令都会启动一个进程（不会保留变量环境  \n不能执行堵塞的命令  \n\n## 如何使用\n从Releases下载jar文件放到mirai-console的plugins  \n关于如何安装mirai-console看这里[Mirai - UserManual](https://github.com/mamoe/mirai/blob/dev/docs/UserManual.md)\n启动mcl会在config/QShell/生成配置文件\n\n## 配置文件\nmaster 主人的qq,主人有执行所有命令的权限  \nshellList 是一个列表，每一条代表着一个shell配置  \n通常使用 /qs add (shellNmae) (regex) [notPresenMessage] 生成配置\n```\n/**\n * 命令解析器配置\n * @param name 名字\n * @param commandList 命令行，第一个是可执行程序，后面的是参数\n * @param commandRegex 匹配qq消息的正则表达式 第X个分组会替换命令行的$X,X是正整数\n * @param replace 执行前替换执行的命令的 是一个字符串 左边是替换的字符串用;隔开右是替换的字符串\n * @param trustList 能执行命令的用户 * 代表所有人， u[qq]代表qq用户， f[qq]代表qq好友， g[q群号码]qq群\n * @param blackList 黑名单\n * @param isEnabled 是否启用\n * @param description 说明\n * @param notPresentMessage 没有权限的提示,这个字符串长度小于1时不提示\n * @param message  里面的 $msg 会被替换从标准（错误）输出\n * @param timeout 超时时间\n */\n@Serializable\ndata class ShellConfig(\n    var name : String,\n    var commandRegex : String,\n    var replace : MutableList\u003cString\u003e,\n    val commandList: MutableList\u003cString\u003e,\n    val trustList : MutableList\u003cString\u003e,\n    val blackList : MutableList\u003cString\u003e,\n    var isEnabled : Boolean,\n    var description : String,\n    var notPresentMessage : String,\n    var message : String,\n    var timeout : Long\n    )\n```\n\n## Master 在QQ执行QShell指令\nQShell每次启动都会把Master添加到权限系统  \n配合 [chat-command](https://github.com/project-mirai/chat-command) \nMaster 可以在qq上执行Qshell命令  \n![.github/images/command.png](.github/images/command.png)\n\n## 配置\n### 默认的配置\n只在Linux有效\n```\n# 主人qq号\nmaster: 2476255563\n# shell列表\nshellList: \n  - name: shell\n    commandRegex: '^\\$(.+)'\n    replace: []\n    commandList: \n      - bash\n      - '-c'\n      - '$1'\n    trustList: []\n    blackList: []\n    isEnabled: true\n    description: 执行Shell命令\n    notPresentMessage: 没有执行Shell的权限\n    message: '$msg'\n    timeout: 0\n```\n\n\n### Windows Cmd\n```\n# 主人qq号\nmaster: 2476255563\n# shell列表\nshellList: \n  - name: shell\n    commandRegex: '^\\$(.+)'\n    replace: []\n    commandList: \n      - cmd\n      - '/c'\n      - '$1'\n    trustList: []\n    blackList: []\n    isEnabled: true\n    description: 执行Shell命令\n    notPresentMessage: 没有执行Cmd的权限\n    message: '$msg'\n    timeout: 0\n```\n\n### Windows PowerShell\n```\n# 主人qq号\nmaster: 2476255563\n# shell列表\nshellList: \n  - name: shell\n    commandRegex: '^\\$(.+)'\n    replace: []\n    commandList: \n      - powershell\n      - '-Command'\n      - '$1'\n    trustList: []\n    blackList: []\n    isEnabled: true\n    description: 执行Shell命令\n    notPresentMessage: 没有执行PowerShell的权限\n    message: '$msg'\n    timeout: 0\n```\n\n### Python\n```\n# 主人qq号\nmaster: 2476255563\n# shell列表\nshellList: \n  - name: shell\n    commandRegex: '^\\$(.+)'\n    replace: []\n    commandList: \n      - python\n      - '-c'\n      - '$1'\n    trustList: []\n    blackList: []\n    isEnabled: true\n    description: 执行Shell命令\n    notPresentMessage: 没有执行Python的权限\n    message: '$msg'\n    timeout: 0\n```\n\n### 在容器中运行bash\n确保当前有权限执行docker命令\n并且容器shell在运行  \n运行一个容器,守护进程方式，并且执行bash,不让ta退出  \ndocker container run -d -it --rm --name=shell archlinux /bin/bash  \n不要用bash去执行docker（很容易被提权,直接使用docker  \n\n```\n# 主人qq号\nmaster: 2476255563\n# shell列表\nshellList: \n  - name: shell\n    commandRegex: '^\\$(.+)'\n    replace: []\n    commandList: \n      - docker\n      - exec\n      - shell\n      - bash\n      - '-c'\n      - '$1'\n    trustList: []\n    blackList: []\n    isEnabled: true\n    description: 执行Shell命令\n    notPresentMessage: 没有执行Shell的权限\n    message: '$msg'\n    timeout: 0\n```\n\n## 输出格式化\n标准（错误）输出有些特殊字符串会被格式化  \n### qshell image\n![](.github/images/qsehllImage.png)  \n### Mirai码\n阅读 [Mirai Core Api Document](https://docs.mirai.mamoe.net/Messages.html#%E8%BD%AC%E4%B9%89%E8%A7%84%E5%88%99)  \n![](.github/images/mirai.png)\n\n## 变量环境\n在执行程序之前qshell会添加一些环境变量  \n可以在shell下执行env 查看所有环境变量  \n### 配置相关\nMASTER 和配置文件的master一样  \n### 发送者相关\nSENDERNAME 发送者的qq昵称  \nSENDERID 发送者的qq号  \nSENDERSIGN 发送者的qq签名  \nSENDEREMAIL 发送者的电子邮箱  \nSENDERLEVEL 发送者等级 数字类型  \nSENDERAGE 发送者年龄  \nSENDERSEX 发送者性别  \n### 消息相关\nMESSAGECONTENT 消息内容  \nMESSAGEMIRAI 消息内容MiraiCode格式\n### 机器人相关\nBOTNAME 机器人的qq昵称  \nBOTAVATARURL 机器人头像的Url地址  \nBOTFRIENDSSIZE 机器人的好友数量  \nBOTGROUPSSIZE 机器人加入群的数量  \n### java相关\nJAVAVMNAME java虚拟机名字  \nJAVAVERSION java版本  \n### 操作系统相关\nOSARCH 操作系统架构  \nOSNAME 操作系统名字  \n\n## 指令\n/qs help 获取帮助  \n/qs list 获取shell列表  \n/qs info 获取shell详细信息  \n/qs echo 回复指定消息  \n/qs trust 添加用户到指定信任列表  \n/qs deny 从信任列表移除用户  \n/qs denyAll 清楚指定的shell所有信任列表  \n/qs enable 开启一个shell  \n/qs disable 关闭一个shell  \n/qs add 添加一个shell  \n/qs set 设置shell的指定值  \n/qs cmd 编辑命令行  \n/qs reload 重新加载配置  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEroSagiri%2FQShell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEroSagiri%2FQShell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEroSagiri%2FQShell/lists"}