Skip to content

Commit 61dad68

Browse files
author
hubert
committed
chore: initial project
0 parents  commit 61dad68

File tree

15 files changed

+2511
-0
lines changed

15 files changed

+2511
-0
lines changed

.env.example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# 账号配置
2+
ACCOUNTS=[{"cookies":{"session":"你的session值"},"api_user":"你的api_user值","github":{"username":"你的用户名","password":"你的密码"}},{"provider":"agentrouter","linux.do":{"username":"你的用户名","password":"你的密码"}}]
3+
4+
# 可选:通知配置
5+
# DINGDING_WEBHOOK=https://oapi.dingtalk.com/robot/send?access_token=xxx
6+
# EMAIL_USER=your_email@example.com
7+
# EMAIL_PASS=your_password
8+
# EMAIL_TO=recipient@example.com
9+
# PUSHPLUS_TOKEN=your_pushplus_token
10+
# SERVERPUSHKEY=your_server_pushkey
11+
# FEISHU_WEBHOOK=https://open.feishu.cn/open-apis/bot/v2/hook/xxx
12+
# WEIXIN_WEBHOOK=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxx

.github/workflows/checkin.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: newapi.ai 自动签到
2+
on:
3+
schedule:
4+
- cron: '0 */6 * * *'
5+
workflow_dispatch:
6+
7+
jobs:
8+
checkin:
9+
runs-on: windows-2025
10+
environment: production
11+
env:
12+
PYTHONIOENCODING: utf-8
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- uses: astral-sh/setup-uv@v3
17+
with:
18+
version: "latest"
19+
20+
- uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.11'
23+
24+
- name: 缓存 UV 依赖
25+
uses: actions/cache@v4
26+
id: uv-cache
27+
with:
28+
path: |
29+
~/.cache/uv
30+
.venv
31+
key: ${{ runner.os }}-uv-${{ hashFiles('pyproject.toml', 'uv.lock') }}
32+
restore-keys: |
33+
${{ runner.os }}-uv-
34+
35+
- name: 安装依赖
36+
if: steps.uv-cache.outputs.cache-hit != 'true'
37+
run: |
38+
echo "缓存未命中,开始安装项目依赖..."
39+
uv sync
40+
echo "✅ 环境初始化完成"
41+
42+
- name: 获取 Playwright 版本
43+
id: playwright-version
44+
run: |
45+
$version = uv run python -c "import importlib.metadata; print(importlib.metadata.version('playwright'))"
46+
echo "version=$version" >> $env:GITHUB_OUTPUT
47+
echo "Playwright version: $version"
48+
49+
- name: 缓存 Playwright 浏览器
50+
uses: actions/cache@v4
51+
id: playwright-cache
52+
with:
53+
path: ~\AppData\Local\ms-playwright
54+
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}
55+
restore-keys: |
56+
${{ runner.os }}-playwright-
57+
58+
- name: 安装 Playwright 浏览器
59+
if: steps.playwright-cache.outputs.cache-hit != 'true'
60+
run: |
61+
echo "缓存未命中,开始安装 Playwright 浏览器..."
62+
uv run playwright install chromium --with-deps
63+
64+
- name: 恢复登录状态缓存
65+
uses: actions/cache@v4
66+
with:
67+
path: |
68+
caches
69+
key: auth-caches-${{ github.sha }}
70+
restore-keys: |
71+
auth-caches-
72+
73+
- name: 恢复余额历史缓存
74+
uses: actions/cache@v4
75+
with:
76+
path: |
77+
balance_hash.txt
78+
key: balance-hash-${{ github.sha }}
79+
restore-keys: |
80+
balance-hash-
81+
82+
- name: 执行签到
83+
env:
84+
ACCOUNTS: ${{ secrets.ACCOUNTS }}
85+
PROVIDERS: ${{ secrets.PROVIDERS }}
86+
DINGDING_WEBHOOK: ${{ secrets.DINGDING_WEBHOOK }}
87+
EMAIL_USER: ${{ secrets.EMAIL_USER }}
88+
EMAIL_PASS: ${{ secrets.EMAIL_PASS }}
89+
EMAIL_TO: ${{ secrets.EMAIL_TO }}
90+
CUSTOM_SMTP_SERVER: ${{ secrets.CUSTOM_SMTP_SERVER }}
91+
PUSHPLUS_TOKEN: ${{ secrets.PUSHPLUS_TOKEN }}
92+
SERVERPUSHKEY: ${{ secrets.SERVERPUSHKEY }}
93+
FEISHU_WEBHOOK: ${{ secrets.FEISHU_WEBHOOK }}
94+
WEIXIN_WEBHOOK: ${{ secrets.WEIXIN_WEBHOOK }}
95+
run: |
96+
uv run main.py
97+
98+
- name: 执行结果
99+
if: always()
100+
run: |
101+
echo "签到任务执行完成"
102+
echo "时间: $(Get-Date)"

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.claude
2+
.env
3+
.venv
4+
__pycache__
5+
.pytest_cache
6+
.ruff_cache
7+
caches
8+

