PyRunner 🐍
让你的 Python Discord 机器人直接与 Minecraft 服务器一起运行 —— 无需外部托管、无需 VPS、无需麻烦。
PyRunner 是一个 Paper 插件,它将一个 Python 进程(通常是 Discord 机器人)作为 Minecraft 服务器的子进程进行管理。它自动处理所有事情:下载 Python、从 requirements.txt 安装依赖项、崩溃后重启、将日志流式传输到实时 Web 仪表板,以及发送 Discord 通知 —— 所有这些只需通过单个 config.yml 进行配置。
🆕 1.4.2 版本更新:平台修复
修复
- 已修复:PyRunner 安装了最旧的可用 Python(3.11)而不是较新的版本。现在它会安装第二新 Python 版本(目前是 3.14)的最新发布版。最新版本被跳过,因为许多包还没有为它准备好现成的安装程序。设置
python-version 仍可固定版本。现有安装保留其 Python 版本;删除 plugins/PyRunner/python/ 以获取新版本。
- 已修复:Python 下载可能因 GitHub 超时(504)而失败。 PyRunner 现在一次性向 GitHub 请求的内容更少。
- 已修复:32 位 ARM Linux(例如旧版 Raspberry Pi OS)下载了 x64 Python。现在它会获取 ARM 构建版本。
还包含来自 1.4.1 的可靠性与安全修复
如果你从 spidey.in 下载了 1.4.0,请更新: 其仪表板在登录后无法正常工作。Modrinth 上的 1.4.0 与 1.4.1 具有相同的代码,仅版本号不同。
安全
- 新安装会生成随机仪表板密码,仅在控制台中打印一次,并且仅监听
127.0.0.1。之前,每个安装都在所有网络接口上使用 changeme。现有安装保留其设置,因此如果你的密码仍然是 changeme,请立即更改它。
- 已修复:登录锁定可以通过同时发送大量猜测来绕过,而且隧道后面陌生人的错误猜测可能会将你锁定。
- 已修复:过大的登录请求会占用服务器内存。
- 已修复:
/pybot logs 将机器人输出视为格式化聊天,因此你的机器人记录的某条消息可能变成可点击的命令。日志行现在是纯文本。
- 已修复:机器人的入口文件或名称可能指向插件文件夹之外。
机器人
- 已修复:在安装期间启动后,或停止后再启动时,一个机器人可能会运行两次,且停止命令无法触及第二个副本。
- 已修复:手动运行
pip install 会导致机器人卡在 INSTALLING 状态。
- 已修复:拼写错误的机器人名称会作用于你的第一个机器人。
- 已修复:将机器人重命名为已存在的名称会使旧机器人继续运行,且没有任何东西跟踪它,编辑正在运行的机器人可能会在新机器人停止之前启动新机器人。
- 已修复:如果连续触发两次,重启可能会静默地什么都不做。
- 已修复:损坏的下载存档可能在 Windows 上提取文件夹之外的文件。
- 命令不再使用仅 Paper 拥有的类,Spigot 和 Bukkit 没有这些类。
仪表板
- 已修复:编辑机器人可能会丢失其环境变量,包括机器人令牌。
- 已修复:在大量机器人输出的情况下,实时控制台可能变空白,并且在 cloudflared 快速隧道后面永远不会更新。
- 已修复:包含撇号的机器人名称会破坏该机器人卡片上的每个按钮。
- 当你的会话结束时,仪表板返回到登录页面。
✨ 功能
🐍 零接触 Python 设置
服务器上未安装 Python?没问题。PyRunner 会自动检测你的操作系统和 CPU 架构,并在首次启动时通过 python-build-standalone 下载独立的 Python 二进制文件。适用于 Linux (x64, ARM64 & 32 位 ARM)、macOS (x64 & ARM64) 和 Windows (x64 & ARM64)。二进制文件仅下载一次并缓存在本地。
📦 自动依赖项安装
如果你的机器人有 requirements.txt,PyRunner 将在启动前自动运行 pip install -r requirements.txt,前提是依赖项尚未安装。删除 bot/.pyrunner_deps_installed 可在下次启动时强制重新安装。
🔁 崩溃恢复与循环保护
机器人进程受到持续监控。如果它崩溃,PyRunner 会等待一段可配置的时间,然后自动重启它。如果在短时间内崩溃次数过多,崩溃循环保护 将会介入并停止重试 —— 防止无限重启骚扰,同时向你发出警报。
🖥️ 实时 Web 仪表板
内置 HTTP 服务器提供一个时尚的、受密码保护的控制面板,可通过任何浏览器访问。功能包括:
- 通过 Server-Sent Events (SSE) 进行 实时日志流式传输 —— 无需刷新
- 开始 / 停止 / 重启 / pip install 按钮
- 实时 状态、运行时间、PID 和重启计数
- 内存监控 —— 显示实时 RSS 内存使用情况
- 颜色编码的日志行(错误、警告、系统消息、回溯)
- 自动滚动并可切换
- stdin 输入栏 —— 直接向机器人进程发送命令
- 多机器人选择器 —— 从仪表板切换机器人(自动检测)
- 所有修改 API 端点的 CSRF 保护
- 暴力破解登录保护 —— 每个访客 5 次失败尝试后锁定,即使在隧道后面也是如此
🔔 Discord Webhook 通知
当你的机器人启动、停止、崩溃或运行 pip install 时,通过标准 Discord webhook URL 在 Discord 频道中收到通知。通知不需要机器人令牌。每种事件类型均可单独切换。
🎮 游戏内命令
通过 Minecraft 控制台或游戏内的 /pybot 命令完全控制。无需仅为了重启机器人而 SSH 进入服务器。
🤖 多机器人支持
同时运行多个 Python 机器人 —— 每个机器人都有自己独立的进程、日志文件和独立的崩溃恢复。使用 /pybot start <n>、/pybot stop <n> 等命令分别控制每个机器人。
📌 Python 版本固定
固定特定的 Python 次要版本(例如 "3.11"、"3.12"),而不是默认值(第二新版本的最新发布版)。
💻 标准输入透传
无需重启即可从 Web 仪表盘直接向机器人进程发送输入——适用于通过标准输入接受控制台命令的机器人。
📊 内存监控
Web 仪表盘显示机器人进程的实时内存使用情况(RSS),直接从 Linux 上的 /proc/<pid>/status 读取。
🔗 TunnelMC 集成
如果已安装 TunnelMC 且仪表盘端口上有活跃隧道,PyRunner 会在机器人启动时将公共 URL 打印到控制台——仅为信息提示,TunnelMC 绝不会自动启动。
📥 安装
- 下载
PyRunner.jar 并将其放入 plugins/ 文件夹
- 启动服务器一次以生成配置文件
- 将你的机器人代码放在
plugins/PyRunner/bot/ 中(应包含用于依赖项的 requirements.txt)
- 编辑
plugins/PyRunner/config.yml —— 至少需要在 env: 下设置你的机器人令牌
- 重启服务器,或运行
/pybot start
PyRunner 将处理其余部分——Python 下载、pip install 和机器人启动均自动完成。
📂 文件结构
plugins/
PyRunner/
config.yml ← 所有插件设置
bot/ ← 你的机器人代码放在这里
main.py
requirements.txt
.pyrunner_deps_installed ← pip install 成功后创建
logs/
bot.log ← 实时机器人输出(在 5MB 时轮换,保留 3 个备份)
bot-<n>.log ← 使用多个机器人时的每个机器人日志文件
python/ ← 自动下载的 Python 二进制文件(请勿编辑)
python.properties ← 缓存的二进制路径
🎮 命令与权限
权限节点: pyrunner.admin (默认:OP)
| 命令 |
描述 |
/pybot start [name] |
启动机器人(或通过名称指定特定机器人) |
/pybot stop [name] |
停止机器人(或通过名称指定特定机器人) |
/pybot restart [name] |
重启机器人(或通过名称指定特定机器人) |
/pybot status [name] |
显示所有机器人或特定机器人的状态 |
/pybot install [name] |
强制重新运行 pip install |
/pybot reload |
重载 config.yml |
🌐 Web 仪表盘
仪表盘监听 http://127.0.0.1:8080(端口可配置),因此默认情况下只有服务器本机可以打开它。要从其他位置访问:
- 使用隧道,如 TunnelMC 或 Cloudflare Tunnel(无需额外端口),或
- 设置
dashboard.bind-address: "0.0.0.0" 并打开 http://<your-server-ip>:8080
它具有密码保护。随机密码在首次启动时生成,仅在控制台中打印一次,并保存在 config.yml 中。
🔔 Discord Webhook 设置
- 打开你希望接收通知的 Discord 频道
- 进入 编辑频道 → 集成 → Webhooks → 新建 Webhook
- 复制 Webhook URL
- 将其粘贴到
config.yml 中的 discord.webhook.url 下
- 设置
discord.webhook.enabled: true
- 重启服务器或运行
/pybot reload
📊 兼容性
|
|
| Minecraft |
1.21.x – 26.3.x |
| Java |
25+(使用 Java 25 编译) |
| 操作系统 |
Linux, macOS, Windows |
| 架构 |
x64, ARM64 |
| 托管方式 |
自托管, Pterodactyl, 任何 VPS |
⚠️ 需要 Java 25: JAR 是使用 Java 25 编译的。你的服务器必须运行 Java 25 或更高版本。Paper 1.21.x+ 搭配 Java 25 是推荐且经过充分测试的设置。
🔗 相关项目
NodeRunner — 此插件的 Node.js 等效项。在你的 Minecraft 服务器旁运行一个 Node.js Discord 机器人。
TunnelMC — 通过 ngrok 隧道将任何服务器端口暴露到互联网。如果你的主机不提供多个端口分配,TunnelMC 与 PyRunner 完美配合,使得 Web 仪表盘无需额外端口即可公开访问。
📄 许可证
保留所有权利 — 此插件及其源代码均为专有软件。
由 Spider 开发
PyRunner 🐍
Run your Python Discord bot directly alongside your Minecraft server — no external hosting, no VPS, no hassle.
PyRunner is a Paper plugin that manages a Python process (typically a Discord bot) as a child process of your Minecraft server. It handles everything automatically: downloading Python, installing dependencies from requirements.txt, restarting on crash, streaming logs to a live web dashboard, and sending Discord notifications — all configured from a single config.yml.
🆕 What's New in 1.4.2: Platform Fixes
Fixes
- Fixed: PyRunner installed the oldest Python available (3.11) instead of a current one. It now installs the newest release of the second-newest Python version (3.14 today). The newest version is skipped because many packages don't have ready-made installs for it yet. Setting
python-version still pins a version. Existing installs keep their Python; delete plugins/PyRunner/python/ to get the new one.
- Fixed: Python downloads could fail with a GitHub timeout (504). PyRunner now asks GitHub for less at once.
- Fixed: 32-bit ARM Linux (such as older Raspberry Pi OS) downloaded x64 Python. It now gets the ARM build.
Also included from 1.4.1: Reliability & Security Fixes
If you downloaded 1.4.0 from spidey.in, please update: its dashboard didn't work after login. The 1.4.0 on Modrinth has the same code as 1.4.1, only the version number differs.
Security
- New installs get a random dashboard password, printed once in the console, and listen on
127.0.0.1 only. Before, every install used changeme on all network interfaces. Existing installs keep their settings, so if yours is still changeme, change it now.
- Fixed: the login lockout could be bypassed by sending many guesses at once, and one stranger's bad guesses behind a tunnel could lock you out.
- Fixed: oversized login requests could use up server memory.
- Fixed:
/pybot logs treated bot output as formatted chat, so a message your bot logged could become a clickable command. Log lines are now plain text.
- Fixed: a bot's entry file or name could point outside the plugin's own folder.
Bots
- Fixed: one bot could end up running twice after Start during an install, or Stop and then Start, and Stop couldn't reach the second copy.
- Fixed: running
pip install by hand left the bot stuck on INSTALLING.
- Fixed: a mistyped bot name acted on your first bot.
- Fixed: renaming a bot to an existing name left the old one running with nothing tracking it, and editing a running bot could start the new one before the old one had stopped.
- Fixed: restarting could silently do nothing if triggered twice in quick succession.
- Fixed: a corrupted download archive could extract files outside its folder on Windows.
- Commands no longer use Paper-only classes, which Spigot and Bukkit don't have.
Dashboard
- Fixed: editing a bot could lose its environment variables, including bot tokens.
- Fixed: the live console could go blank under heavy bot output, and never updated behind a cloudflared quick tunnel.
- Fixed: bot names containing an apostrophe broke every button on that bot's card.
- When your session ends, the dashboard returns to the login page.
✨ Features
🐍 Zero-Touch Python Setup
No Python installed on your server? No problem. PyRunner automatically detects your OS and CPU architecture and downloads a self-contained Python binary via python-build-standalone on first start. Works on Linux (x64, ARM64 & 32-bit ARM), macOS (x64 & ARM64), and Windows (x64 & ARM64). The binary is downloaded once and cached locally.
📦 Automatic Dependency Installation
If your bot has a requirements.txt, PyRunner will automatically run pip install -r requirements.txt before launching whenever the deps haven't been installed yet. Delete bot/.pyrunner_deps_installed to force a reinstall on next start.
🔁 Crash Recovery & Loop Protection
The bot process is monitored constantly. If it crashes, PyRunner waits a configurable delay then restarts it automatically. If it crashes too many times in a short window, crash-loop protection kicks in and stops retrying — preventing infinite restart spam while alerting you.
🖥️ Live Web Dashboard
A built-in HTTP server hosts a sleek, password-protected control panel accessible from any browser. Features include:
- Live log streaming via Server-Sent Events (SSE) — no refresh needed
- Start / Stop / Restart / pip install buttons
- Real-time status, uptime, PID, and restart count
- Memory monitoring — live RSS memory usage display
- Color-coded log lines (errors, warnings, system messages, tracebacks)
- Auto-scroll with toggle
- stdin input bar — send commands directly to the bot process
- Multi-bot selector — switch between bots from the dashboard (auto-detected)
- CSRF protection on all mutating API endpoints
- Brute-force login protection — lockout after 5 failed attempts per visitor, even behind a tunnel
🔔 Discord Webhook Notifications
Get notified in a Discord channel when your bot starts, stops, crashes, or when pip install runs — all via a standard Discord webhook URL. No bot token required for notifications. Each event type is individually toggleable.
🎮 In-Game Commands
Full control from the Minecraft console or in-game with the /pybot command. No need to SSH into your server just to restart the bot.
🤖 Multiple Bot Support
Run more than one Python bot simultaneously — each with its own process, log file, and independent crash recovery. Control each bot individually with /pybot start <n>, /pybot stop <n>, etc.
📌 Python Version Pinning
Pin a specific Python minor version (e.g. "3.11", "3.12") instead of the default (the newest release of the second-newest version).
💻 stdin Passthrough
Send input directly to the bot process from the web dashboard without restarting it — useful for bots that accept console commands via stdin.
📊 Memory Monitoring
The web dashboard shows live memory usage (RSS) of the bot process, read directly from /proc/<pid>/status on Linux.
🔗 TunnelMC Integration
If TunnelMC is installed and has an active tunnel on the dashboard port, PyRunner will print the public URL to console when the bot starts — purely informational, TunnelMC is never auto-started.
📥 Installation
- Download
PyRunner.jar and place it in your plugins/ folder
- Start the server once to generate config files
- Place your bot code in
plugins/PyRunner/bot/ (should include requirements.txt for dependencies)
- Edit
plugins/PyRunner/config.yml — at minimum set your bot token under env:
- Restart the server, or run
/pybot start
PyRunner will handle the rest — Python download, pip install, and bot launch happen automatically.
📂 File Structure
plugins/
PyRunner/
config.yml ← All plugin settings
bot/ ← Your bot code goes here
main.py
requirements.txt
.pyrunner_deps_installed ← Created after successful pip install
logs/
bot.log ← Live bot output (rotates at 5MB, keeps 3 backups)
bot-<n>.log ← Per-bot log files when using multiple bots
python/ ← Auto-downloaded Python binary (do not edit)
python.properties ← Cached binary paths
🎮 Commands & Permissions
Permission node: pyrunner.admin (default: OP)
| Command |
Description |
/pybot start [name] |
Start the bot (or a specific bot by name) |
/pybot stop [name] |
Stop the bot (or a specific bot by name) |
/pybot restart [name] |
Restart the bot (or a specific bot by name) |
/pybot status [name] |
Show status of all bots or a specific one |
/pybot install [name] |
Force re-run pip install |
/pybot reload |
Reload config.yml |
🌐 Web Dashboard
The dashboard listens on http://127.0.0.1:8080 (port is configurable), so by default only the server machine itself can open it. To reach it from elsewhere:
- use a tunnel such as TunnelMC or a Cloudflare Tunnel (no extra port needed), or
- set
dashboard.bind-address: "0.0.0.0" and open http://<your-server-ip>:8080
It is password protected. A random password is generated on first start, printed once in the console and saved in config.yml.
🔔 Discord Webhook Setup
- Open the Discord channel you want notifications in
- Go to Edit Channel → Integrations → Webhooks → New Webhook
- Copy the Webhook URL
- Paste it into
config.yml under discord.webhook.url
- Set
discord.webhook.enabled: true
- Restart the server or run
/pybot reload
📊 Compatibility
|
|
| Minecraft |
1.21.x – 26.3.x |
| Java |
25+ (compiled with Java 25) |
| OS |
Linux, macOS, Windows |
| Architectures |
x64, ARM64 |
| Hosting |
Self-hosted, Pterodactyl, any VPS |
⚠️ Java 25 Required: The JAR is compiled with Java 25. Your server must run Java 25 or higher. Paper 1.21.x+ with Java 25 is the recommended and fully tested setup.
🔗 Related Projects
NodeRunner — The Node.js equivalent of this plugin. Run a Node.js Discord bot alongside your Minecraft server.
TunnelMC — Expose any server port to the internet via ngrok tunnels. If your host doesn't provide multiple port allocations, TunnelMC pairs perfectly with PyRunner to make the web dashboard publicly accessible without needing an extra port.
📄 License
All Rights Reserved — This plugin and its source code are proprietary.
Developed by Spider
评论 0
登录后参与评分
还没有评论,来抢沙发吧