配置日志

openclaw openclaw官方 1

OpenClaw 自动签到教程

准备工作

获取签到所需信息

  • Cookie(必需)
  • User-Agent(必需)
  • 其他可能需要的参数

获取Cookie的方法:

  1. 浏览器登录OpenClaw网站
  2. 按F12打开开发者工具
  3. 进入Network(网络)选项卡
  4. 刷新页面
  5. 找到任意请求,复制Request Headers中的Cookie

Python自动签到脚本

import requests
import time
import logging
from datetime import datetime
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s: %(message)s')
class OpenClawAutoCheckin:
    def __init__(self):
        self.session = requests.Session()
        self.headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
            'Accept': 'application/json, text/plain, */*',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Content-Type': 'application/x-www-form-urlencoded',
            'Origin': 'https://openclaw.org',
            'Referer': 'https://openclaw.org/',
        }
    def set_cookie(self, cookie_str):
        """设置Cookie"""
        self.headers['Cookie'] = cookie_str
    def checkin(self):
        """执行签到"""
        try:
            # 获取签到页面,可能需要先获取token
            response = self.session.get(
                'https://openclaw.org/user/checkin',
                headers=self.headers,
                timeout=10
            )
            # 解析页面获取token(如果需要)
            # token = self.extract_token(response.text)
            # 发送签到请求
            checkin_data = {
                # 根据实际需要添加参数
                # 'token': token,
            }
            response = self.session.post(
                'https://openclaw.org/user/checkin',
                headers=self.headers,
                data=checkin_data,
                timeout=10
            )
            result = response.json()
            logging.info(f"签到结果: {result}")
            return result
        except Exception as e:
            logging.error(f"签到失败: {e}")
            return None
    def get_user_info(self):
        """获取用户信息"""
        try:
            response = self.session.get(
                'https://openclaw.org/user/profile',
                headers=self.headers,
                timeout=10
            )
            return response.text
        except Exception as e:
            logging.error(f"获取用户信息失败: {e}")
            return None
def main():
    # 创建实例
    checker = OpenClawAutoCheckin()
    # 设置你的Cookie(请替换为实际值)
    cookie = """
    _ga=GA1.1.xxxx;
    _gid=GA1.1.xxxx;
    uid=xxxx;
    email=xxxx;
    key=xxxx;
    ip=xxxx;
    expire_in=xxxx;
    """
    checker.set_cookie(cookie.strip())
    # 执行签到
    result = checker.checkin()
    if result:
        print(f"签到成功!时间: {datetime.now()}")
        print(f"返回数据: {result}")
    else:
        print("签到失败")
if __name__ == "__main__":
    main()

使用GitHub Actions自动签到(推荐)

创建GitHub仓库

  • 新建一个私有仓库

设置Secrets

在仓库Settings → Secrets → Actions中添加:

配置日志-第1张图片-OpenClaw开源下载|官方OpenClaw下载

  • OPENCLAW_COOKIE:你的Cookie

创建工作流文件 .github/workflows/checkin.yml

name: OpenClaw Auto Checkin
on:
  schedule:
    # 每天北京时间8:00运行
    - cron: '0 0 * * *'
  workflow_dispatch:  # 手动触发
jobs:
  checkin:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
      uses: actions/checkout@v3
    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: '3.9'
    - name: Install dependencies
      run: pip install requests
    - name: Run checkin script
      env:
        OPENCLAW_COOKIE: ${{ secrets.OPENCLAW_COOKIE }}
      run: python checkin.py
    - name: Send notification
      if: always()
      uses: appleboy/telegram-action@master
      with:
        to: ${{ secrets.TELEGRAM_CHAT_ID }}
        token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
        message: |
          OpenClaw签到结果
          时间: $(date)
          状态: ${{ job.status }}

服务器部署方案

使用crontab定时执行

# 编辑crontab
crontab -e
# 添加以下内容(每天8点执行)
0 8 * * * /usr/bin/python3 /path/to/checkin.py >> /path/to/checkin.log 2>&1

使用Docker部署

FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY checkin.py .
# 设置环境变量
ENV COOKIE="your_cookie_here"
CMD ["python", "checkin.py"]

高级功能

多账号支持

class MultiAccountCheckin:
    def __init__(self, accounts):
        self.accounts = accounts  # [{name: '账号1', cookie: 'xxx'}, ...]
    def run_all(self):
        for account in self.accounts:
            checker = OpenClawAutoCheckin()
            checker.set_cookie(account['cookie'])
            result = checker.checkin()
            self.send_notification(account['name'], result)

通知功能

def send_notification(platform, message):
    """发送通知到不同平台"""
    if platform == "telegram":
        # Telegram Bot通知
        pass
    elif platform == "serverchan":
        # Server酱通知
        pass
    elif platform == "email":
        # 邮件通知
        pass

注意事项

  1. 安全提醒

    • Cookie包含敏感信息,请妥善保管
    • 不要将Cookie提交到公开仓库
    • 定期更新Cookie
  2. 合规使用

    • 仅用于个人账号
    • 遵守网站使用条款
    • 不要设置过于频繁的签到间隔
  3. 故障排查

    • 定期检查日志
    • 关注网站更新
    • Cookie失效时及时更新

更新维护

  1. 关注网站API变化
  2. 定期测试脚本
  3. 备份重要数据

这个方案提供了从简单到完整的自动签到实现,你可以根据自己的需求选择合适的方案,建议先从本地测试开始,确认无误后再部署到服务器或GitHub Actions。

标签: 配置 日志

抱歉,评论功能暂时关闭!