利用OpenClaw与Telegram机器人自动化管理着陆页
OpenClaw让您能够通过Telegram机器人管理多个着陆页:删除元素、添加内容、更改样式、创建页面、回滚更改以及收集表单统计数据。这将上线时间从数周缩短至几分钟。搭建需要一台运行Ubuntu 22.04+且拥有3 GB内存的VPS,适用于简单的单页网站。
准备服务器并安装OpenClaw
选择OpenClaw版本(例如nanobot)。指定Telegram机器人令牌,并设置昵称白名单。使用gpt-5.2+或gpt-5.3-codex模型。以sudo权限将其部署为systemd守护进程。
创建服务文件/etc/systemd/system/nanobot-gateway.service:
[Unit]
Description=SiteBot
After=network.target
Wants=network-online.target
[Service]
Type=simple
User=root
Group=root
ExecStart=%h/.local/bin/nanobot gateway
Restart=always
RestartSec=10
ProtectSystem=yes
# 资源限制
MemoryHigh=1G
MemoryMax=2G
MemorySwapMax=0
[Install]
WantedBy=multi-user.target
激活服务:
sudo systemctl daemon-reload
sudo systemctl enable --now nanobot-gateway
sudo systemctl start nanobot-gateway
ProtectSystem=yes可防止错误命令对系统造成损害。
集成Playwright进行测试
安装Node.js LTS:
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejs
检查版本:node --version(v20.x/v22.x),npm --version(10.x+)。
安装Playwright:
npm install @playwright/mcp@latest
npx playwright install --with-deps
添加到OpenClaw配置中:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--browser=firefox",
"--headless",
"--no-sandbox"
]
}
}
}
这实现了通过浏览器自动化测试更改。
组织着陆页存储
创建/var/www/Landings目录和一个空的GitHub仓库用于版本历史:
git clone <repo-url> /var/www/Landings
配置Nginx以提供网站服务
安装Nginx:
sudo apt update
sudo apt install nginx
sudo systemctl enable --now nginx
对于网站/var/www/Landings/site1,创建/etc/nginx/sites-available/site1.conf:
server {
listen 80;
server_name site1.example.com www.site1.example.com;
root /var/www/Landings/site1;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}
激活配置:
sudo ln -s /etc/nginx/sites-available/site1.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
为site2、site3等重复此步骤。机器人可以自动完成此操作。
迁移现有网站
通过Telegram机器人:"将网站example.com克隆到/var/www/Landings/site1。"
或手动操作:
scp -r "/path/to/site/folder" username@ip_or_host_of_our_VPS:/var/www/Landings/site1
通过机器人执行的关键操作
- 删除元素:"从网站X中移除这个。"
- 添加内容:"将那个添加到网站Y。"
- 更改样式:"将网站Z的样式更改为..."
- 创建页面:"为...创建一个新页面。"
- 回滚更改:"回滚网站XM上的最新更改。"
- 更新图标:"将网站XS上的图标替换为更现代的。"
- 收集统计数据:"收集网站X、Y、Z的表单提交统计数据。"
Playwright将在无头模式下测试更改。
重要事项
- 节省上线时间:带测试的更改只需几分钟而非数周。
- Git历史用于回滚和版本控制。
- 通过TG机器人白名单限制访问。
- 资源限制(MemoryHigh=1G,MemoryMax=2G)确保稳定性。
- ProtectSystem=yes最小化AI命令带来的风险。
— Editorial Team
暂无评论。