This commit is contained in:
2026-01-18 03:45:02 +08:00
parent 0d19a9a96d
commit a4ca3ec093
4 changed files with 390 additions and 100 deletions

View File

@@ -96,7 +96,7 @@ class ProvisionerBot:
("team", self.cmd_team),
("list", self.cmd_list),
("config", self.cmd_config),
("headless", self.cmd_headless),
("fingerprint", self.cmd_fingerprint),
("run", self.cmd_run),
("run_all", self.cmd_run_all),
("stop", self.cmd_stop),
@@ -214,7 +214,7 @@ class ProvisionerBot:
/stop - 停止当前任务
<b>⚙️ 配置管理:</b>
/headless - 开启/关闭无头模式
/fingerprint - 开启/关闭随机指纹
/include_owners - 开启/关闭 Owner 入库
/reload - 重载配置文件 (无需重启)
@@ -397,37 +397,41 @@ class ProvisionerBot:
await update.message.reply_text("\n".join(lines), parse_mode="HTML")
@admin_only
async def cmd_headless(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
"""切换无头模式"""
async def cmd_fingerprint(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
"""切换随机指纹"""
import tomli_w
try:
# 读取当前配置
with open(CONFIG_FILE, "rb") as f:
import tomllib
config = tomllib.load(f)
# 获取当前状态
current = config.get("browser", {}).get("headless", False)
current = config.get("browser", {}).get("random_fingerprint", True)
new_value = not current
# 更新配置
if "browser" not in config:
config["browser"] = {}
config["browser"]["headless"] = new_value
config["browser"]["random_fingerprint"] = new_value
# 写回文件
with open(CONFIG_FILE, "wb") as f:
tomli_w.dump(config, f)
status = "✅ 已开启" if new_value else "❌ 已关闭"
await update.message.reply_text(
f"<b>🌐 无头模式</b>\n\n"
f"<b>🎭 随机指纹</b>\n\n"
f"状态: {status}\n\n"
f"开启后每次启动浏览器将随机使用不同的:\n"
f"• User-Agent (Chrome 133-144)\n"
f"• WebGL 显卡指纹\n"
f"• 屏幕分辨率\n\n"
f"💡 使用 /reload 立即生效",
parse_mode="HTML"
)
except ImportError:
await update.message.reply_text(
"❌ 缺少 tomli_w 依赖\n"