.pre-commit-config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-json
9+
- id: check-toml
10+
- id: check-added-large-files
11+
- id: check-merge-conflict
12+
- id: check-case-conflict
13+
- id: detect-private-key
14+
- id: mixed-line-ending
15+
16+
- repo: https://github.com/astral-sh/ruff-pre-commit
17+
rev: v0.6.9
18+
hooks:
19+
- id: ruff
20+
- id: ruff-format

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11

LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
BSD 2-Clause License
2+
3+
Copyright (c) 2025, Milly
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# newapi.ai 多账号自动签到
2+
3+
> Fork from [anyrouter-check-in](https://github.com/millylee/anyrouter-check-in),添加 linux.do/github 登录时签到,支持更多场景
4+
5+
用于 Claude Code 中转站 newapi.ai 多账号每日签到。
6+
[AnyRouter 限时注册](https://anyrouter.top/register?aff=wJrb)即送 200 美金(推荐额外赠送 100 美金),每日签到赠送 $25。业界良心,支持 `claude-sonnet-4.5``gpt-5-codex`,Claude Code 百万上下文(使用 `/model sonnet[1m]` 开启),`gemini-2.5-pro` 模型。
7+
[AgentRouter 限时注册](https://agentrouter.org/register?aff=wDU2)即送 200 美金(推荐额外赠送 100 美金),每日签到赠送 $25。支持 `claude-sonnet-4.5``gpt-5``deepseek-v3.2``glm4.6`
8+
其它使用 `newapi.ai` 功能相似
9+
10+
## 功能特性
11+
12+
- ✅ 单个/多账号自动签到
13+
- ✅ 多种机器人通知(可选)
14+
- ✅ linux.do 登录认证
15+
- ✅ github 登录认证
16+
17+
## 使用方法
18+
19+
### 1. Fork 本仓库
20+
21+
点击右上角的 "Fork" 按钮,将本仓库 fork 到你的账户。
22+
23+
### 2. 设置 GitHub Environment Secret
24+
25+
1. 在你 fork 的仓库中,点击 "Settings" 选项卡
26+
2. 在左侧菜单中找到 "Environments" -> "New environment"
27+
3. 新建一个名为 `production` 的环境
28+
4. 点击新建的 `production` 环境进入环境配置页
29+
5. 点击 "Add environment secret" 创建 secret:
30+
- Name: `ACCOUNTS`
31+
- Value: 你的多账号配置数据
32+
33+
### 3. 多账号配置格式
34+
35+
支持单个与多个账号配置,可选 `name` 字段用于自定义账号显示名称:
36+
37+
```json
38+
[
39+
{
40+
"name": "我的账号",
41+
"cookies": {
42+
"session": "account1_session_value"
43+
},
44+
"api_user": "account1_api_user_id"
45+
"github": {
46+
"username": "myuser",
47+
"password": "mypass",
48+
}
49+
},
50+
{
51+
"name": "另一个账号",
52+
"provider": "agentrouter",
53+
"linux.do": {
54+
"username": "user2",
55+
"password": "pass2",
56+
}
57+
}
58+
]
59+
```
60+
61+
**字段说明**
62+
- `name` (可选):自定义账号显示名称,用于通知和日志中标识账号
63+
- `cookies`(可选):用于身份验证的 cookies 数据
64+
- `api_user`(cookies 设置时必需):用于请求头的 new-api-user 参数
65+
- `linux.do`(可选):用于登录身份验证
66+
* `username`: 用户名
67+
* `password`: 密码
68+
- `github`(可选):用于登录身份验证
69+
* `username`: 用户名
70+
* `password`: 密码
71+
72+
如果未提供 `name` 字段,会使用 `Account 1``Account 2` 等默认名称。
73+
74+
### 4. 启用 GitHub Actions
75+
76+
1. 在你的仓库中,点击 "Actions" 选项卡
77+
2. 如果提示启用 Actions,请点击启用
78+
3. 找到 "newapi.ai 自动签到" workflow
79+
4. 点击 "Enable workflow"
80+
81+
### 5. 测试运行
82+
83+
你可以手动触发一次签到来测试:
84+
85+
1. 在 "Actions" 选项卡中,点击 "newapi.ai 自动签到"
86+
2. 点击 "Run workflow" 按钮
87+
3. 确认运行
88+
89+
![运行结果](./assets/check-in.png)
90+
91+
## 执行时间
92+
93+
- 脚本每6小时执行一次(1. action 无法准确触发,基本延时 1~1.5h;2. 目前观测到 newapi.ai 的签到是每 24h 而不是零点就可签到)
94+
- 你也可以随时手动触发签到
95+
96+
## 注意事项
97+
98+
- 可以在 Actions 页面查看详细的运行日志
99+
- 支持部分账号失败,只要有账号成功签到,整个任务就不会失败
100+
101+
## 开启通知
102+
103+
脚本支持多种通知方式,可以通过配置以下环境变量开启,如果 `webhook` 有要求安全设置,例如钉钉,可以在新建机器人时选择自定义关键词,填写 `newapi.ai`
104+
105+
### 邮箱通知
106+
- `EMAIL_USER`: 发件人邮箱地址
107+
- `EMAIL_PASS`: 发件人邮箱密码/授权码
108+
- `CUSTOM_SMTP_SERVER`: 自定义发件人SMTP服务器(可选)
109+
- `EMAIL_TO`: 收件人邮箱地址
110+
### 钉钉机器人
111+
- `DINGDING_WEBHOOK`: 钉钉机器人的 Webhook 地址
112+
113+
### 飞书机器人
114+
- `FEISHU_WEBHOOK`: 飞书机器人的 Webhook 地址
115+
116+
### 企业微信机器人
117+
- `WEIXIN_WEBHOOK`: 企业微信机器人的 Webhook 地址
118+
119+
### PushPlus 推送
120+
- `PUSHPLUS_TOKEN`: PushPlus 的 Token
121+
122+
### Server酱
123+
- `SERVERPUSHKEY`: Server酱的 SendKey
124+
125+
配置步骤:
126+
1. 在仓库的 Settings -> Environments -> production -> Environment secrets 中添加上述环境变量
127+
2. 每个通知方式都是独立的,可以只配置你需要的推送方式
128+
3. 如果某个通知方式配置不正确或未配置,脚本会自动跳过该通知方式
129+
130+
## 故障排除
131+
132+
如果签到失败,请检查:
133+
134+
1. 账号配置格式是否正确
135+
2. 网站是否更改了签到接口
136+
3. 查看 Actions 运行日志获取详细错误信息
137+
138+
## 本地开发环境设置
139+
140+
如果你需要在本地测试或开发,请按照以下步骤设置:
141+
142+
```bash
143+
# 安装所有依赖
144+
uv sync --dev
145+
146+
# 安装 Playwright 浏览器
147+
playwright install chromium
148+
149+
# 按 .env.example 创建 .env
150+
uv run main.py
151+
```
152+
153+
## 测试
154+
155+
```bash
156+
uv sync --dev
157+
158+
# 安装 Playwright 浏览器
159+
playwright install chromium
160+
161+
# 运行测试
162+
uv run pytest tests/
163+
```
164+
165+
## 免责声明
166+
167+
本脚本仅用于学习和研究目的,使用前请确保遵守相关网站的使用条款.

balance_hash.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
df3ae7e32a3f9e74

0 commit comments

Comments
 (0)