Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
continuationc committed Mar 25, 2023
0 parents commit 20e7786
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[Makefile]
indent_style = tab
21 changes: 21 additions & 0 deletions .github/workflows/run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: run

on:
workflow_dispatch:
push:
schedule:
- cron: 10 16 * * *

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npm run main
env:
GLADOS: ${{ secrets.GLADOS }}
NOTIFY: ${{ secrets.NOTIFY }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
52 changes: 52 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const glados = async () => {
const cookie = process.env.GLADOS
if (!cookie) return
try {
const headers = {
'cookie': cookie,
'referer': 'https://glados.rocks/console/checkin',
'user-agent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)',
}
const checkin = await fetch('https://glados.rocks/api/user/checkin', {
method: 'POST',
headers: { ...headers, 'content-type': 'application/json' },
body: '{"token":"glados.network"}',
}).then((r) => r.json())
const status = await fetch('https://glados.rocks/api/user/status', {
method: 'GET',
headers,
}).then((r) => r.json())
return [
'Checkin OK',
`${checkin.message}`,
`Left Days ${Number(status.data.leftDays)}`,
]
} catch (error) {
return [
'Checkin Error',
`${error}`,
`<${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}>`,
]
}
}

const notify = async (contents) => {
const token = process.env.NOTIFY
if (!token || !contents) return
await fetch(`https://www.pushplus.plus/send`, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
token,
title: contents[0],
content: contents.join('<br>'),
template: 'markdown',
}),
})
}

const main = async () => {
await notify(await glados())
}

main()
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "module",
"scripts": {
"main": "node main.js"
}
}
20 changes: 20 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Checkin

GitHub Actions 实现 [GLaDOS][glados] 自动签到

([GLaDOS][glados] 可用邀请码: `MW4DK-O0RSF-C7AOU-EN1MP`, 双方都有奖励天数)

## 使用说明

1. Fork 这个仓库

1. 登录 [GLaDOS][glados] 获取 Cookie

1. 添加 Cookie 到 Secret `GLADOS`

1. 启用 Actions, 每天北京时间 00:10 自动签到

1. 如需推送通知, 可用 [PushPlus][pushplus], 添加 Token 到 Secret `NOTIFY`

[glados]: https://github.com/glados-network/GLaDOS
[pushplus]: https://www.pushplus.plus/

0 comments on commit 20e7786

Please sign in to comment.