mirror of
https://github.com/hex-ci/smzdm_script.git
synced 2026-02-03 11:03:15 +08:00
Add docker-compose.yml
This commit is contained in:
@@ -15,4 +15,4 @@ COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||
COPY . /smzdm_bot
|
||||
|
||||
CMD ["python", "main.py"]
|
||||
CMD python scheduler.py
|
||||
|
||||
23
README.md
23
README.md
@@ -10,6 +10,8 @@
|
||||
## 1. 实现功能
|
||||
|
||||
- `什么值得买`每日签到
|
||||
- Github Action(两种配置方式,直接运行或者调用 Docker 运行)
|
||||
- 本地 Docker 定时运行
|
||||
- 通过`pushplus`推送运行结果到微信
|
||||
- 通过`server酱`推送运行结果到微信
|
||||
- 通过`telegram bot`推送
|
||||
@@ -31,7 +33,7 @@ on:
|
||||
- cron: "0 18 * * *"
|
||||
```
|
||||
|
||||
3. Secret 新增`SMZDM_COOKIE`, 填入[什么值得买官网](https://www.smzdm.com/)获取的 Cookie 信息, [详见](#31-cookie获取方法)
|
||||
3. Secret 新增`SMZDM_COOKIE`, 填入[什么值得买官网](https://www.smzdm.com/)获取的 Cookie 信息, [详见](#31-Cookie获取方法)
|
||||
4. (可选) Secret 新增`PUSH_PLUS_TOKEN`用于推送通知, [详见](https://www.pushplus.plus/)
|
||||
5. (可选) Secret 新增`SC_KEY`用于推送通知, [详见](https://sct.ftqq.com/)
|
||||
6. (可选) Secret 新增`TG_BOT_TOKEN` 和`TG_USER_ID`用于推送通知
|
||||
@@ -44,7 +46,24 @@ on:
|
||||
cp config/config_example.toml config/config.toml
|
||||
```
|
||||
|
||||
### 2.3 使用 Cookie Editor
|
||||
### 2.3 本地 docker 运行
|
||||
|
||||
见`docker-compose.yml`
|
||||
|
||||
本地生成一个`.env` 文件, 用于配置 docker-compose.yml 运行所需要的环境变量, 如下:
|
||||
|
||||
```
|
||||
SMZDM_COOKIE=__ckguid=
|
||||
PUSH_PLUS_TOKEN=
|
||||
SC_KEY=
|
||||
TG_BOT_TOKEN=
|
||||
TG_USER_ID=
|
||||
# 定时设定(可选), 若没有设定则随机定时执行
|
||||
SCH_HOUR=
|
||||
SCH_MINUTE=
|
||||
```
|
||||
|
||||
### 2.4 使用 Cookie Editor
|
||||
|
||||
也可以使用浏览器扩展 [Cookie Editor](https://microsoftedge.microsoft.com/addons/detail/cookie-editor/oaaopmblghnnjfgbgmflnkjkilhihdpb)导出 cookies, 另存为`cookies.json`在项目的根目录
|
||||
|
||||
|
||||
14
docker-compose.yml
Normal file
14
docker-compose.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
version: "3.9"
|
||||
services:
|
||||
smzdm_bot:
|
||||
image: enwaiax/smzdm_bot
|
||||
container_name: smzdm_bot
|
||||
restart: unless-stopped
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "1m"
|
||||
max-file: "1"
|
||||
env_file:
|
||||
- ${ENVIROMENT}.env
|
||||
entrypoint: "sleep infinity"
|
||||
@@ -1,10 +1,4 @@
|
||||
certifi==2022.9.24
|
||||
charset-normalizer==3.0.0
|
||||
docopt==0.6.2
|
||||
idna==3.4
|
||||
APScheduler==3.9.1
|
||||
prettytable==3.4.1
|
||||
requests==2.28.1
|
||||
toml==0.10.2
|
||||
urllib3==1.26.12
|
||||
wcwidth==0.2.5
|
||||
yarg==0.1.9
|
||||
18
scheduler.py
Normal file
18
scheduler.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import os
|
||||
from random import randint
|
||||
|
||||
from apscheduler.schedulers.background import BlockingScheduler
|
||||
|
||||
from main import main
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
SCH_HOUR = os.environ.get("SCH_HOUR", randint(0, 23))
|
||||
SCH_MINUTE = os.environ.get("SCH_MINUTE", randint(0, 59))
|
||||
scheduler = BlockingScheduler(timezone="Asia/Shanghai")
|
||||
scheduler.add_job(main, 'cron', hour=SCH_HOUR, minute=SCH_MINUTE)
|
||||
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
|
||||
try:
|
||||
scheduler.start()
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
pass
|
||||
Reference in New Issue
Block a user