Compare commits

...
163 Commits
Author SHA1 Message Date
shanmite 1bf0bd7d19 docs: 更新CHANGELOG 2022-11-15 14:51:36 +08:00
shanmite 28fc79ea33 fix: 通知内不显示抽奖信息 2022-11-15 14:49:57 +08:00
shanmite 9e6fe661ca fix: free log._cache 2022-11-15 14:21:04 +08:00
shanmite 5b50611ffe ci: update actions 2022-11-09 18:49:28 +08:00
shanmite 003508e1f3 docs: 更新CHANGELOG 2022-11-07 15:19:35 +08:00
shanmite 847e6806c6 feat: 丰富推送内容(#135)(#194)(#211)
Fixed #135
Fixed #194
Fixed #211
2022-11-07 15:14:10 +08:00
shanmite 8bf5070459 fix: flatMap is not a function (#218)
Fixed #218
2022-11-07 13:33:07 +08:00
shanmite 727883a269 feat: 推送NOTE (#221)
Fixed #221
2022-11-07 13:18:46 +08:00
shanmite fd33478af1 fix: 微信企业应用推送未配置出错 (#220)
Fixed #220
2022-11-07 12:34:23 +08:00
shanmite b2d9e192aa docs: 更新CHANGELOG 2022-11-05 12:39:14 +08:00
shanmite db7ba49ca1 style: 修改通知格式 2022-11-05 12:30:16 +08:00
shanmite b51882819a feat: 新增企业微信应用推送 (#217)
Fixed #217
2022-11-05 12:20:01 +08:00
shanmite e0a8ce5b20 doc: update image 2022-10-31 12:49:27 +08:00
shanmite 2b2613386d docs: 更新CHANGELOG 2022-10-31 12:39:14 +08:00
shanmite 92f700384e perf: monochrome 2022-10-31 12:34:42 +08:00
shanmite 8e77afadc3 fix: fs.uninkSync returns before remove finish 2022-10-31 11:34:16 +08:00
shanmite bfc8fb6a14 ci: gitlab mirror workflow_dispatch 2022-10-30 12:43:01 +08:00
shanmite f8dbe5ea5a docs: 更新CHANGELOG 2022-10-30 11:33:28 +08:00
shanmite 47e09a1263 ci: arm64 added, and optimized 2022-10-30 11:29:25 +08:00
shanmite b91a4f979d fix: fs.rm node12 2022-10-30 09:40:09 +08:00
shanmite d9cecbe163 ci: push shanmite/pkg-arm64 2022-10-29 20:37:09 +08:00
shanmite 989f836ba2 ci: 修改github release镜像源 2022-10-29 20:05:10 +08:00
shanmite 98948ad7f0 docs: 更新CHANGELOG 2022-10-29 13:41:28 +08:00
shanmite a363b4ee34 ci: 关闭arm64自动打包
```
curl: (18) transfer closed with 44597952 bytes remaining to read
Error: error building at STEP "RUN mkdir -p "${PKG_CACHE_PATH}" && curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-linux-arm64" -o "${PKG_CACHE_PATH}/fetched-v$NODEV-linux-arm64" && curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-linuxstatic-arm64" -o "${PKG_CACHE_PATH}/fetched-v$NODEV-linuxstatic-arm64"": error while running runtime: exit status 18
Error: Process completed with exit code 125.
```
2022-10-29 13:38:38 +08:00
shanmite c220ff5d27 feat(多账号优化): 抽奖信息本地保存 (#209)
Fixed #209
2022-10-29 13:15:36 +08:00
shanmite 2b6cc8d602 feat: 每条运行结果后面加上当前账号序列号 (#206) 2022-10-29 13:15:23 +08:00
ypw96andshanmite 856dd79ee9 fix: 增加获取关注上限(#207) 2022-10-20 19:29:05 +08:00
shanmite 468300227d fix: 青龙执行脚本时出错(#202) 2022-09-24 20:35:29 +08:00
shanmite ae4d1fde91 docs: 更新CHANGELOG 2022-09-24 17:24:47 +08:00
shanmite ca1acd21e8 fix: 转发随机动态视频新的错误码(#201)
Fixed #201
2022-09-24 16:26:44 +08:00
shanmite dabf8f9d75 fix: 关注出错(#199)
Fixed #199
2022-09-24 16:20:43 +08:00
shanmite affe24f441 fix: 发布随机动态显示转发请求不合法(#197)
Fixed #197
2022-09-24 16:15:25 +08:00
shanmite 3a5a8d0ded feat: ql support(#200)
Fixed #200
2022-09-23 13:47:23 +08:00
shanmite 5d3103102e docs: 更新CHANGELOG 2022-09-11 17:58:13 +08:00
shanmite 7ab38f258c feat: 弃用update_loop_wait(#180)
Fixed #180
2022-09-11 17:55:02 +08:00
shanmite 35fe4481fa feat: 预约抽奖参与间隔reserve_lottery_wait(#191)
Fixed #191
2022-09-11 17:42:23 +08:00
shanmite 58edd4129c fix: 该动态不能转发分享(#189)
Fixed #189
2022-09-11 17:24:43 +08:00
shanmite c8e1a328ec fix: 关注UP主7天以上的人可发评论(#192)
Fixed #192
2022-09-11 17:12:50 +08:00
shanmite 4f8f50f90b ci: docker 2022-08-29 10:47:01 +08:00
shanmite 3b4b85bc42 ci: pkg 2022-08-29 09:25:11 +08:00
shanmite db11265b28 docker: sh change to bash 2022-08-29 09:18:07 +08:00
shanmite 6df137201a docs: 更新CHANGELOG 2022-08-24 19:03:43 +08:00
shanmite 82efbb4219 ci: pkg arm64 use podman 2022-08-24 17:47:54 +08:00
shanmite 886ccff341 fix: cookie缺少buvid3导致412(#182)(#185)
Fixed #185
2022-08-24 17:09:14 +08:00
shanmite 0d5f5eca1d ci(docker): support more platforms 2022-08-23 15:48:52 +08:00
shanmite f75d2b66c4 fix: checkAllDynamic重试与null检测 2022-08-23 13:45:09 +08:00
shanmite 29bf439288 fix: 中途掉号账号未登录(#179)
Fixed #179
2022-08-23 12:40:27 +08:00
shanmite d3a8b86f55 fix: 重复评论(#184)
Fixed #184
2022-08-23 12:28:54 +08:00
shanmite d205cb5ddc fix: 未知错误1004(#175)
fixed #175
2022-08-23 12:01:43 +08:00
shanmite 223a6e13c9 fix: 获取推荐412(#182) 2022-08-23 11:46:23 +08:00
shanmite 664e33b3a6 docs: 更新CHANGELOG 2022-08-15 16:26:08 +08:00
shanmite 5a7b6721b9 fix: LotteryOrder设置(#176) 2022-08-15 16:21:52 +08:00
shanmite aae3de84f4 fix: 仅在评论需要验证码时退出(#175)
Fixed #175
2022-08-15 15:28:45 +08:00
shanmite 3491888f88 feat: 抽奖顺序可调LotteryOrder(#176)
Fixed #176
2022-08-15 12:25:57 +08:00
shanmite f6aa0d0544 fix: 未知错误带状态码(#175) 2022-08-15 10:53:39 +08:00
shanmite 1415f18fea fix: 无屏蔽词时全屏蔽 2022-07-24 14:00:10 +08:00
shanmite f498ee39b4 docs: 更新CHANGELOG 2022-07-19 12:36:40 +08:00
shanmite 292b8e05eb fix: 动态数据为null时异常退出 2022-07-19 12:35:40 +08:00
shanmite ca6549dc6f feat: 程序在请求多次输入验证码时切换下一个账号 (#167)
fixed: #167
2022-07-19 11:44:03 +08:00
shanmite e03b4832e4 fix: 远程设置换源gitee 2022-07-19 11:37:08 +08:00
shanmite 3e01e423b7 feat: 预约抽奖奖品屏蔽词 (#159)
fixed #159
2022-07-19 11:35:08 +08:00
shanmite 00b5310b59 feat: 自动点赞且检索本地(#162)
fixed #162
2022-07-18 10:16:08 +08:00
shanmiteandGitHub ba100e0444 docs: 更新docker运行说明(#160)
fixed #160
2022-07-05 10:37:14 +08:00
shanmite 29676d5c4b ci: mirror to gitlab 2022-06-29 11:40:23 +08:00
shanmite dd9ff1b3c8 docs: 修改changelog.sh使用http链接 2022-06-29 10:24:21 +08:00
shanmite d53881cbbd docs: 更新CHANGELOG 2022-06-29 10:19:54 +08:00
shanmite 4238ee50a6 fix: 预约验重(#158) 2022-06-29 10:18:55 +08:00
shanmite 784f148d75 docs: 更新CHANGELOG 2022-06-25 10:41:57 +08:00
shanmite 607b2d7055 feat: 新增设置disable_reserve_lottery
是否不参与预约抽奖
2022-06-25 10:39:57 +08:00
shanmite 03e24b9b84 fix: extend_json中的reserve获取失败(#155)
隐藏于`“”`键之下{“”:{reserve:{}}}
2022-06-25 10:28:14 +08:00
shanmite 73f04a357a docs: 更新CHANGELOG 2022-06-24 11:08:41 +08:00
shanmite 2742dcbd4f feat: 清理动态加入错误重试(#140)
fixed: #140
2022-06-24 11:07:48 +08:00
shanmite 329c5e506f feat: 自动参与预约抽奖(#155)
fixed #155
2022-06-24 10:27:11 +08:00
shanmite 3bc7dafe3e doc: 图片换源gitlab 2022-05-21 17:02:01 +08:00
shanmite 23432edb74 docs: 更新CHANGELOG 2022-05-21 16:36:07 +08:00
shanmite df7b3210a3 fix: 远程设置换源gitlab 2022-05-21 16:35:26 +08:00
shanmite 31e8941415 docs: 更新CHANGELOG 2022-05-03 10:01:55 +08:00
shanmite f329457c9a fix: 评论包含敏感词(#150)
Fixed #150
2022-05-03 09:55:53 +08:00
shanmiteandGitHub 0eddee4f15 Merge pull request #147 from spiritLHLS/patch-1
更换仓库地址
2022-04-11 09:21:36 +08:00
spiritLHLSandGitHub ce2c9e58dd Update README.md
备份迁移至此号
2022-04-11 09:10:09 +08:00
spiritLHLSandGitHub f1bbc9d1da Update README.md
备份迁移至此号
2022-04-11 08:53:58 +08:00
shanmite 29bb2f32a3 docs: 更新CHANGELOG 2022-03-23 15:58:12 +08:00
shanmite 22e4d2aaa1 fix: 转发了不含关键词的抽奖动态(#136)
Fixed #136
2022-03-23 15:04:59 +08:00
shanmite 354d8cff1a fix: 推送异常(#132)
Fixed #132
2022-03-22 15:02:59 +08:00
shanmite 1b80f853ed docs: 更新CHANGELOG 2022-03-02 19:49:10 +08:00
shanmite b1f478cb8e feat: 可选通知现阶段运行到哪个账号(#132)
新增设置`notice_running_state`
 Fixed #132
2022-03-02 19:44:27 +08:00
shanmite 39d69e0448 docs: 更新CHANGELOG 2022-03-01 21:17:53 +08:00
shanmite 45ac58e312 fix: 评论与转发相同时去掉动态原文(#128)
Fixed #128
2022-03-01 21:08:33 +08:00
shanmite a0d910632a docs: 更新CHANGELOG 2022-02-08 11:37:43 +08:00
shanmite 41b954081a fix: 未知错误退出 2022-02-08 11:34:30 +08:00
shanmite 2723048bb3 docs: 更新CHANGELOG 2022-02-07 15:27:09 +08:00
shanmite 3f59076d83 feat: 推送中奖检测可添加账号备注(#121)
详见env.example.js
2022-02-07 15:05:10 +08:00
shanmite b80c65558d docs: 更新CHANGELOG 2022-02-04 10:20:22 +08:00
shanmite f569207dc5 fix: 低版本node(< v15)不支持replaceAll
Nodejs v15 has V8 8.6 and thus that's the
 first nodejs version where you can use .replaceAll()
2022-02-04 10:18:20 +08:00
shanmite 6dbb9854c8 docs: 更新CHANGELOG 2022-02-03 11:53:24 +08:00
shanmite 2fbd292e7a feat: 自动评语中可用up主昵称${uname}变量(#118)
例如:
relay: ["祝${uname}早日百大!"]
2022-02-03 11:46:04 +08:00
shanmite 484f2e9ba9 docs: 更新CHANGELOG 2022-01-25 14:42:33 +08:00
shanmite 266ecf75a9 feat: 添加Qmsg酱推送(#115) 2022-01-25 14:32:04 +08:00
shanmite 4d90d83b67 feat: 日志细节优化
- 下载进度条
- iso+08
- 结构调整缓存变量
2022-01-20 17:51:40 +08:00
shanmite c56ec7a2c2 merge: 更新readme(#110)
相关项目添加
2022-01-20 16:11:23 +08:00
shanmite aa9cb68c81 docs: 更新CHANGELOG 2022-01-16 20:18:13 +08:00
shanmite dd1b1db76a feat(update): 优先使用代理更新失败时切回去 2022-01-16 20:12:35 +08:00
shanmite 86e6b7dbc9 feat: 重命名设置sneaktower(#104) 2022-01-16 16:58:49 +08:00
shanmite 731b8475ec docs: 更新CHANGELOG 2022-01-15 14:48:55 +08:00
shanmite 043fee21e7 feat: 新增设置sneaktopic(#104)
偷塔模式不检查是否重复转发
* 偷塔模式: 临近开奖时参与抽奖
`sneaktopic: true`
2022-01-15 14:23:22 +08:00
shanmite ae34c691b1 feat: 新增设置is_repost_then_chat(#103)
转发并评论
2022-01-05 18:13:48 +08:00
shanmite 7496bc58a8 feat: 中奖检查时增加回复信息读取(#102) 2022-01-05 16:37:49 +08:00
shanmite 7c455aff9c docs: 更新CHANGELOG 2021-12-23 15:28:01 +08:00
shanmite ef969bb2c2 feat: 每组显示动态转发数(#97) 2021-12-23 15:19:07 +08:00
shanmite 0cbacd6ddf feat: 推送携带帐号编号(#98) 2021-12-23 14:54:02 +08:00
shanmite da75c8c17b feat: 增加设置屏蔽动态类型block_dynamic_type(#99) 2021-12-23 14:42:46 +08:00
shanmite 548ad4b589 fix: pushplus更新域名(#93) 2021-12-14 16:54:25 +08:00
shanmite 922dd989bc docs: 更新CHANGELOG 2021-12-13 14:44:55 +08:00
shanmite c486abf0ed fix: 黑名单不起作用(#92)
类型判断错误
2021-12-13 14:31:24 +08:00
shanmite 4bbbfc89a7 docs: 更新CHANGELOG 2021-12-12 16:39:45 +08:00
shanmite aba17ed0ad feat: 提示关键词修改建议 2021-12-12 16:32:49 +08:00
shanmite 5a23043466 feat: 只通过是否点赞判断时点赞 2021-12-12 16:02:01 +08:00
shanmite 76f715248d fix: 黑名单匹配(#90)
子串不参与匹配
2021-12-12 15:57:48 +08:00
shanmite 0d4185d02a fix(Searcher): getLotteryInfoByUID(#89)
是否获取点赞信息
2021-12-12 15:04:37 +08:00
shanmite 2ff4ec812b docs: 更新CHANGELOG 2021-12-11 18:24:38 +08:00
shanmite 20c423fc09 fix: "公共黑名单"显示错误(#87) 2021-12-11 18:21:37 +08:00
shanmite 6851f29f75 fix: 描述中出现undefined(#88) 2021-12-11 18:18:43 +08:00
shanmite 77d198bec5 docs: 更新CHANGELOG 2021-12-10 15:21:26 +08:00
shanmite 0ba6acec31 feat: check_if_duplicated可同时使用多种方式 2021-12-10 15:16:17 +08:00
shanmite dd994263b9 fix: 只转已关注功能失效 2021-12-10 14:50:41 +08:00
shanmite 12847d7cfc docs: 更新CHANGELOG 2021-12-06 16:26:56 +08:00
shanmite 01562b6ee0 ci: verison升级时小版本号归0 2021-12-06 16:26:11 +08:00
shanmite 90ac347ff2 docs: 更新README 2021-12-06 16:14:59 +08:00
shanmite 3cf3939b49 feat: 新增设置check_if_duplicated
检查是否重复转发
- 不检查 -1
- 通过是否点赞判断 0
- 检索本地dyids文件 1
2021-12-06 16:12:41 +08:00
shanmite d0a8aa9169 feat: metainfo显示nodejs版本号 2021-12-05 20:12:47 +08:00
shanmite 10db52f9ae fix: 完善错误延时重试(#82)
- 成功 0
- 评论 未知错误 1001
- 评论 原动态已删除 1002
- 评论 评论区已关闭 1003
- 评论 需要输入验证码 1004
- 评论 已被对方拉入黑名单 1005
- 评论 黑名单用户无法互动 1006
- 评论 UP主已关闭评论区 1007
- 关注 未知错误 2001
- 关注 您已被对方拉入黑名单 2002
- 关注 黑名单用户无法关注 2003
- 关注 账号异常 2004
- 关注 关注已达上限 2005
- 分区 移动失败 3001
- 点赞 未知错误 4001
- 点赞 点赞异常 4002
- 点赞 点赞频繁 4003
- 转发 未知错误 5001
- 转发 该动态不能转发分享 5002
- 转发 请求数据发生错误,请刷新或稍后重试 5003
- 转发 操作太频繁了,请稍后重试 5004
2021-12-05 19:56:50 +08:00
shanmite f9ebbb30eb docs: 更新CHANGELOG 2021-12-03 19:16:39 +08:00
shanmite b36c555c13 ci: auto gen changelog 2021-12-03 19:15:34 +08:00
shanmite 7338e09caf feat: 更新notice_key_words
更新屏蔽通知词
"~你的账号在新设备或平台登录成功",
"~你预约的直播已开始"
2021-12-03 18:46:28 +08:00
shanmite 80a54e87f8 ci: *.exe latest_version0 2021-12-03 15:49:17 +08:00
shanmite 1a6291471a feat: 新增设置is_outof_maxfollow(#80)
关注已达上限时自动切换
2021-12-03 15:29:21 +08:00
shanmite 449c8d9272 docs: update README 2021-12-02 21:53:27 +08:00
shanmite 136379a3aa docs: 更新CHANGELOG 2021-12-02 19:47:00 +08:00
shanmite 313942adb7 ci: pkg.yml tag_name 2021-12-02 19:40:08 +08:00
shanmite 66efd62d56 feat: 新增设置use_public_blacklist 2021-12-02 19:29:26 +08:00
shanmite d7cf7422f4 feat: 增加粉丝数查询第三方接口 2021-12-02 19:18:51 +08:00
shanmite 094e019063 fix: 二级转发带有效抽奖 2021-12-02 19:07:43 +08:00
shanmite 8de74537f7 fix: description获取不到 2021-12-02 18:51:59 +08:00
shanmite 70c10f247b fix: 更改默认设置key_words blockword 2021-12-02 18:50:41 +08:00
shanmite 2f26a393ca feat: 源uid参与筛选判断
- 重构筛选处关于uid的逻辑
- debug日志详细化
2021-12-02 17:53:49 +08:00
shanmite a19739d2d8 docs: 更新CHANGELOG 2021-12-01 20:39:00 +08:00
shanmite 50e18e2772 feat: 下载更新时有多个版本 2021-12-01 20:30:18 +08:00
shanmite b9c73bda96 chore: change docker auto build 2021-12-01 20:08:38 +08:00
shanmite 608b1fb83e pref: 增加筛选时日志输出(#79) 2021-12-01 19:26:50 +08:00
shanmite 07ef8dfb2e chore: 移植并完善自动化构建脚本 2021-12-01 18:48:52 +08:00
shanmite 6b09e26cbf chore: update docker init.sh
see stackoverflow why-docker-run-creates-new-container-every-time
2021-11-30 16:19:16 +08:00
shanmite 7babd5780b docs: about docker 2021-11-29 20:28:52 +08:00
shanmite 8b57a85476 chore: pkg build 2021-11-29 16:09:39 +08:00
shanmite c85ea6bc77 docs: 更新CHANGELOG 2021-11-29 15:49:16 +08:00
shanmite eae72dbdd7 feat: minfollower填0可关闭本地粉丝数筛选 2021-11-28 21:33:15 +08:00
shanmite 111602f248 perf: 日志显示是否转发过 2021-11-28 20:04:45 +08:00
shanmite d366e252e9 fix: 转发动态时非限制性错误码(#72)
```json
{
  "code":2201116,
  "msg":"请求数据发生错误,请刷新或稍后重试",
  "message":"请求数据发生错误,请刷新或稍后重试",
  "data":{}
}
```
2021-11-27 15:14:25 +08:00
shanmite 40dcc5f879 docs: 更新CHANGELOG 2021-11-17 16:49:04 +08:00
shanmite 8c0d96afc6 refactor: 检测是否已经发送过随机动态(#71)
* 优化随机动态发送逻辑
* 修复随机动态的部分bug
2021-11-17 16:42:17 +08:00
shanmite 09b6db4f8b feat: 新增设置check_session_pages(#66)
获取私信页数
- check_session_pages
- 默认16
2021-11-17 15:36:54 +08:00
shanmite 24e16ed8bc fix: 多帐号使用默认设置初始化(#70) 2021-11-17 15:20:43 +08:00
shanmite fabe9f7d6e docs: 更新CHANGELOG 2021-11-09 19:13:32 +08:00
jkluio78andshanmite 1962d97bc1 fix: 过滤专栏时间失效(#67) 2021-11-09 19:04:07 +08:00
50 changed files with 2525 additions and 880 deletions
+7 -2
View File
@@ -1,4 +1,9 @@
**/**
!lib/
!package*
!main.js
!script/
!test/
!main.js
!package.json
!env.example.js
!my_config.example.js
!README.md
+3 -1
View File
@@ -60,9 +60,11 @@ body:
attributes:
label: "运行日志"
description: |
控制台日志
控制台日志,请用md代码格式上传,日志内容过多时请上传文件
placeholder: |
```
请在此黏贴运行日志。
```
- id: system
type: input
+11 -17
View File
@@ -6,35 +6,29 @@ on:
- main
paths:
- "lib/**"
- "main.js"
pull_request:
branches:
- main
paths:
- "lib/**"
- "main.js"
- "*.js"
- "*.json"
- ".github/workflows/docker.yml"
workflow_dispatch:
jobs:
path-context:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: shanmite/lottery_auto_docker:latest
tags: ${{ secrets.DOCKERHUB_REPO }}
platforms: "linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/ppc64le,linux/s390x"
+24
View File
@@ -0,0 +1,24 @@
name: Mirror and run GitLab CI
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Mirror + trigger CI
uses: SvanBoxel/gitlab-mirror-and-ci-action@master
with:
args: "https://gitlab.com/shanmiteko/LotteryAutoScript"
env:
FORCE_PUSH: "true"
GITLAB_HOSTNAME: "gitlab.com"
GITLAB_USERNAME: "shanmiteko"
GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }}
GITLAB_PROJECT_ID: "36365601"
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+1 -1
View File
@@ -12,7 +12,7 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
+65 -64
View File
@@ -1,82 +1,83 @@
name: "Package Node.js project into an executable"
on:
push:
branches:
- main
- pkg
paths:
- "lib/**"
- "main.js"
pull_request:
branches:
- main
paths:
- "lib/**"
- "main.js"
- "*.js"
- "*.json"
- ".github/workflows/pkg.yml"
- "script/build/pkg.sh"
workflow_dispatch:
branches:
- main
jobs:
pkg_x64:
runs-on: windows-latest
x64:
runs-on: ubuntu-latest
name: node${{ matrix.nodev }}-${{ matrix.platform }}-x64
strategy:
matrix:
include:
- platform: linux
nodev: 18
- platform: macos
nodev: 18
- platform: win
nodev: 18
- platform: win
nodev: 12
steps:
- name: "Checkout codes"
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: "Use Node.js"
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: "16"
node-version: "*"
- name: "Pkg this"
run: |
npm install
npm run pkg_x64
- name: "Upload to artifact(win)"
uses: actions/upload-artifact@v2
npm run pkg "node${{ matrix.nodev }}-${{ matrix.platform }}-x64"
- name: "Upload to artifact"
uses: actions/upload-artifact@v3
with:
name: nlts-win-x64
path: dist/nlts-win-x64/
- name: "Upload to artifact(linux)"
uses: actions/upload-artifact@v2
name: node${{ matrix.nodev }}-${{ matrix.platform }}-x64
path: "dist/*.zip"
- name: "Upload to release draft"
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
name: nlts-linux-x64
path: dist/nlts-linux-x64/
- name: "Upload to artifact(macos)"
uses: actions/upload-artifact@v2
file: "dist/*.zip"
delete_file: "dist/*.zip"
tag_name: "v2"
overwrite: true
arm64:
runs-on: ubuntu-latest
name: node18-${{ matrix.platform }}-arm64
strategy:
matrix:
include:
- platform: linux
- platform: linuxstatic
- platform: alpine
steps:
- name: "Checkout codes"
uses: actions/checkout@v3
- name: "Pkg this"
run: |
npm run pkg "${{ matrix.platform }}-arm64"
- name: "Upload to artifact"
uses: actions/upload-artifact@v3
with:
name: nlts-macos-x64
path: dist/nlts-macos-x64/
# pkg_arm64:
# runs-on: ubuntu-latest
# steps:
# - name: "Checkout codes"
# uses: actions/checkout@v2
# - name: "Use Node.js"
# uses: actions/setup-node@v1
# with:
# node-version: "16"
# - name: "Pkg this"
# run: |
# npm install
# npm run pkg_arm64
# - name: "Upload to artifact"
# uses: actions/upload-artifact@v2
# with:
# name: nlts-linux-arm64
# path: dist/
# pkg_armv7:
# runs-on: ubuntu-latest
# steps:
# - name: "Checkout codes"
# uses: actions/checkout@v2
# - name: "Use Node.js"
# uses: actions/setup-node@v1
# with:
# node-version: "16"
# - name: "Pkg this"
# run: |
# npm install
# npm run pkg_armv7
# - name: "Upload to artifact"
# uses: actions/upload-artifact@v2
# with:
# name: nlts-linux-armv7
# path: dist/
name: arm64
path: "dist/*.zip"
- name: "Upload to release draft"
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
file: "dist/*.zip"
delete_file: "dist/*.zip"
tag_name: "v2"
overwrite: true
+4
View File
@@ -2,7 +2,11 @@ node_modules/
.vscode/
tests/
dyids/
lottery_info/
dist/
.env
*.log
*.zip
package-lock.json
env.js
my_config.js
+298
View File
@@ -1,5 +1,303 @@
<!-- markdownlint-disable MD036 MD024-->
# CHANGELOG
## 主要变化(2.6.9)
* 28fc79e fix: 通知内不显示抽奖信息
* 9e6fe66 fix: free `log._cache`
* 5b50611 ci: update actions
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.6.8)
* 847e680 feat: 丰富推送内容(#135)(#194)(#211)
* 8bf5070 fix: `flatMap` is not a function (#218)
* 727883a feat: 推送`NOTE` (#221)
* fd33478 fix: 微信企业应用推送未配置出错 (#220)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.6.7)
* db7ba49 style: 修改通知格式
* b518828 feat: 新增企业微信应用推送 (#217)
* e0a8ce5 doc: update image
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.6.6)
* 92f7003 perf: monochrome
* 8e77afa fix: `fs.uninkSync` returns before remove finish
* bfc8fb6 ci: gitlab mirror `workflow_dispatch`
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.6.5)
* 47e09a1 ci: arm64 added, and optimized
* b91a4f9 fix: `fs.rm` node12
* d9cecbe ci: push shanmite/pkg-arm64
* 989f836 ci: 修改github release镜像源
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.6.4)
* a363b4e ci: 关闭`arm64`自动打包
* c220ff5 feat(多账号优化): 抽奖信息本地保存 (#209)
* 2b6cc8d feat: 每条运行结果后面加上当前账号序列号 (#206)
* 856dd79 fix: 增加获取关注上限(#207)
* 4683002 fix: 青龙执行脚本时出错(#202)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.6.3)
* ca1acd2 fix: 转发随机动态视频新的错误码(#201)
* dabf8f9 fix: 关注出错(#199)
* affe24f fix: 发布随机动态显示转发请求不合法(#197)
* 3a5a8d0 feat: 青龙面板(#200)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.6.2)
* 7ab38f2 feat: 弃用`update_loop_wait`(#180)
* 35fe448 feat: 预约抽奖参与间隔`reserve_lottery_wait`(#191)
* 58edd41 fix: 该动态不能转发分享(#189)
* c8e1a32 fix: 关注UP主7天以上的人可发评论(#192)
* 4f8f50f ci: docker
* 3b4b85b ci: pkg
* db11265 docker: change sh to bash
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.6.1)
* 82efbb4 ci: pkg arm64 use podman
* 886ccff fix: cookie缺少`buvid3`导致412(#182)(#185)
* 0d5f5ec ci(docker): support more platforms
* f75d2b6 fix: `checkAllDynamic`重试与`null`检测
* 29bf439 fix: 中途掉号账号未登录(#179)
* d3a8b86 fix: 重复评论(#184)
* d205cb5 fix: 未知错误1004(#175)
* 223a6e1 fix: 获取推荐412(#182)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.6.0)
* 5a7b672 fix: `LotteryOrder`设置(#176)
* aae3de8 fix: 仅在评论需要验证码时退出(#175)
* 3491888 feat: 抽奖顺序可调`LotteryOrder`(#176)
* f6aa0d0 fix: 未知错误带状态码(#175)
* 1415f18 fix: 无屏蔽词时全屏蔽
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.5.9)
* 292b8e0 fix: 动态数据为null时异常退出
* ca6549d feat: 程序在请求多次输入验证码时切换下一个账号 (#167)
* e03b483 fix: 远程设置换源gitee
* 3e01e42 feat: 预约抽奖奖品屏蔽词 (#159)
* 00b5310 feat: 自动点赞且检索本地(#162)
* ba100e0 docs: 更新docker运行说明(#160)
* 29676d5 ci: mirror to gitlab
* dd9ff1b docs: 修改changelog.sh使用http链接
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.5.8)
* 4238ee5 fix: 预约验重(#158)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.5.7)
* 607b2d7 feat: 新增设置`disable_reserve_lottery`
* 03e24b9 fix: `extend_json`中的`reserve`获取失败(#155)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.5.6)
* 2742dcb feat: 清理动态加入错误重试(#140)
* 329c5e5 feat: 自动参与预约抽奖(#155)
* 3bc7daf doc: 图片换源gitlab
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.5.5)
* df7b321 fix: 远程设置换源gitlab
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.5.4)
* f329457 fix: 评论包含敏感词(#150)
* 0eddee4 Merge pull request #147 from spiritLHLS/patch-1
* ce2c9e5 Update README.md
* f1bbc9d Update README.md
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.5.3)
* 22e4d2a fix: 转发了不含关键词的抽奖动态(#136)
* 354d8cf fix: 推送异常(#132)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.5.2)
* b1f478c feat: 可选通知现阶段运行到哪个账号(#132)
* 新增设置`notice_running_state`
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.5.1)
* 45ac58e fix: 评论与转发相同时去掉动态原文(#128)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.5.0)
* 41b9540 fix: 未知错误退出
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.11)
* 3f59076 feat: 推送中奖检测可添加账号备注(#121)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.10)
* f569207 fix: 低版本node(< v15)不支持replaceAll
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.9)
* 2fbd292 feat: 自动评语中可用up主昵称`${uname}`变量(#118)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.8)
* 266ecf7 feat: 添加Qmsg酱推送(#115)
* 4d90d83 feat: 日志细节优化
* c56ec7a merge: 更新readme(#110)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.7)
* dd1b1db feat(update): 优先使用代理更新失败时切回去
* 86e6b7d feat: 重命名设置`sneaktower`(#104)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.6)
* 043fee2 feat: 新增设置`sneaktopic`(#104)
* ae34c69 feat: 新增设置`is_repost_then_chat`(#103)
* 7496bc5 feat: 中奖检查时增加回复信息读取(#102)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.5)
* ef969bb feat: 每组显示动态转发数(#97)
* 0cbacd6 feat: 推送携带帐号编号(#98)
* da75c8c feat: 增加设置屏蔽动态类型`block_dynamic_type`(#99)
* 548ad4b fix: pushplus更新域名(#93)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.4)
* c486abf fix: 黑名单不起作用(#92)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.3)
* aba17ed feat: 提示关键词修改建议
* 5a23043 feat: 只通过是否点赞判断时点赞
* 76f7152 fix: 黑名单匹配(#90)
* 0d4185d fix(Searcher): getLotteryInfoByUID(#89)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.2)
* 20c423f fix: "公共黑名单"显示错误(#87)
* 6851f29 fix: 描述中出现undefined(#88)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.1)
* 0ba6ace feat: check_if_duplicated可同时使用多种方式
* dd99426 fix: 只转已关注功能失效
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.0)
* 01562b6 ci: verison升级时小版本号归0
* 90ac347 docs: 更新README
* 3cf3939 feat: 新增设置`check_if_duplicated`
* d0a8aa9 feat: metainfo显示nodejs版本号
* 10db52f fix: 完善错误延时重试(#82)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.3.9)
* b36c555 ci: auto gen changelog
* 7338e09 feat: 更新`notice_key_words`
* 80a54e8 ci: `*.exe` `latest_version0`
* 1a62914 feat: 新增设置`is_outof_maxfollow`(#80)
* 449c8d9 docs: update README
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.3.8)
* 313942a ci: pkg.yml tag_name
* 66efd62 feat: 新增设置`use_public_blacklist`
* d7cf742 feat: 增加粉丝数查询第三方接口
* 094e019 fix: 二级转发带有效抽奖
* 8de7453 fix: description获取不到
* 70c10f2 fix: 更改默认设置`key_words` `blockword`
* 2f26a39 feat: 源uid参与筛选判断
## 较上一版本变化
* 变更可执行文件
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.7...v2.3.8
## 主要变化(2.3.7)
* 50e18e2 feat: 下载更新时有多个版本
* b9c73bd chore: change docker auto build
* 608b1fb pref: 增加筛选时日志输出(#79)
* 07ef8df chore: 移植并完善自动化构建脚本
* 6b09e26 chore: update docker init.sh
* 7babd57 docs: about docker
* 8b57a85 chore: pkg build
## 较上一版本变化
* 变更可执行文件
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.6...v2.3.7
## 主要变化(2.3.6)
* eae72db feat: minfollower填0可关闭本地粉丝数筛选
* 111602f perf: 日志显示是否转发过
* d366e25 fix: 转发动态时非限制性错误码(#72)
## 较上一版本变化
* 变更可执行文件
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.5...v2.3.6
## 主要变化(2.3.5)
* 8c0d96a refactor: 检测是否已经发送过随机动态(#71)
* 09b6db4 feat: 新增设置`check_session_pages`(#66)
## 较上一版本变化
* 变更可执行文件
* [my_config.js](my_config.example.js)增加
- `check_session_pages` - 检查私信页数
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.4...v2.3.5
## 主要变化(2.3.4)
* 1962d97 fix: 过滤专栏时间失效(#67)
## 较上一版本变化
只变更可执行文件
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.2...v2.3.4
## 主要变化(2.3.3)
* 11625b3 feat: 检索专栏时能够根据发布时间进行过滤(#65)
+3 -6
View File
@@ -1,13 +1,10 @@
# Latest Nodejs + Alpine Linux
FROM node:lts-alpine
MAINTAINER [email protected]
LABEL version="1.0" description="自动参与B站动态抽奖"
LABEL author="shanmite" version="1.1" description="自动参与B站动态抽奖"
WORKDIR /lottery
COPY ["package.json", "package*.json", "./"]
COPY ["package.json", "./"]
RUN npm install
@@ -15,4 +12,4 @@ COPY ["main.js", "./"]
COPY ["lib/", "lib/"]
ENTRYPOINT ["npm", "run"]
CMD ["start"]
CMD ["start"]
+23
View File
@@ -0,0 +1,23 @@
FROM arm64v8/node:lts-alpine
WORKDIR /root/lottery
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
apk add --no-cache curl
ENV DOWNLOAD_HOST=https://ghproxy.com/https://github.com \
RELEASE_TAG=v3.4 \
NODEV=18.5.0 \
PKG_CACHE_PATH=/root/.pkg-cache \
PKG_IGNORE_TAG=true
RUN mkdir -p "${PKG_CACHE_PATH}" && \
curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-linux-arm64" -o \
"${PKG_CACHE_PATH}/fetched-v$NODEV-linux-arm64" && \
curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-alpine-arm64" -o \
"${PKG_CACHE_PATH}/fetched-v$NODEV-alpine-arm64" && \
curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-linuxstatic-arm64" -o \
"${PKG_CACHE_PATH}/fetched-v$NODEV-linuxstatic-arm64"
ENTRYPOINT ["npx", "pkg"]
CMD [""]
+72 -164
View File
@@ -6,10 +6,9 @@
- [本地运行](#本地运行)
- [可执行文件](#可执行文件)
- [以源码方式运行](#以源码方式运行)
- [Windows](#windows)
- [Linux](#linux)
- [Docker](#docker)
- [防重复转发](#防重复转发)
- [青龙面板](#青龙面板)
- [防重复转发(可选)](#防重复转发可选)
- [检测中奖](#检测中奖)
- [检测未读信息, 已读未读信息](#检测未读信息-已读未读信息)
- [中奖推送(可选)](#中奖推送可选)
@@ -18,16 +17,21 @@
[Github仓库链接](https://github.com/shanmiteko/LotteryAutoScript)
[![Package Node.js project into an executable](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/pkg.yml/badge.svg)](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/pkg.yml)<br>
[![Build and push Docker images](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/docker.yml/badge.svg)](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/docker.yml)<br>
[![Package Node.js project into an executable](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/pkg.yml/badge.svg)](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/pkg.yml)
[![Build and push Docker images](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/docker.yml/badge.svg)](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/docker.yml)
[![Publishing to NPM](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/npmp.yml/badge.svg)](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/npmp.yml)
[![Mirror and run GitLab CI](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/mirror.yml/badge.svg)](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/mirror.yml)
已实现功能:
- 监控用户转发
- 监控话题页面
- 监控专栏合集
- 自动点赞、评论、乱序转发、@好友、带话题、可选随机动态
- 直播预约抽奖
- 检测是否中奖
- 已读@
- 已读私信
@@ -59,7 +63,7 @@ Chrome浏览器:
(此步骤是为了方便后续采用JS获取Cookies,获取完毕后应再次勾选)
![取消httponly](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/getCookies.png)
![取消httponly](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/getCookies.png)
3. 在Console中复制以下代码回车
@@ -104,150 +108,48 @@ Chrome浏览器:
3. 在`env.js`中填入`COOKIE`和推送参数
4. 在`my_config.js`中自定义设置
5. 在当前目录下**打开终端**运行可执行文件`lottery`(勿直接点击`lottery`)
```sh
# unix-like
## 进入脚本所在目录
## 授予执行权限
$ chmod u+x lottery
## 启动脚本
$ ./lottery start
## 检测中奖
$ ./lottery check
## 清理关注动态
$ ./lottery clear
## 下载最新版本
$ ./lottery clear
# windows
## 不需要chmod
## 把`./`换成`.\`或去掉
## 已自带*.bat可直接点击
```
- windows 可直接点击对应的`*.bat`文件
- unix-like
```sh
## 进入脚本所在目录
## 授予执行权限
$ chmod u+x lottery
## 启动脚本
$ ./lottery start
## 检测中奖
$ ./lottery check
## 清理关注动态
$ ./lottery clear
## 下载最新版本
$ ./lottery update
```
7. 运行截图
![lottery_start](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/lottery_start.png)
![lottery_start](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/lottery_start.png)
#### 以源码方式运行
<details>
<summary>点击显示详细说明</summary>
##### Windows
step1: 下载代码到本地
[点此下载](https://github.com/shanmiteko/LotteryAutoScript/archive/refs/heads/main.zip)或如图示下载↓
![点我加载下载操作图示](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/download.png)
下载的压缩包解压后修改env.example.js文件,详见step3
step2: 下载并安装Node.js
[点此进入nodejs下载页面](http://nodejs.cn/download)
![点我加载下载nodejs操作图示](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/nodejs.png)
step3:修改env.example.js文件及创建运行文件(打开扩展名显示)
1.step1下载的压缩包解压后将其中的`env.example.js`文件重命名为`env.js`
2.右键`env.js`文件选择编辑或用记事本打开
3.填入相关参数
4.`my_config.example.js`同样操作
5.运行
注: `npm i`意味安装依赖, 只需运行一次, 为防止依赖有变化遂每次都执行
命令一: 启动抽奖
```bash
npm i && npm run start
```
命令二: 检查中奖
```bash
npm i && npm run check
```
命令三: 清理动态
```bash
npm i && npm run clear
```
`script`目录下有启动脚本, 点击即可运行
注: **本地运行时可在设置中增大扫描页数**
> ~~[windows系统定时运行](./doc/win_schedule.md)~~
脚本已内置定时运行功能
##### Linux
[linux系统配置与定时运行](./doc/linux_schedule.md)
</details>
### Docker
1.初始化
```bash
curl -fsSL https://cdn.staticaly.com/gh/shanmiteko/LotteryAutoScript/main/script/docker/init.sh | sh
```
进入`lottery`文件夹
```bash
cd lottery
```
编辑`env.js`与`my_config.js`文件
- env.js 设置必要环境变量
- my_config.js 你的设置
执行相应的脚本
> start,check,clear
例如:
```bash
./start.sh
```
2.更新
进入lottery上一级目录
使用与初始化相同的命令
3.卸载
进入lottery上一级目录
```bash
docker image rm -f shanmite/lottery_auto_docker
rm -rf lottery/
```
[点击跳转](doc/run_use_sc.md)
----------------------------------------
## 防重复转发
### Docker
~~存储在专栏草稿~~
[点击跳转](doc/run_use_docker.md)
~~脚本将转发过的动态和被过滤的动态都写入`dyids/dyid*.txt`文件中~~
----------------------------------------
是否点赞
### 青龙面板
[点击跳转](doc/run_use_ql.md)
----------------------------------------
## 防重复转发(可选)
- 脚本将转发过的动态和被过滤的动态都写入`dyids/dyid*.txt`文件中
- 是否点赞
----------------------------------------
@@ -269,29 +171,32 @@ rm -rf lottery/
以下是支持的推送方式
| Name | 归属 | 属性 | 说明 |
| :---------------: | :--------------------------------------------------------------------------------: | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SCKEY` | 微信server酱推送(于2021/4月下线) | 非必须 | server酱的微信通知[官方文档](http://sc.ftqq.com/3.version) |
| `SENDKEY` | 微信server酱(Turbo版)推送 | 非必须 | [获取SENDKEY](https://sct.ftqq.com/sendkey) [选择消息通道](https://sct.ftqq.com/forward) |
| `BARK_PUSH` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | 非必须 | IOS用户下载BARK这个APP,填写内容是app提供的`设备码`,例如:<https://api.day.app/123> ,那么此处的设备码就是`123`,再不懂看 [这个图](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/bark.jpg)(注:支持自建填完整链接即可) |
| `BARK_SOUND` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | 非必须 | bark推送声音设置,例如`choo`,具体值请在`bark`-`推送铃声`-`查看所有铃声` |
| `TG_BOT_TOKEN` | telegram推送 | 非必须 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写自己申请[@BotFather](https://t.me/BotFather)的Token,如`10xxx4:AAFcqxxxxgER5uw` , [具体教程](doc/TG_PUSH.md) |
| `TG_USER_ID` | telegram推送 | 非必须 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写[@getuseridbot](https://t.me/getuseridbot)中获取到的纯数字ID, [具体教程](doc/TG_PUSH.md) |
| `TG_PROXY_HOST` | Telegram 代理的 IP | 非必须 | 代理类型为 http。例子:http代理 <http://127.0.0.1:1080> 则填写 127.0.0.1 |
| `TG_PROXY_PORT` | Telegram 代理的端口 | 非必须 | 例子:http代理 <http://127.0.0.1:1080> 则填写 1080 |
| `DD_BOT_TOKEN` | 钉钉推送 | 非必须 | 钉钉推送(`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需)[官方文档](https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq) ,只需`https://oapi.dingtalk.com/robot/send?access_token=XXX` 等于`=`符号后面的XXX即可 |
| `DD_BOT_SECRET` | 钉钉推送 | 非必须 | (`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需) ,密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的`SECXXXXXXXXXX`等字符 , 注:钉钉机器人安全设置只需勾选`加签`即可,其他选项不要勾选,再不懂看 [这个图](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/DD_bot.png) |
| `IGOT_PUSH_KEY` | iGot推送 | 非必须 | iGot聚合推送,支持多方式推送,确保消息可达。 [参考文档](https://wahao.github.io/Bark-MP-helper ) |
| `QQ_SKEY` | 酷推(Cool Push)推送 | 非必须 | 推送所需的Skey,登录后获取Skey [参考文档](https://cp.xuthus.cc/) |
| `QQ_MODE` | 酷推(Cool Push)推送 | 非必须 | 推送方式(send或group或者wx,默认send) [参考文档](https://cp.xuthus.cc/) |
| `QYWX_KEY` | 企业微信推送 | 非必须 | 密钥,企业微信推送 webhook 后面的 key [详见官方说明文档](https://work.weixin.qq.com/api/doc/90000/90136/91770) |
| `PUSH_PLUS_TOKEN` | pushplus推送 | 非必须 | 微信扫码登录后一对一推送或一对多推送下面的token(您的Token) [官方网站](http://pushplus.hxtrip.com/) |
| `PUSH_PLUS_USER` | pushplus推送 | 非必须 | 一对推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码)注:(1、需订阅者扫描二维码 2、如果您是创建群组所属人,也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送),只填`PUSH_PLUS_TOKEN`默认为一对一推送 |
| `SMTP_HOST` | 电子邮件 | 非必须 | smtp服务器的主机名 如: `smtp.qq.com` |
| `SMTP_PORT` | 电子邮件 | 非必须 | smtp服务器的端口 如: `465` |
| `SMTP_USER` | 电子邮件 | 非必须 | 发送方的电子邮件 如: `xxxxxxxxx@qq.com` |
| `SMTP_PASS` | 电子邮件 | 非必须 | smtp服务对应的授权码 |
| `SMTP_TO_USER` | 电子邮件 | 非必须 | 接收方电子邮件 |
| Name | 归属 | 说明 |
| :---------------: | :--------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SCKEY` | 微信server酱推送(于2021/4月下线) | server酱的微信通知[官方文档](http://sc.ftqq.com/3.version) |
| `SENDKEY` | 微信server酱(Turbo版)推送 | [获取SENDKEY](https://sct.ftqq.com/sendkey) [选择消息通道](https://sct.ftqq.com/forward) |
| `BARK_PUSH` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | IOS用户下载BARK这个APP,填写内容是app提供的`设备码`,例如:<https://api.day.app/123> ,那么此处的设备码就是`123`,再不懂看 [这个图](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/bark.jpg)(注:支持自建填完整链接即可) |
| `BARK_SOUND` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | bark推送声音设置,例如`choo`,具体值请在`bark`-`推送铃声`-`查看所有铃声` |
| `TG_BOT_TOKEN` | telegram推送 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写自己申请[@BotFather](https://t.me/BotFather)的Token,如`10xxx4:AAFcqxxxxgER5uw` , [具体教程](doc/TG_PUSH.md) |
| `TG_USER_ID` | telegram推送 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写[@getuseridbot](https://t.me/getuseridbot)中获取到的纯数字ID, [具体教程](doc/TG_PUSH.md) |
| `TG_PROXY_HOST` | Telegram 代理的 IP | 代理类型为 http。例子:http代理 <http://127.0.0.1:1080> 则填写 127.0.0.1 |
| `TG_PROXY_PORT` | Telegram 代理的端口 | 例子:http代理 <http://127.0.0.1:1080> 则填写 1080 |
| `DD_BOT_TOKEN` | 钉钉推送 | 钉钉推送(`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需)[官方文档](https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq) ,只需`https://oapi.dingtalk.com/robot/send?access_token=XXX` 等于`=`符号后面的XXX即可 |
| `DD_BOT_SECRET` | 钉钉推送 | (`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需) ,密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的`SECXXXXXXXXXX`等字符 , 注:钉钉机器人安全设置只需勾选`加签`即可,其他选项不要勾选,再不懂看 [这个图](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/DD_bot.png) |
| `IGOT_PUSH_KEY` | iGot推送 | iGot聚合推送,支持多方式推送,确保消息可达。 [参考文档](https://wahao.github.io/Bark-MP-helper ) |
| `QQ_SKEY` | 酷推(Cool Push)推送 | 推送所需的Skey,登录后获取Skey [参考文档](https://cp.xuthus.cc/) |
| `QQ_MODE` | 酷推(Cool Push)推送 | 推送方式(send或group或者wx,默认send) [参考文档](https://cp.xuthus.cc/) |
| `QYWX_AM` | 企业微信应用 | 第一个值是企业id,第二个值是secret,第三个值@all(或者成员id),第四个值是AgentID (逗号分割) 可查看此[教程](http://note.youdao.com/s/HMiudGkb) [官方文档](https://developer.work.weixin.qq.com/document/path/90236) |
| `QYWX_KEY` | 企业微信Bot推送 | 密钥,企业微信推送 webhook 后面的 key [详见官方说明文档](https://work.weixin.qq.com/api/doc/90000/90136/91770) |
| `PUSH_PLUS_TOKEN` | pushplus推送 | 微信扫码登录后一对推送或一对多推送下面的token(您的Token) [官方网站](http://pushplus.hxtrip.com/) |
| `PUSH_PLUS_USER` | pushplus推送 | 一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码)注:(1、需订阅者扫描二维码 2、如果您是创建群组所属人,也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送),只填`PUSH_PLUS_TOKEN`默认为一对一推送 |
| `QMSG_KEY` | [Qmsg酱](https://qmsg.zendee.cn)私聊推送 | [Qmsg注册](https://qmsg.zendee.cn/login.html) |
| `QMSG_QQ` | 私聊消息推送接口,指定需要接收消息的QQ | 指定的QQ号必须在你的[管理台](https://qmsg.zendee.cn/me.html)已添加 |
| `SMTP_HOST` | 电子邮件 | smtp服务器的主机名 如: `smtp.qq.com` |
| `SMTP_PORT` | 电子邮件 | smtp服务器的端口 如: `465` |
| `SMTP_USER` | 电子邮件 | 发送方的电子邮件 如: `xxxxxxxxx@qq.com` |
| `SMTP_PASS` | 电子邮件 | smtp服务对应的授权码 |
| `SMTP_TO_USER` | 电子邮件 | 接收方电子邮件 |
----------------------------------------
@@ -301,8 +206,11 @@ rm -rf lottery/
详见[my_config.example.js](./my_config.example.js)文件内部注释
----------------------------------------
## Awesome
相关项目
- [LotteryAutoScript_Station](https://github.com/spiritLHL/LotteryAutoScript_Station) - @spiritLHL
- [sync_lottery](https://github.com/spiritLHL/sync_lottery) - @spiritLHL
- [LotteryAutoScript_Station](https://github.com/spiritLHLS/LotteryAutoScript_Station) - [@spiritLHL](https://github.com/spiritLHLS)
- [sync_lottery](https://github.com/spiritLHLS/sync_lottery) - [@spiritLHL](https://github.com/spiritLHLS)
- [BDSF](https://github.com/spiritLHLS/BDSF) - [@spiritLHL](https://github.com/spiritLHLS)
+3 -3
View File
@@ -4,16 +4,16 @@
.首先在Telegram上搜索[BotFather](https://t.me/BotFather)机器人<br>
![TG_PUSH1](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/TG_PUSH1.png)
![TG_PUSH1](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/TG_PUSH1.png)
Ⅱ.利用[BotFather](https://t.me/BotFather)创建一个属于自己的通知机器人,按照下图中的1、2、3步骤拿到token,格式形如```10xxx4:AAFcqxxxxgER5uw```。填入```TG_BOT_TOKEN```<br>
![TG_PUSH2](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/TG_PUSH2.png)<br>
![TG_PUSH2](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/TG_PUSH2.png)<br>
**新创建的机器人需要跟它发一条消息来开启对话,否则可能会遇到secret填对了但是收不到消息的情况**<br>
Ⅲ.再次在Telegram上搜索[getuserIDbot](https://t.me/getuserIDbot)机器人,获取UserID。填入```TG_USER_ID```<br>
![TG_PUSH3](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/TG_PUSH3.png)
![TG_PUSH3](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/TG_PUSH3.png)
至此,获取**TG_BOT_TOKEN**以及**TG_USER_ID**的教程结束
+1 -1
View File
@@ -73,7 +73,7 @@ PATH=/sbin:/bin:/usr/sbin/:/usr/bin
看看有没有效果
![image-start](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/image-start.png)
![image-start](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/image-start.png)
7.如果本地的脚本需要更新
Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 KiB

After

Width:  |  Height:  |  Size: 221 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

+43
View File
@@ -0,0 +1,43 @@
1.初始化
```bash
curl -fsSL https://cdn.staticaly.com/gh/shanmiteko/LotteryAutoScript/main/script/docker/init.sh | sudo sh
```
进入`lottery`文件夹
```bash
cd lottery
```
编辑`env.js``my_config.js`文件
- env.js 设置必要环境变量
- my_config.js 你的设置
2.执行相应的脚本
```
$ tree
.
├── check.sh 检查中奖
├── clear.sh 清理动态
├── debug.sh 进入临时容器查看内容
├── env.js
├── my_config.js
├── new_env.js
├── new_my_config.js
├── remove_all.sh 移除对应docker镜像和所有相关容器
└── start.sh 启动抽奖
```
[![asciicast](https://asciinema.org/a/453237.svg)](https://asciinema.org/a/453237)
完成配置后
```sh
$ ./start.sh
```
3.更新
进入lottery上一级目录
使用与初始化相同的命令
+17
View File
@@ -0,0 +1,17 @@
1. 脚本初始化
复制脚本内容[qinglong](../script/qinglong/init.sh)
![ql0](pic/ql0.gif)
2. 新建任务
![ql1](pic/ql1.png)
![ql2](pic/ql2.png)
3. 填入cookie 修改设置
![ql3](pic/ql3.gif)
4. 脚本更新即再次运行初始化脚本
+61
View File
@@ -0,0 +1,61 @@
##### Windows
step1: 下载代码到本地
[点此下载](https://github.com/shanmiteko/LotteryAutoScript/archive/refs/heads/main.zip)或如图示下载↓
![点我加载下载操作图示](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/download.png)
下载的压缩包解压后修改env.example.js文件,详见step3
step2: 下载并安装Node.js
[点此进入nodejs下载页面](http://nodejs.cn/download)
![点我加载下载nodejs操作图示](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/nodejs.png)
step3:修改env.example.js文件及创建运行文件(打开扩展名显示)
1.step1下载的压缩包解压后将其中的`env.example.js`文件重命名为`env.js`
2.右键`env.js`文件选择编辑或用记事本打开
3.填入相关参数
4.`my_config.example.js`同样操作
5.运行
注: `npm i`意味安装依赖, 只需运行一次, 为防止依赖有变化遂每次都执行
命令一: 启动抽奖
```bash
npm i && npm run start
```
命令二: 检查中奖
```bash
npm i && npm run check
```
命令三: 清理动态
```bash
npm i && npm run clear
```
`script`目录下有启动脚本, 点击即可运行
注: **本地运行时可在设置中增大扫描页数**
> [windows系统定时运行](./win_schedule.md)
脚本已内置定时运行功能
##### Linux
> [linux系统配置与定时运行](./linux_schedule.md)
脚本已内置定时运行功能
+3 -3
View File
@@ -16,13 +16,13 @@
7.在`操作`页面中点击`新建`,选择操作为`启动程序`,在设置里点击浏览找到`start.bat`文件并选择,在`起始于(可选)(T)`中的空白框里输入`start.bat`文件的目录地址,也就是`程序或脚本(P)``start.bat`的前面那一串目录地址,最后是以`\`结尾的 ,填好东西后按下面`确认`
![点我加载步骤7结果图示](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/step_menu.png)
![点我加载步骤7结果图示](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/step_menu.png)
8.在`条件`页面中选择`网络`,设定启动条件为任何连接
9.在`设置`页面中选择如图示选项,或者不修改默认设置
![点我加载步骤9结果图示](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/shezhi_renwu.png)
![点我加载步骤9结果图示](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/shezhi_renwu.png)
10.最后按`确定`
@@ -30,6 +30,6 @@
最后你可以在任务列表中选择已有的任务,右边的操作框中选择`运行`点击,启动计划的任务,如下图所示
![点我加载运行图示](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/start_renwu.png)
![点我加载运行图示](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/start_renwu.png)
具体看任务是否正常执行,你可以看看自己的账号动态的最新转发,运行成功每几分钟自动转发抽奖动态
+22 -1
View File
@@ -2,6 +2,7 @@ module.exports = Object.freeze({
/**
* ## 账号相关
* - `COOKIE` 是必填项
* - `NOTE` 帐号备注
* - `NUMBER` 表示是第几个账号
* - `CLEAR` 是否启用清理功能
* - `ENABLE_MULTIPLE_ACCOUNT` 是否启用多账号
@@ -18,6 +19,7 @@ module.exports = Object.freeze({
*/
account_parm: {
COOKIE: "",
NOTE: "",
NUMBER: 1,
CLEAR: true,
@@ -30,11 +32,27 @@ module.exports = Object.freeze({
/**
* 为防止环境变量过长, 请将多账号填在此处
* 以大括号内容为模板依次复制(包含大括号),逗号分割
* 以 **大括号内容** 为模板依次复制(包含大括号),逗号分割
*
* ```txt
* [
* {
* ...
* NUMBER: 1
* ...
* },
* {
* ...
* NUMBER: 2
* ...
* }
* ]
* ```
*/
multiple_account_parm: [
{
COOKIE: "",
NOTE: "",
NUMBER: 1,
CLEAR: true,
WAIT: 60 * 1000
@@ -57,10 +75,13 @@ module.exports = Object.freeze({
TG_PROXY_PORT: "",
DD_BOT_TOKEN: "",
DD_BOT_SECRET: "",
QYWX_AM: "",
QYWX_KEY: "",
IGOT_PUSH_KEY: "",
PUSH_PLUS_TOKEN: "",
PUSH_PLUS_USER: "",
QMSG_KEY: "",
QMSG_QQ: "",
SMTP_HOST: "",
SMTP_PORT: "",
SMTP_USER: "",
+43 -23
View File
@@ -6,34 +6,55 @@ const bili = require('./net/bili')
/**
* 是否中奖
* @param {number} num
*/
async function isMe() {
async function isMe(num) {
let desp = '';
const
{ notice_key_words, update_session_wait, get_session_wait } = config,
UnreadAtNum = await bili.getUnreadAtNum(),
UnreadSessionNum = await bili.getUnreadSessionNum(),
{ follow_unread, unfollow_unread } = UnreadSessionNum || { unfollow_unread: 0, follow_unread: 0 };
if (UnreadAtNum > 0) {
{ notice_key_words, update_session_wait, get_session_wait, check_session_pages } = config,
{ at: unread_at_num, reply: unread_reply_num } = await bili.getUnreadNum(),
unread_session_num = await bili.getUnreadSessionNum(),
{ follow_unread, unfollow_unread } = unread_session_num || { unfollow_unread: 0, follow_unread: 0 };
if (unread_at_num) {
log.info('中奖检测', '<-- 正在检查at');
const MyAtInfo = await bili.getMyAtInfo();
MyAtInfo.forEach(async AtInfo => {
const { at_time, up_uname, business, source_content, url } = AtInfo
desp += '## [at]检测结果\n\n'
desp += '----------------------------------------------------------------\n\n'
desp += `发生时间: ${new Date(at_time * 1000).toLocaleString()}\n\n`
desp += `用户: ${up_uname}\n\n`
desp += `${business}中@了你(${global_var.get("myUID")})\n\n`
desp += `原内容为: ${source_content}\n\n`
desp += `[直达链接](${url})\n\n`
desp += '----------------------------------------------------------------\n\n'
});
MyAtInfo
.slice(0, unread_at_num)
.forEach(({ at_time, up_uname, business, source_content, url }) => {
desp += '## [at]检测结果\n\n'
desp += '- - - -\n\n'
desp += `发生时间: ${new Date(at_time * 1000).toLocaleString()}\n\n`
desp += `用户: ${up_uname}\n\n`
desp += `${business}中@了你(https://space.bilibili.com/${global_var.get("myUID")})\n\n`
desp += `原内容为: ${source_content}\n\n`
desp += `[直达链接](${url})\n\n`
desp += '- - - -\n\n'
});
log.info('中奖检测', '--> OK');
}
if (unread_reply_num) {
log.info('中奖检测', '<-- 正在检查回复');
const replys = await bili.getReplyMsg();
replys
.slice(0, unread_reply_num)
.forEach(({ nickname, uri, source, timestamp }) => {
if (judge(source, notice_key_words)) {
desp += '## 回复检测结果\n\n'
desp += '- - - -\n\n'
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()}\n\n`
desp += `用户: ${nickname}\n\n`
desp += `回复你(https://space.bilibili.com/${global_var.get("myUID")})说:\n${source}\n\n`
desp += `[直达链接](${uri})\n\n`
desp += '- - - -\n\n'
}
})
log.info('中奖检测', '--> OK');
}
if (follow_unread + unfollow_unread > 0) {
const check = async (type) => {
let session_t = '';
let MySession = await bili.getSessionInfo(type)
log.info("准备检查私信", check_session_pages + "页")
for (const index of infiniteNumber()) {
for (const Session of MySession.data) {
const { sender_uid, session_ts, timestamp, unread_count, talker_id, msg_seqno } = Session;
@@ -42,18 +63,18 @@ async function isMe() {
const content = await bili.fetch_session_msgs(talker_id, unread_count);
if (judge(content, notice_key_words)) {
desp += '## 私信检测结果\n\n'
desp += '----------------------------------------------------------------\n\n'
desp += '- - - -\n\n'
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()}\n\n`
desp += `用户: ${sender_uid}\n\n`
desp += `私信你(${global_var.get("myUID")})说:\n${content}\n\n`
desp += `私信你(https://space.bilibili.com/${global_var.get("myUID")})说:\n${content}\n\n`
desp += `[直达链接](https://message.bilibili.com/#/whisper/mid${sender_uid})\n\n`
desp += '----------------------------------------------------------------\n\n'
desp += '- - - -\n\n'
}
await bili.updateSessionStatus(talker_id, type, msg_seqno);
await delay(update_session_wait);
}
}
if (MySession.has_more && index < 16) {
if (MySession.has_more && index < check_session_pages) {
await delay(get_session_wait);
MySession = await bili.getSessionInfo(type, session_t)
} else {
@@ -72,9 +93,8 @@ async function isMe() {
log.info('中奖检测', '--> OK');
}
if (desp) {
desp += '中奖了别忘给脚本(https://github.com/shanmiteko/LotteryAutoScript)点一个Star哦, 赞助一两块也不是不可以‍_(:з」∠)_\n\n'
log.info('可能中奖了', desp);
await sendNotify('可能中奖了', desp);
await sendNotify(`帐号${num}可能中奖了`, desp);
} else {
log.info('中奖检测', "暂未中奖");
}
+11 -7
View File
@@ -1,4 +1,4 @@
const { log, delay, infiniteNumber } = require("./utils");
const { log, delay, infiniteNumber, retryfn } = require("./utils");
const bili = require("./net/bili");
const { Searcher } = require("./core/searcher");
const global_var = require('./data/global_var');
@@ -17,7 +17,7 @@ async function getFollowList() {
log.info('获取关注列表', '未能成功获取关注分区id');
return rmup
}
for (let index = 1; index < 42; index++) {
for (let index = 1; index < 100; index++) {
const uids = await bili.getPartitionUID(tagid, index);
await delay(get_partition_wait);
if (!uids.length) break;
@@ -46,7 +46,7 @@ async function clear() {
for (const [index, uid] of uid_list.entries()) {
log.info('清理关注', `(${index}) (${uid})`)
/* 取消关注 */
if (await bili.cancelAttention(uid)) {
if (await retryfn(3, [false], () => bili.cancelAttention(uid))) {
log.info('清理关注', '成功')
} else {
log.error('清理关注', '失败')
@@ -65,7 +65,11 @@ async function clear() {
for (const page of infiniteNumber()) {
log.info('清理动态', `开始读取第${page + 1}`);
const { allModifyDynamicResArray, offset } = await Searcher.checkAllDynamic(MY_UID, 1, search_wait, next_offset);
const { allModifyDynamicResArray, offset } = (await retryfn(
3,
[null],
() => Searcher.checkAllDynamic(MY_UID, 1, search_wait, next_offset)
)) || { allModifyDynamicResArray: [], offset: '0' };
next_offset = offset;
for (const [index, dyinfo] of allModifyDynamicResArray.entries()) {
log.info('清理动态', `${page + 1}页中的第${index + 1}个动态`)
@@ -82,7 +86,7 @@ async function clear() {
if (dynamic_id
&& clear_remove_dynamic
&& !(new RegExp(dynamic_id).test(clear_white_list))) {
success = await bili.rmDynamic(dynamic_id)
success = await retryfn(3, [false], () => bili.rmDynamic(dynamic_id))
}
/* 取消关注 */
@@ -91,7 +95,7 @@ async function clear() {
&& clear_remove_attention
&& before_separate.indexOf(origin_uid) === -1
&& uid_list.indexOf(origin_uid) > -1) {
success = await bili.cancelAttention(origin_uid);
success = await retryfn(3, [false], () => bili.cancelAttention(origin_uid))
}
if (!success) {
@@ -122,4 +126,4 @@ async function clear() {
}
module.exports = { clear }
module.exports = { clear }
+341 -125
View File
@@ -1,4 +1,4 @@
const { log, hasEnv, shuffle, getRandomOne, delay, try_for_each } = require('../utils');
const { log, hasEnv, shuffle, getRandomOne, delay, try_for_each, retryfn, appendLotteryInfoFile } = require('../utils');
const { send } = require('../net/http');
const bili = require('../net/bili');
const { sendNotify } = require('../helper/notify');
@@ -7,6 +7,7 @@ const { randomDynamic } = require('../helper/randomDynamic')
const { Searcher } = require('./searcher');
const global_var = require("../data/global_var");
const config = require("../data/config");
const d_storage = require('../helper/d_storage');
/**
* 监视器
@@ -45,35 +46,57 @@ class Monitor extends Searcher {
}
/** 关注列表初始化 */
this.attentionList = await bili.getAttentionList(global_var.get("myUID"));
switch (await this.startLottery()) {
const status = await this.startLottery();
switch (status) {
case 0:
event_bus.emit('Turn_on_the_Monitor')
break;
case 11:
case 1001:
event_bus.emit('Turn_off_the_Monitor', '评论失败')
break;
case 1004:
event_bus.emit('Turn_off_the_Monitor', '需要输入验证码')
break
case 21:
case 2001:
event_bus.emit('Turn_off_the_Monitor', '关注出错')
break
case 22:
break;
case 3001:
event_bus.emit('Turn_off_the_Monitor', '分区移动出错')
break;
case 2004:
log.warn('账号异常', `UID(${global_var.get('myUID')})异常号只会对部分UP出现关注异常`)
if (!config.is_exception) {
await sendNotify('[动态抽奖]账号异常通知', `UID: ${global_var.get('myUID')}\n\n异常号只会对部分UP出现关注异常\n\n可在设置中令is_exception为true关闭此推送`)
await sendNotify(
'[动态抽奖]账号异常通知',
`UID: ${global_var.get('myUID')}\n异常号只会对部分UP出现关注异常\n可在设置中令is_exception为true关闭此推送\n${log._cache.filter(it => /Error|\s抽奖信息\]/.test(it)).join('\n')}`
)
}
config.is_exception = true;
event_bus.emit('Turn_on_the_Monitor')
break
case 31:
case 2005:
log.warn('关注已达上限', `UID(${global_var.get('myUID')})关注已达上限,已临时进入只转已关注模式`)
if (!config.is_outof_maxfollow) {
await sendNotify(
'[动态抽奖]关注已达上限',
`UID: ${global_var.get('myUID')}\n关注已达上限,已临时进入只转已关注模式\n可在设置中令is_outof_maxfollow为true关闭此推送\n${log._cache.filter(it => /Error|\s抽奖信息\]/.test(it)).join('\n')}`
)
}
config.is_outof_maxfollow = true;
config.only_followed = true;
event_bus.emit('Turn_on_the_Monitor')
break
case 5001:
event_bus.emit('Turn_off_the_Monitor', '转发失败')
break
case 41:
case 6001:
event_bus.emit('Turn_off_the_Monitor', '获取开奖时间失败')
break
case 51:
case 7001:
event_bus.emit('Turn_off_the_Monitor', '获取关注数失败')
break
default:
event_bus.emit('Turn_off_the_Monitor', '未知错误')
event_bus.emit('Turn_off_the_Monitor', `??? 未知错误: ${status}`)
break;
}
}
@@ -89,35 +112,59 @@ class Monitor extends Searcher {
log.info('筛选动态', `筛选完毕(${len})`);
if (len) {
let is_exception = false;
for (const [index, Lottery] of shuffle(allLottery).entries()) {
let status = 0;
let
status = 0,
is_exception = 0,
is_outof_maxfollow = 0,
relayed_nums = 0,
total_nums = 0;
for (const [index, lottery] of shuffle(allLottery).entries()) {
total_nums += 1;
let is_shutdown = false;
if (
is_outof_maxfollow
&& lottery.uid.length
&& (new RegExp(lottery.uid.join('|'))).test(this.attentionList)
) {
log.info('过滤', `已关注(${lottery.uid.join(',')})`)
continue
}
if (Lottery.isOfficialLottery) {
let { ts } = await bili.getLotteryNotice(Lottery.dyid);
if (lottery.isOfficialLottery) {
let { ts } = await bili.getLotteryNotice(lottery.dyid);
const ts_10 = Date.now() / 1000;
if (ts < 0) {
return 41
status = 6001
break;
}
if (ts < ts_10) {
log.info('过滤', '已过开奖时间')
d_storage.updateDyid(lottery.dyid)
await delay(filter_wait)
continue
}
if (ts > ts_10 + config.maxday * 86400) {
log.info('过滤', '超过指定开奖时间')
d_storage.updateDyid(lottery.dyid)
await delay(filter_wait)
continue
}
} else if (Lottery.uid[0]) {
const followerNum = await bili.getUserInfo(Lottery.uid[0]);
if (followerNum < 0) {
return 51
}
if (followerNum < config.minfollower) {
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
await delay(filter_wait)
continue
} else if (lottery.uid[0]) {
const { minfollower } = config
if (minfollower > 0) {
const followerNum = await bili.getUserInfo(lottery.uid[0]);
if (followerNum < 0) {
status = 7001
break;
}
if (followerNum < minfollower) {
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
d_storage.updateDyid(lottery.dyid)
await delay(filter_wait)
continue
}
} else {
log.info('过滤', "不过滤粉丝数")
}
}
@@ -130,27 +177,55 @@ class Monitor extends Searcher {
randomDynamic(number)
}
status = await this.go(Lottery)
status = await this.go(lottery)
switch (status) {
case 0:
case 9:
case 19:
relayed_nums += 1
break;
case 22:
is_exception = true
case 1002:
case 1003:
case 1005:
case 1006:
case 1007:
case 1008:
case 1009:
case 1010:
case 1011:
case 2002:
case 2003:
case 4001:
case 4002:
case 4003:
case 5002:
case 5003:
case 5004:
status = 0
break;
case 2004:
is_exception = 2004
break;
case 2005:
is_outof_maxfollow = 2005
break;
case 1001:
case 1004:
case 2001:
case 3001:
case 5001:
is_shutdown = true
break;
default:
return status
}
if (is_shutdown) break
d_storage.updateDyid(lottery.dyid)
await delay(wait * (Math.random() + 0.5));
}
log.info('抽奖', '开始转发下一组动态');
if (is_exception) {
return 22
} else {
return 0
}
log.info('抽奖', `本轮共处理${total_nums}条,成功参与${relayed_nums}`);
return is_exception
|| is_outof_maxfollow
|| status
} else {
log.info('抽奖', '无未转发抽奖');
return 0
@@ -165,8 +240,9 @@ class Monitor extends Searcher {
* @property {boolean} isOfficialLottery 是否官方抽奖
* @property {string} relay_chat 转发词
* @property {string} ctrl 定位@
* @property {string} rid 评论标识
* @property {string} [rid] 评论标识
* @property {number} chat_type 评论类型
* @property {string} [chat] 评论词
*/
/**
* @returns {Promise<LotteryOptions[]>}
@@ -183,12 +259,10 @@ class Monitor extends Searcher {
log.info('筛选动态', `开始筛选(${protoLotteryInfo.length})`);
log.debug('未进行筛选的动态信息', protoLotteryInfo);
/** 所有抽奖信息 */
let alllotteryinfo = [];
const
{ set_lottery_info_url, key_words, model, chatmodel, max_create_time, is_imitator, only_followed, at_users, blockword, blacklist } = config,
{ check_if_duplicated, save_lottery_info_to_file, set_lottery_info_url, disable_reserve_lottery, reserve_lottery_wait, sneaktower, key_words, model, chatmodel, chat: chats, relay: relays, block_dynamic_type, max_create_time, is_imitator, only_followed, at_users, blockword, blacklist, use_public_blacklist } = config,
now_ts = Date.now() / 1000;
/**
@@ -205,8 +279,27 @@ class Monitor extends Searcher {
return true
});
log.info('筛选动态', `去重后(${protoLotteryInfo.length})`);
/**并发查询dyid */
if (check_if_duplicated >= 1) {
await Promise.all(
[...dyids_map.keys()]
.map(it => d_storage
.searchDyid(it)
.then(hasIt => dyids_map.set(it, hasIt))
)
)
log.info('筛选动态', `并发查询本地dyid完毕`);
}
if (lottery_param[0] !== "APIs" && save_lottery_info_to_file && protoLotteryInfo.length) {
log.info("保存抽奖信息", "保存开始")
await appendLotteryInfoFile(lottery_param[1].toString(), protoLotteryInfo)
}
if (lottery_param[0] !== "APIs" && set_lottery_info_url && protoLotteryInfo.length) {
log.info("上传抽奖信息", "开始")
log.info("上传抽奖信息", "上传开始")
await new Promise((resolve) => {
send({
url: set_lottery_info_url,
@@ -228,53 +321,128 @@ class Monitor extends Searcher {
}
/* 检查动态是否满足要求 */
await try_for_each(protoLotteryInfo, async function ({
lottery_info_type, is_liked,
uids, uname, dyid, create_time,
ctrl, rid, des, type,
hasOfficialLottery
}) {
/* 遇到转发过就退出 */
if (is_liked) return false;
await try_for_each(protoLotteryInfo, async function (lottery_info) {
const {
lottery_info_type, is_liked,
uids, uname, dyid, reserve_id, reserve_lottery_text, create_time,
ctrl, rid, des, type,
hasOfficialLottery
} = lottery_info;
log.debug('正在筛选的动态信息', lottery_info);
if (lottery_info_type.startsWith('sneak') && sneaktower) {
log.info("筛选动态", `偷塔模式不检查是否已转发(https://t.bilibili.com/${dyid})`)
} else {
/* 遇到转发过就退出 */
if (
((!check_if_duplicated || check_if_duplicated >= 2) && is_liked)
|| ((check_if_duplicated >= 1) && dyids_map.get(dyid))
) {
log.info("筛选动态", `已转发(https://t.bilibili.com/${dyid})`)
return false
}
}
/* 超过指定时间退出 */
if (now_ts - create_time > max_create_time * 86400) return false;
if (now_ts - create_time > max_create_time * 86400) {
log.info("筛选动态", `过时动态(https://t.bilibili.com/${dyid})`)
return false
}
const
/**判断是转发源动态还是现动态 */
uid = lottery_info_type === 'uid' ? uids[1] : uids[0],
isFollowed = (new RegExp(uid)).test(attentionList),
description = typeof des === 'string' ? des : '',
[m_uid, ori_uid] = uids,
mIsFollowed = !m_uid || (new RegExp(m_uid)).test(attentionList),
oriIsFollowed = !ori_uid || (new RegExp(ori_uid)).test(attentionList),
/**判断是转发源动态还是现动态 实际发奖人*/
[real_uid, realIsFollowed] = lottery_info_type === 'uid'
? [ori_uid, oriIsFollowed]
: [m_uid, mIsFollowed],
description = des.split(/\/\/@.*?:/)[0],
needAt = /(?:@|艾特)[^@|(艾特)]*?好友/.test(description),
needTopic = [...new Set(description.match(/(?<=[带加上](?:话题|tag).*)#.+?#|(?<=[带加上])#.+?#(?=话题|tag)/ig) || [])].join(' '),
isRelayDynamic = type === 1,
isTwoLevelDynamic = /\/\/@/.test(description),
has_key_words = key_words.every(it => new RegExp(it).test(description)),
isBlock = new RegExp(blockword.join('|')).test(description),
isBlock = blockword.length && new RegExp(blockword.join('|')).test(description + reserve_lottery_text),
isLottery =
(is_imitator && lottery_info_type === 'uid' && model !== '00')
|| (hasOfficialLottery && model[0] === '1')
|| (!hasOfficialLottery && model[1] === '1' && !isTwoLevelDynamic && has_key_words),
|| (!hasOfficialLottery && model[1] === '1' && has_key_words),
isSendChat =
(is_imitator && lottery_info_type === 'uid' && chatmodel !== '00')
|| (hasOfficialLottery && chatmodel[0] === '1')
|| (!hasOfficialLottery && chatmodel[1] === '1');
|| (!hasOfficialLottery && chatmodel[1] === '1'),
{ blacklist: remote_blacklist } = use_public_blacklist === false
? { blacklist: "" }
: global_var.get("remoteconfig"),
/**
* 获取黑名单并去重合并
* @type {string[]}
*/
new_blacklist = remote_blacklist
? [
...new Set([...blacklist.split(','),
...remote_blacklist.split(',')])
]
: blacklist.split(','),
keys = [dyid, m_uid, ori_uid];
log.debug("筛选动态", { real_uid, mIsFollowed, oriIsFollowed, realIsFollowed, needAt, needTopic, type, isRelayDynamic, key_words, has_key_words, blockword, isBlock, isLottery, isSendChat })
if (
new_blacklist.some(id => keys.some(key => {
if (key + '' === id) {
log.info("筛选动态", `黑名单匹配(${id})(https://t.bilibili.com/${dyid})`)
return true
} else {
return false
}
}))
) {
return false
}
if (block_dynamic_type.includes(type)) {
log.warn("筛选动态", `屏蔽动态类型 ${type}`)
return false
}
/**屏蔽词 */
if (isBlock) return false;
if (isBlock) {
log.info("筛选动态", `包含屏蔽词(https://t.bilibili.com/${dyid})`)
return false
}
if (reserve_id) {
if (disable_reserve_lottery) {
log.info("已关闭预约抽奖功能")
} else {
log.info("预约抽奖", "开始");
log.info("预约抽奖", `奖品: ${reserve_lottery_text}`);
if (hasEnv('NOT_GO_LOTTERY')) {
log.info('NOT_GO_LOTTERY', 'ON');
} else {
await delay(reserve_lottery_wait);
await bili.reserve_lottery(reserve_id)
}
}
}
if (!has_key_words && description) {
log.warn("筛选动态", `无关键词动态的描述: ${description}\n\n考虑是否修改设置key_words:\n${key_words.join('\n且满足: ')}`)
return false
}
/**若勾选只转已关注 */
if (only_followed && !isFollowed) return false;
/* 获取黑名单并去重合并 */
const { blacklist: remote_blacklist } = global_var.get("remoteconfig")
, new_blacklist = remote_blacklist
? [...new Set([...blacklist.split(','), ...remote_blacklist.split(',')])].join()
: blacklist;
if ((new RegExp(dyid + '|' + uid)).test(new_blacklist)) return false;
if (only_followed
&& (!mIsFollowed || !oriIsFollowed)
) {
log.info("筛选动态", `只转已关注(https://t.bilibili.com/${dyid})`)
return false
}
if (isLottery) {
const { uname_map = {} } = global_var.get("remoteconfig")
let onelotteryinfo = {};
onelotteryinfo.isOfficialLottery = hasOfficialLottery;
@@ -282,15 +450,16 @@ class Monitor extends Searcher {
/**初始化待关注列表 */
onelotteryinfo.uid = []
if (!isFollowed) {
onelotteryinfo.uid.push(uid);
if (!realIsFollowed) {
onelotteryinfo.uid.push(real_uid);
}
onelotteryinfo.dyid = dyid;
let
/**转发评语 */
RandomStr = getRandomOne(config.relay),
RandomStr = getRandomOne(relays)
.replace(/\$\{uname\}/g, uname_map[real_uid] || uname),
/**控制字段 */
new_ctrl = [];
@@ -318,7 +487,7 @@ class Monitor extends Searcher {
const addlength = RandomStr.length + 2 + uname.length + 1 + 1;
onelotteryinfo.relay_chat = RandomStr + `//@${uname}:` + des;
new_ctrl.push({
data: String(uid),
data: String(real_uid),
location: RandomStr.length + 2,
length: uname.length + 1,
type: 1
@@ -327,8 +496,9 @@ class Monitor extends Searcher {
item.location += addlength;
return item;
}).forEach(it => new_ctrl.push(it))
if (!(new RegExp(uids[1])).test(attentionList))
onelotteryinfo.uid.push(uids[1]);
if (!oriIsFollowed) {
onelotteryinfo.uid.push(ori_uid);
}
} else {
onelotteryinfo.relay_chat = RandomStr;
}
@@ -346,9 +516,15 @@ class Monitor extends Searcher {
: 0;
/* 是否评论 */
if (isSendChat) onelotteryinfo.rid = rid;
if (isSendChat) {
onelotteryinfo.rid = rid
onelotteryinfo.chat = getRandomOne(chats)
.replace(/\$\{uname\}/g, uname_map[real_uid] || uname)
}
alllotteryinfo.push(onelotteryinfo);
} else {
log.info("筛选动态", `非抽奖动态(https://t.bilibili.com/${dyid})`)
}
})
@@ -358,13 +534,31 @@ class Monitor extends Searcher {
* 关注转发评论
* @param {LotteryOptions} option
* @returns {Promise<number>}
* 0 - 成功
* 9 - 评论黑名单/评论区关闭/动态删除
* 11 - 评论错误
* 19 - 关注黑名单
* 21 - 关注错误
* 22 - 关注异常
* 31 - 转发失败
* - 成功 0
* - 评论 未知错误 1001
* - 评论 原动态已删除 1002
* - 评论 评论区已关闭 1003
* - 评论 需要输入验证码 1004
* - 评论 已被对方拉入黑名单 1005
* - 评论 黑名单用户无法互动 1006
* - 评论 UP主已关闭评论区 1007
* - 评论 内容包含敏感信息 1008
* - 评论 重复评论 1009
* - 评论 帐号未登录 1010
* - 评论 关注UP主7天以上的人可发评论 1011
* - 关注 未知错误 2001
* - 关注 您已被对方拉入黑名单 2002
* - 关注 黑名单用户无法关注 2003
* - 关注 账号异常 2004
* - 关注 关注已达上限 2005
* - 分区 移动失败 3001
* - 点赞 未知错误 4001
* - 点赞 点赞异常 4002
* - 点赞 点赞频繁 4003
* - 转发 未知错误 5001
* - 转发 该动态不能转发分享 5002
* - 转发 请求数据发生错误,请刷新或稍后重试 5003
* - 转发 操作太频繁了,请稍后重试 5004
*/
async go(option) {
log.debug('正在转发的动态信息', option);
@@ -373,63 +567,85 @@ class Monitor extends Searcher {
return 0
}
const { uid, dyid, chat_type, rid, relay_chat, ctrl } = option;
let status = 0
const
{ uid, dyid, chat_type, rid, relay_chat, ctrl, chat } = option,
{ check_if_duplicated, is_repost_then_chat } = config;
/* 评论 */
if (rid && chat_type) {
let status = 0
const
{ chat } = config,
retry = [...new Array(5).keys()],
max_retry_times = retry.length;
await try_for_each(retry, async (times) => {
status = await bili.sendChat(rid, getRandomOne(chat), chat_type)
switch (status) {
case 0:
return true
case -1:
log.warn('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
return true
default:
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
log.info('自动评论', `将在 ${times + 1} 分钟后再次发送评论(${times + 1}/${max_retry_times})`)
await delay(60 * 1000 * (times + 1))
return false
}
})
if (status) return 10 + status;
status = await retryfn(
6,
[1, 4],
() => bili.sendChat(
rid,
is_repost_then_chat ? relay_chat.split('//')[0] : chat,
chat_type
)
)
if (status === 8 ||
status === 9) {
status = await bili.sendChat(
rid,
"[doge][doge][doge][doge][doge]",
chat_type
)
}
if (status) {
log.warn("抽奖信息", `dyid: ${dyid}, rid: ${rid}, chat_type: ${chat_type}`)
return 1000 + status
}
}
/* 关注 */
if (uid.length) {
let status = 0
await try_for_each(uid, async (u) => {
status = await bili.autoAttention(u)
switch (status) {
case 0:
if (await bili.movePartition(u, this.tagid)) {
log.error('抽奖信息', `uid: ${u},dyid: ${dyid}`)
}
return false
case -1:
case 2:
log.warn('抽奖信息', `uid: ${u},dyid: ${dyid}`)
return true
default:
log.error('抽奖信息', `uid: ${u},dyid: ${dyid}`)
return true
if (status) {
log.warn("抽奖信息", `dyid: ${dyid}, uid: ${u}`)
return true
} else if (await bili.movePartition(u, this.tagid)) {
log.warn("抽奖信息", `dyid: ${dyid}, uid: ${u} tagid: ${this.tagid}`)
/* 3000系错误 */
status = 1001
return true
} else {
return false
}
})
if (status) return 20 + status
if (status) return 2000 + status
}
/* 点赞 */
await bili.autolike(dyid)
if (!check_if_duplicated || check_if_duplicated === 3) {
status = await retryfn(
5,
[1, 2, 3],
() => bili.autolike(dyid)
)
if (status) {
log.warn("抽奖信息", `dyid: ${dyid}`)
return 4000 + status
}
}
/* 转发 */
if (await bili.autoRelay(global_var.get("myUID"), dyid, relay_chat, ctrl)) return 31;
status = await retryfn(
5,
[1, 3, 4],
() => bili.autoRelay(global_var.get("myUID"), dyid, relay_chat, ctrl)
)
return 0
if (status) {
log.warn("抽奖信息", `dyid: ${dyid}`)
return 5000 + status
}
return status
}
}
+148 -77
View File
@@ -1,7 +1,8 @@
const utils = require('../utils');
const bili = require('../net/bili');
const { send } = require("../net/http");
const { article_scan_page, article_create_time, not_check_article, get_dynamic_detail_wait, uid_scan_page, search_wait, tag_scan_page } = require("../data/config");
const { check_if_duplicated, article_scan_page, article_create_time, not_check_article, get_dynamic_detail_wait, uid_scan_page, search_wait, tag_scan_page } = require("../data/config");
const d_storage = require("../helper/d_storage")
const { log } = utils
@@ -17,6 +18,8 @@ const { log } = utils
* @property {string} dynamic_id
* @property {number} type
* @property {string} description
* @property {string} reserve_id
* @property {string} reserve_lottery_text
* @property {boolean} hasOfficialLottery
* @property {Array<Object.<string,string|number>>} ctrl
* @property {number} origin_create_time 10
@@ -26,6 +29,8 @@ const { log } = utils
* @property {string} origin_dynamic_id
* @property {number} orig_type
* @property {string} origin_description
* @property {string} origin_reserve_id
* @property {string} origin_reserve_lottery_text
* @property {boolean} origin_hasOfficialLottery
*
* 整理后的抽奖信息
@@ -37,6 +42,8 @@ const { log } = utils
* @property {string} uname
* @property {Array<{}>} ctrl
* @property {string} dyid
* @property {string} reserve_id
* @property {string} reserve_lottery_text
* @property {string} rid
* @property {string} des
* @property {number} type
@@ -49,10 +56,12 @@ function parseDynamicCard(dynamic_detail_card) {
const { strToJson } = utils;
/**临时储存单个动态中的信息 */
let obj = {};
const { desc, card, extension, extend_json } = dynamic_detail_card
const { desc, card, extension, extend_json, display = {} } = dynamic_detail_card
, { is_liked = 1, user_profile = {} } = desc
, { info = {} } = user_profile
, cardToJson = strToJson(card)
, extendjsonToJson = strToJson(extend_json)
, { add_on_card_info = [] } = display
, { item } = cardToJson;
/* 转发者的UID */
obj.uid = desc.uid
@@ -71,14 +80,33 @@ function parseDynamicCard(dynamic_detail_card) {
/* 转发者的动态ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
obj.dynamic_id = desc.dynamic_id_str;
/* 定位@信息 */
obj.ctrl = (extend_json && strToJson(extend_json).ctrl) || [];
obj.ctrl = (extendjsonToJson.ctrl) || [];
/* 预约抽奖信息 */
if (add_on_card_info.length > 0) {
const [status, oid_str, text] = add_on_card_info
.filter(it => typeof it.reserve_attach_card !== 'undefined'
&& typeof it.reserve_attach_card.reserve_lottery !== 'undefined'
&& typeof it.reserve_attach_card.reserve_button !== 'undefined')
.map(({ reserve_attach_card }) => [
reserve_attach_card.reserve_button.status,
reserve_attach_card.oid_str,
reserve_attach_card.reserve_lottery.text])[0] || [];
if (status === 1) {
obj.reserve_id = oid_str;
obj.reserve_lottery_text = text;
}
}
/* 是否有官方抽奖 */
obj.hasOfficialLottery = extension && extension.lott && true;
/* 转发者的描述 后两个分别是视频动态的描述和视频本身的描述*/
obj.description = (item && (item.content || item.description || cardToJson.dynamic || cardToJson.desc)) || '';
/* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/
obj.description =
(item && (item.content || '' + item.description || ''))
|| (cardToJson.dynamic || '' + cardToJson.desc || '')
|| '';
if (obj.type === 1) {
const { origin_extension, origin } = cardToJson
, originToJson = strToJson(origin)
, { add_on_card_info = [] } = display.origin || {}
, { user, item } = originToJson;
/* 源动态的ts10 */
obj.origin_create_time = desc.origin.timestamp;
@@ -88,12 +116,30 @@ function parseDynamicCard(dynamic_detail_card) {
obj.origin_rid_str = desc.origin.rid_str.length > 12 ? desc.origin.dynamic_id_str : desc.origin.rid_str;
/* 被转发者的动态的ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
obj.origin_dynamic_id = desc.orig_dy_id_str;
/* 预约抽奖信息 */
if (add_on_card_info.length > 0) {
const [status, oid_str, text] = add_on_card_info
.filter(it => typeof it.reserve_attach_card !== 'undefined'
&& typeof it.reserve_attach_card.reserve_lottery !== 'undefined'
&& typeof it.reserve_attach_card.reserve_button !== 'undefined')
.map(({ reserve_attach_card }) => [
reserve_attach_card.reserve_button.status,
reserve_attach_card.oid_str,
reserve_attach_card.reserve_lottery.text])[0] || [];
if (status === 1) {
obj.origin_reserve_id = oid_str;
obj.origin_reserve_lottery_text = text;
}
}
/* 是否有官方抽奖 */
obj.origin_hasOfficialLottery = origin_extension && origin_extension.lott;
/* 被转发者的name */
obj.origin_uname = (user && (user.name || user.uname)) || '';
/* 被转发者的描述 */
obj.origin_description = (item && (item.content || item.description || originToJson.dynamic || originToJson.desc)) || '';
obj.origin_description =
(item && (item.content || '' + item.description || ''))
|| (originToJson.dynamic || '' + originToJson.desc || '')
|| '';
}
return obj
@@ -154,7 +200,7 @@ class Searcher {
* @param {number} pages 读取页数
* @param {number} time 时延
* @param {string} [offset] 默认'0'
* @returns {Promise<{allModifyDynamicResArray: UsefulDynamicInfo[], offset: string}>} 获取前 `pages*12` 个动态信息
* @returns {Promise<{allModifyDynamicResArray: UsefulDynamicInfo[], offset: string} | null>} 获取前 `pages*12` 个动态信息
*/
static async checkAllDynamic(hostuid, pages, time = 0, offset = '0') {
log.info('检查所有动态', `准备读取${pages}页动态`);
@@ -183,7 +229,7 @@ class Searcher {
mDRdata = modifyDynamicRes(OneDynamicInfo);
if (mDRdata === null) {
break;
return null
}
const
@@ -218,9 +264,12 @@ class Searcher {
*/
async getLotteryInfoByUID(UID) {
log.info('获取动态', `开始获取用户${UID}的动态信息`);
const { allModifyDynamicResArray } = await Searcher.checkAllDynamic(UID, uid_scan_page, search_wait);
const AllDynamic = await Searcher.checkAllDynamic(UID, uid_scan_page, search_wait);
let { length } = allModifyDynamicResArray
if (AllDynamic === null) return null
let { allModifyDynamicResArray } = AllDynamic,
{ length } = allModifyDynamicResArray;
if (!length) return null;
@@ -234,35 +283,37 @@ class Searcher {
}
})
.reduce(async (pre, cur) => {
const results = await pre
, { origin_dynamic_id } = cur;
let
results = await pre,
{ origin_dynamic_id } = cur,
is_liked = false;
log.info('获取动态', `查看源动态(${origin_dynamic_id})是否点赞 (${length--})`)
const card = await bili.getOneDynamicByDyid(origin_dynamic_id)
if (card) {
if (!check_if_duplicated || check_if_duplicated >= 2) {
const card = await bili.getOneDynamicByDyid(origin_dynamic_id)
log.info('获取动态', `查看源动态(${origin_dynamic_id})是否点赞 (${length--})`)
if (card) {
({ is_liked } = parseDynamicCard(card))
}
await utils.delay(get_dynamic_detail_wait)
const { is_liked } = parseDynamicCard(card)
return [...results, {
lottery_info_type: 'uid',
create_time: cur.origin_create_time,
is_liked,
uids: [cur.uid, cur.origin_uid],
uname: cur.origin_uname,
ctrl: [],
dyid: cur.origin_dynamic_id,
rid: cur.origin_rid_str,
des: cur.origin_description,
type: cur.orig_type,
hasOfficialLottery: cur.origin_hasOfficialLottery
}]
}
return results
results.push({
lottery_info_type: 'uid',
create_time: cur.origin_create_time,
is_liked,
uids: [cur.uid, cur.origin_uid],
uname: cur.origin_uname,
ctrl: [],
dyid: cur.origin_dynamic_id,
reserve_id: cur.origin_reserve_id,
reserve_lottery_text: cur.origin_reserve_lottery_text,
rid: cur.origin_rid_str,
des: cur.origin_description,
type: cur.orig_type,
hasOfficialLottery: cur.origin_hasOfficialLottery
})
return results
}, Promise.resolve([]))
log.info('获取动态', `成功获取用户${UID}的动态信息`);
@@ -314,6 +365,8 @@ class Searcher {
uname: o.uname,
ctrl: o.ctrl,
dyid: o.dynamic_id,
reserve_id: o.reserve_id,
reserve_lottery_text: o.reserve_lottery_text,
rid: o.rid_str,
des: o.description,
type: o.type,
@@ -337,7 +390,8 @@ class Searcher {
let dyinfos = [];
/**遍历专栏s */
for (const { id, pub_time } of cvs) {
if (pub_time / 86400 > article_create_time) {
let now_time = Math.floor(Date.now() / 1000);
if ((now_time - pub_time) / 86400 > article_create_time) {
log.warn("获取动态", `该专栏(${id})创建时间大于设定天数(${article_create_time}天)`)
continue
}
@@ -358,8 +412,8 @@ class Searcher {
/**遍历某专栏中的dyids */
for (const dyid of dyids_set) {
if (dyid.length === utils.dyid_length) {
log.info('获取动态', `查看专栏中所提及动态(${dyid})是否点赞 (${length--})`)
log.info('获取动态', `查看专栏中所提及动态(${dyid}) (${length--})`)
const card = await bili.getOneDynamicByDyid(dyid)
if (card) {
@@ -368,7 +422,12 @@ class Searcher {
const parsed_card = parseDynamicCard(card)
, { is_liked } = parsed_card;
if (is_liked) {
if (
((!check_if_duplicated || check_if_duplicated >= 2)
&& is_liked)
|| ((check_if_duplicated >= 1)
&& await d_storage.searchDyid(dyid))
) {
log.info('获取动态', `动态(${dyid})已转发过`)
_weight += 1;
}
@@ -396,6 +455,8 @@ class Searcher {
uname: o.uname,
ctrl: o.ctrl,
dyid: o.dynamic_id,
reserve_id: o.reserve_id,
reserve_lottery_text: o.reserve_lottery_text,
rid: o.rid_str,
des: o.description,
type: o.type,
@@ -417,58 +478,68 @@ class Searcher {
if (api) {
const { strToJson } = utils;
log.info('获取动态', `开始获取链接(${api})中的抽奖信息`)
send({
url: api,
config: {
redirect: true
},
method: 'GET',
success: ({ body }) => {
if (body.err_msg) {
log.error("从API响应数据中获取抽奖信息", body.err_msg)
resolve(null)
} else {
const raw_lottery_info = strToJson(body).lottery_info;
if (api.startsWith("file://")) {
utils.readLotteryInfoFile(api.substring(7)).then(resolve)
} else {
send({
url: api,
config: {
redirect: true
},
method: 'GET',
success: ({ body }) => {
if (body.err_msg) {
log.error("从API响应数据中获取抽奖信息", body.err_msg)
resolve(null)
} else {
const raw_lottery_info = strToJson(body).lottery_info;
if (raw_lottery_info) {
let { length } = raw_lottery_info;
if (length) {
const lottery_info = raw_lottery_info
.reduce(async (pre, cur) => {
const results = await pre
, { dyid } = cur;
if (raw_lottery_info) {
let { length } = raw_lottery_info;
if (length) {
const lottery_info = raw_lottery_info
.reduce(async (pre, cur) => {
let results = await pre
, { dyid } = cur;
log.info('获取动态', `查看动态(${dyid})是否点赞 (${length--})`)
if (!check_if_duplicated || check_if_duplicated >= 2) {
log.info('获取动态', `查看动态(${dyid})是否点赞 (${length--})`)
const card = await bili.getOneDynamicByDyid(dyid)
const card = await bili.getOneDynamicByDyid(dyid)
if (card) {
await utils.delay(get_dynamic_detail_wait)
if (card) {
await utils.delay(get_dynamic_detail_wait)
const { is_liked } = parseDynamicCard(card)
const { is_liked } = parseDynamicCard(card)
if (is_liked) {
log.info('获取动态', `动态(${dyid})已转发过`)
} else {
cur.is_liked = is_liked
results.push(cur)
}
}
} else {
results.push(cur)
}
cur.is_liked = is_liked
return results
return [...results, cur]
}
}, Promise.resolve([]))
return results
}, Promise.resolve([]))
resolve(lottery_info)
return
resolve(lottery_info)
return
}
}
log.error("从API响应数据中获取抽奖信息", "非Json数据或没有lottery_info或lottery为空")
resolve(null)
}
log.error("从API响应数据中获取抽奖信息", "非Json数据或没有lottery_info或lottery为空")
},
failure: err => {
log.error("从API响应数据中获取抽奖信息", err)
resolve(null)
}
},
failure: err => {
log.error("从API响应数据中获取抽奖信息", err)
resolve(null)
}
})
})
}
} else {
log.warn('获取动态', `链接为空`)
resolve(null)
+111 -14
View File
@@ -6,18 +6,17 @@ const config = {
*/
UIDs: [],
/**
* 监视的tag
*/
TAGs: [],
/**
* 监视的专栏关键词
*/
Articles: [],
/**
* 监视的tag
*/
TAGs: [],
/**
* 从API接口中获取抽奖信息
* @typedef {object} LotteryInfo
* @property {string} lottery_info_type
* @property {number} create_time
@@ -26,18 +25,45 @@ const config = {
* @property {string} uname
* @property {Array<{}>} ctrl
* @property {string} dyid
* @property {string} reserve_id
* @property {string} reserve_lottery_text
* @property {string} rid
* @property {string} des
* @property {number} type
* @property {boolean} hasOfficialLottery 是否官方
* @typedef RespondBody
* @typedef {object} RespondBody
* @property {string} err_msg 错误信息
* @property {LotteryInfo[]} lottery_info
* API传回数据类型 {RespondBody}
*
* - 从API接口中获取抽奖信息
* 获取抽奖信息的链接字符串
* @example
* ["https://github.com/spiritLHL/sync_lottery"]
*
* - 从当前路径下符合要求的文件中获取
* 文件名
* @example
* ["file://lottery_info_1.json"]
*/
APIs: [],
/**
* 抽奖参与顺序组合
* * 0 - UIDs
* * 1 - TAGs
* * 2 - Articles
* * 3 - APIs
* @example
* [3,2,1,0]
* [1,2,1,2,1]
*/
LotteryOrder: [2, 0, 1, 3],
/**
* 保存抽奖信息至文件
*/
save_lottery_info_to_file: false,
/**
* API发送数据类型 {LotteryInfo[]}
* 上传抽奖信息的链接字符串
@@ -49,8 +75,8 @@ const config = {
* 符合js正则表达式的字符串
*/
key_words: [
"[抽奖]",
"[转关].*[转关]"
"[抽奖送揪]|福利",
"[转关评粉]|参与"
],
/**
@@ -69,6 +95,43 @@ const config = {
*/
chatmodel: '01',
/**
* 不参与预约抽奖
*/
disable_reserve_lottery: false,
/**
* 检查是否重复转发
* - 不检查 -1
* - 通过是否点赞判断(自动点赞) 0
* - 检索本地dyids文件 1
* - 通过是否点赞判断(不自动点赞)+检索本地dyids文件 2
* - 通过是否点赞判断(自动点赞)+检索本地dyids文件 3
*/
check_if_duplicated: 1,
/**
* 偷塔模式不检查是否重复转发
* * 偷塔模式: 临近开奖时参与抽奖
*/
sneaktower: true,
/**
* 屏蔽动态类型
*
* | 动态类型 | type值 |
* | :------- |:----- |
* | 转发 | `1` |
* | 含图片 | `2` |
* | 无图纯文字 | `4` |
* | 视频 | `8` |
* | 番剧 | `512` |
* | 活动 | `2048` |
* | 专栏 | `64` |
*/
block_dynamic_type: [0],
/**
* - 动态创建时间
* - 多少天前
@@ -119,7 +182,6 @@ const config = {
lottery_loop_wait: 0,
check_loop_wait: 0,
clear_loop_wait: 0,
update_loop_wait: 0,
/**
* - 转发间隔时间
@@ -170,6 +232,12 @@ const config = {
*/
random_dynamic_wait: 2000,
/**
* - 预约抽奖间隔
* - 单位毫秒
*/
reserve_lottery_wait: 6000,
/**
* - up主粉丝数限制
*/
@@ -221,15 +289,26 @@ const config = {
at_users: [['转发抽奖娘', 294887687], ['你的工具人老公', 100680137]],
/**
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 英文逗号分隔 如: 1,2,3
*/
blacklist: '',
/**
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 使用公共黑名单
*/
use_public_blacklist: true,
/**
* 屏蔽词
*/
blockword: ["脚本抽奖", "恭喜", "结果", "抽奖号", "钓鱼", "涨粉"],
blockword: ["脚本", "抽奖号", "钓鱼"],
/**
* 转发并评论
* - 评论内容与转发内容相同
*/
is_repost_then_chat: false,
/**
* 转发评语
@@ -258,6 +337,11 @@ const config = {
*/
is_exception: false,
/**
* 是否关注已达上限
*/
is_outof_maxfollow: false,
/**
* - 中奖通知关键词(满足一个就推送)
* - 符合js正则表达式的字符串
@@ -266,9 +350,21 @@ const config = {
*/
notice_key_words: [
"~预约成功|预约主题",
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员"
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员",
"~你的账号在新设备或平台登录成功",
"~你预约的直播已开始"
],
/**
* 是否发送运行状态通知
*/
notice_running_state: false,
/**
* - 获取私信页数
*/
check_session_pages: 16,
/**
* - 清理白名单uid或dyid
* - 英文逗号分隔 如: 1,2,3
@@ -340,6 +436,7 @@ const config = {
* @param {string} n
*/
updata(n) {
this.init()
this.setObject(this.raw_config()[`config_${n}`])
},
+25 -13
View File
@@ -1,8 +1,6 @@
const { getRemoteConfig } = require("../utils");
const { getRemoteConfig, createDir, createFile, dyids_dir } = require("../utils");
const config = require("../data/config");
const key_map = new Map([['DedeUserID', 'myUID'], ['bili_jct', 'csrf']]);
let global_var = {
inner: {},
get(key) {
@@ -15,12 +13,23 @@ let global_var = {
* 全局变量初始化
* 更新config
* @param {string} cookie
* @param {string} num
*/
async init(cookie) {
async init(cookie, num) {
if (cookie) {
config.updata(process.env.NUMBER);
const
key_map = new Map([
['DedeUserID', 'myUID'],
['bili_jct', 'csrf']]),
LotteryOrderMap = new Map([
[0, "UIDs"],
[1, "TAGs"],
[2, "Articles"],
[3, "APIs"]]);
this.set('cookie', cookie);
config.updata(num);
this.set('cookie', cookie + ';buvid3=AAAAAAAA-BBBB-CCCC-DDDD-DDDDDDDDDDDDDDDDDinfoc');
cookie.split(/\s*;\s*/).forEach(item => {
const _item = item.split('=');
@@ -28,15 +37,18 @@ let global_var = {
this.set(key_map.get(_item[0]), _item[1]);
});
const { UIDs = [], TAGs = [], Articles = [], APIs = [] } = config;
this.set('Lottery', [
...UIDs.map(it => ['UIDs', it]),
...TAGs.map(it => ['TAGs', it]),
...Articles.map(it => ['Articles', it]),
...APIs.map(it => ['APIs', it])
]);
const { LotteryOrder } = config;
this.set('Lottery',
LotteryOrder
.map(it => LotteryOrderMap.get(it))
.filter(it => typeof it === "string")
.map(lottery_option => config[lottery_option].map(it => [lottery_option, it]))
.flat()
);
this.set('remoteconfig', await getRemoteConfig());
}
await createDir('dyids');
await createFile(dyids_dir, num < 2 ? 'dyid.txt' : `dyid${num}.txt`, '', 'a')
}
};
+52
View File
@@ -0,0 +1,52 @@
const { log, readDyidFile, writeDyidFile, dyid_length } = require("../utils");
const d_storage = {
/**
* 搜索dyid
* @param {string} dyid
* @returns {Promise<boolean>}
*/
searchDyid: (dyid) => {
return new Promise((resolve) => {
const Rdyid = new RegExp(dyid);
const rs = readDyidFile(Number(process.env.NUMBER));
let status = false;
rs.on('data', chunk => {
if (Rdyid.test(chunk)) {
status = true
}
})
rs.on('end', () => {
resolve(status)
})
rs.on('error', err => {
log.error('搜索dyid', err)
resolve(status)
})
})
},
/**
* 更新dyid
* @param {string} dyid
*/
updateDyid: (dyid) => {
log.info('更新dyid', `写入${dyid}`);
if (dyid.length !== dyid_length) {
log.error('更新dyid', `dyid(${dyid})长度不为18 若出现此问题请即时通知开发者`)
}
return new Promise((resolve) => {
const ws = writeDyidFile(Number(process.env.NUMBER));
ws.write(dyid + ',', () => {
ws.destroy();
resolve()
})
ws.on('error', err => {
log.error('更新dyid', err)
resolve()
})
});
}
}
module.exports = d_storage;
+166 -24
View File
@@ -43,6 +43,12 @@ let DD_BOT_TOKEN = '';
//密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的字符串
let DD_BOT_SECRET = '';
// ================================企业微信应用通知设置区域====================================
// 此处填你企业微信应用消息的值(详见文档 https://work.weixin.qq.com/api/doc/90000/90135/90236)
// 环境变量名 QYWX_AM 依次填入 corpid,corpsecret,touser(注:多个成员ID使用|隔开),agentid,消息类型(选填,不填默认文本消息类型)
// 注意用,号隔开(英文输入法的逗号),例如:wwcff56746d9adwers,B-791548lnzXBE6_BWfxdf3kSTMJr9vFEPKAbh6WERQ,mingcheng,1000001,2COXgjH2UIfERF2zxrtUOKgQ9XklUqMdGSWLBoW_lSDAdafat
let QYWX_AM = '';
// =======================================企业微信机器人通知设置区域===========================================
//此处填你企业微信机器人的 webhook(详见文档 https://work.weixin.qq.com/api/doc/90000/90136/91770),例如:693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa
//注:此处设置github action用户填写到Settings-Secrets里面(Name输入QYWX_KEY)
@@ -60,6 +66,10 @@ let IGOT_PUSH_KEY = '';
let PUSH_PLUS_TOKEN = '';
let PUSH_PLUS_USER = '';
// ===========================================QMSG===========================================
let QMSG_KEY = '';
let QMSG_QQ = '';
// ===========================================邮件推送===============================================
let SMTP_HOST = '';
let SMTP_PORT = '';
@@ -121,6 +131,10 @@ if (process.env.DD_BOT_TOKEN) {
}
}
if (process.env.QYWX_AM) {
QYWX_AM = process.env.QYWX_AM;
}
if (process.env.QYWX_KEY) {
QYWX_KEY = process.env.QYWX_KEY;
}
@@ -136,6 +150,14 @@ if (process.env.PUSH_PLUS_USER) {
PUSH_PLUS_USER = process.env.PUSH_PLUS_USER;
}
if (process.env.QMSG_KEY) {
QMSG_KEY = process.env.QMSG_KEY;
}
if (process.env.QMSG_QQ) {
QMSG_QQ = process.env.QMSG_QQ;
}
if (process.env.SMTP_HOST) {
SMTP_HOST = process.env.SMTP_HOST;
}
@@ -152,12 +174,13 @@ if (process.env.SMTP_TO_USER) {
SMTP_TO_USER = process.env.SMTP_TO_USER;
}
//==========================云端环境变量的判断与接收=========================
async function sendNotify(text, desp, params = {}) {
//提供10种通知方式
if (process.env.NOTE) {
desp += `\n帐号备注: ${process.env.NOTE}`
}
//提供多种通知方式
await Promise.all([
//微信server酱
serverNotify(text, desp),
@@ -171,12 +194,16 @@ async function sendNotify(text, desp, params = {}) {
tgBotNotify(text, desp),
//钉钉机器人
ddBotNotify(text, desp),
//企业微信应用
qywxAmNotify(text, desp),
//企业微信机器人
qywxBotNotify(text, desp),
//iGot
iGotNotify(text, desp, params),
//QQ酷推
coolPush(text, desp),
// Qmsg
qmsg(text, desp),
//电子邮件
email(text, desp)
])
@@ -216,8 +243,8 @@ function serverNotify(text, desp) {
}
},
failure: err => {
log.error('发送通知', 'server酱 发送通知调用API失败!!')
throw new Error(err);
log.error('发送通知', 'server酱 发送通知调用API失败!!' + err)
resolve()
}
})
} else {
@@ -258,8 +285,8 @@ function serverNotifyTurbo(text, desp) {
}
},
failure: err => {
log.error('发送通知', 'server酱(Turbo版) 发送通知调用API失败!!')
throw new Error(err);
log.error('发送通知', 'server酱(Turbo版) 发送通知调用API失败!!' + err)
resolve()
}
})
} else {
@@ -314,8 +341,8 @@ function coolPush(text, desp) {
}
},
failure: err => {
log.error('发送通知', `酷推 发送${pushMode(QQ_MODE)}通知调用API失败!!`)
throw new Error(err);
log.error('发送通知', `酷推 发送${pushMode(QQ_MODE)}通知调用API失败!!${err}`)
resolve()
}
})
} else {
@@ -356,9 +383,8 @@ function barkNotify(text, desp, params = {}) {
}
},
failure: err => {
log.error('发送通知', 'Bark APP发送通知调用API失败!!');
log.error('发送通知', 'Bark APP发送通知调用API失败!!' + err);
resolve();
throw new Error(err)
}
})
} else {
@@ -404,9 +430,8 @@ function tgBotNotify(text, desp) {
}
},
failure: err => {
log.error('发送通知', 'telegram发送通知消息失败!!')
log.error('发送通知', 'telegram发送通知消息失败!!' + err)
resolve()
throw new Error(err)
}
}
if (TG_PROXY_HOST && TG_PROXY_PORT) {
@@ -467,8 +492,8 @@ function ddBotNotify(text, desp) {
}
},
failure: err => {
log.error('发送通知', '钉钉发送通知消息失败!!')
throw new Error(err);
log.error('发送通知', '钉钉发送通知消息失败!!' + err)
resolve()
}
})
} else if (DD_BOT_TOKEN) {
@@ -506,9 +531,8 @@ function ddBotNotify(text, desp) {
}
},
failure: err => {
log.error('发送通知', '钉钉发送通知消息失败!!');
log.error('发送通知', '钉钉发送通知消息失败!!' + err);
resolve();
throw new Error(err)
}
})
} else {
@@ -518,6 +542,84 @@ function ddBotNotify(text, desp) {
})
}
function qywxAmNotify(text, desp) {
return new Promise(resolve => {
if (QYWX_AM) {
const QYWX_AM_AY = QYWX_AM.split(',');
send({
method: 'POST',
url: `https://qyapi.weixin.qq.com/cgi-bin/gettoken`,
contents: {
corpid: `${QYWX_AM_AY[0]}`,
corpsecret: `${QYWX_AM_AY[1]}`,
},
config: {
retry: false
},
headers: {
accept: 'application/json, text/plain, */*',
'content-type': 'application/json',
},
success: res => {
try {
const data = JSON.parse(res.body);
let accesstoken = data.access_token;
send({
method: 'POST',
url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`,
contents: {
touser: `${QYWX_AM_AY[2]}`,
agentid: `${QYWX_AM_AY[3]}`,
safe: '0',
msgtype: 'text',
text: {
content: `${text}\n\n${desp}`,
},
},
config: {
retry: false
},
headers: {
accept: 'application/json, text/plain, */*',
'content-type': 'application/json',
},
success: res => {
try {
const data = JSON.parse(res.body);
if (data.errcode === 0) {
log.info('发送通知', '企业微信应用发送通知消息完成。');
} else {
log.error('发送通知', `${data.errmsg}`);
}
} catch (e) {
log.error('发送通知', e);
} finally {
resolve();
}
},
failure: err => {
log.error('发送通知', '企业微信应用发送通知消息失败!!' + err);
resolve();
}
})
} catch (e) {
log.error('发送通知', e);
} finally {
resolve();
}
},
failure: err => {
log.error('发送通知', '企业微信应用发送通知消息失败!!' + err);
resolve();
}
})
} else {
log.debug('发送通知', '您未提供企业微信应用所需的QYWX_AM,取消企业微信应用推送消息通知');
resolve();
}
});
}
function qywxBotNotify(text, desp) {
return new Promise(resolve => {
if (QYWX_KEY) {
@@ -552,9 +654,8 @@ function qywxBotNotify(text, desp) {
}
},
failure: err => {
log.error('发送通知', '企业微信发送通知消息失败!!');
log.error('发送通知', '企业微信发送通知消息失败!!' + err);
resolve();
throw new Error(err)
}
})
} else {
@@ -604,9 +705,8 @@ function iGotNotify(text, desp, params = {}) {
}
},
failure: err => {
log.error('发送通知', 'iGot 发送通知调用API失败!!')
log.error('发送通知', 'iGot 发送通知调用API失败!!' + err)
resolve();
throw new Error(err)
}
})
} else {
@@ -621,7 +721,7 @@ function pushPlusNotify(text, desp) {
if (PUSH_PLUS_TOKEN) {
send({
method: 'POST',
url: 'https://pushplus.hxtrip.com/send',
url: 'http://www.pushplus.plus/send',
contents: {
token: PUSH_PLUS_TOKEN,
title: text,
@@ -650,9 +750,8 @@ function pushPlusNotify(text, desp) {
}
},
failure: err => {
log.error('发送通知', `push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败!!`)
log.error('发送通知', `push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败!!${err}`)
resolve();
throw new Error(err)
}
})
} else {
@@ -662,6 +761,49 @@ function pushPlusNotify(text, desp) {
})
}
async function qmsg(text, desp) {
return new Promise(resolve => {
if (QMSG_KEY) {
send({
method: 'POST',
url: 'https://qmsg.zendee.cn/send/' + QMSG_KEY,
contents: {
msg: text + "\n\n" + desp,
qq: QMSG_QQ
},
config: {
retry: false
},
headers: {
accept: 'application/json, text/plain, */*',
'content-type': 'application/x-www-form-urlencoded',
},
success: res => {
try {
const data = JSON.parse(res.body);
if (data.code === 200) {
log.info('发送通知', `qmsg发送通知消息完成。`)
} else {
log.error('发送通知', `qmsg通知消息失败: ${data.reason}`)
}
} catch (e) {
log.error('发送通知', e);
} finally {
resolve();
}
},
failure: err => {
log.error('发送通知', `qmsg通知消息失败!!` + err)
resolve();
}
})
} else {
log.debug('发送通知', '您未提供qmsg推送所需的QMSG_KEY,取消qmsg推送消息通知');
resolve()
}
})
}
async function email(text, desp) {
if (SMTP_HOST && SMTP_PORT && SMTP_USER && SMTP_PASS && SMTP_TO_USER) {
try {
+25 -21
View File
@@ -8,32 +8,36 @@ const utils = require("../utils");
* @returns
*/
async function randomDynamic(num) {
const { create_dy_type, dy_contents, random_dynamic_wait } = config;
let dynamics = []
const
{ create_dy_type, dy_contents, random_dynamic_wait } = config,
hasShareVideo = create_dy_type === -1 || create_dy_type === 1,
hasRandomCreate = create_dy_type === -1 || create_dy_type === 0 || typeof create_dy_type === 'undefined';
if (create_dy_type === -1 || create_dy_type === 0 || typeof create_dy_type === 'undefined') {
if (hasShareVideo) {
dynamics = await bili.getTopRcmd()
for (let index = 0; dynamics.length < num; index++) {
dynamics.push(...await bili.getTopRcmd())
}
}
if (hasRandomCreate) {
for (let index = 0; index < num; index++) {
await bili.createDynamic(utils.getRandomOne(dy_contents));
dynamics.push(utils.getRandomOne(dy_contents))
}
}
await utils.try_for_each(
utils.shuffle(dynamics).slice(0, num),
async (dynamic) => {
await utils.delay(random_dynamic_wait);
}
}
if (create_dy_type === -1 || create_dy_type === 1) {
let videos = await bili.getTopRcmd()
for (let index = 0; videos.length < num; index++) {
videos.push(...await bili.getTopRcmd())
}
await utils.try_for_each(videos, async ([uid, aid]) => {
if (num--) {
await bili.shareVideo(uid, aid)
await utils.delay(random_dynamic_wait)
return false
if (dynamic instanceof Array && dynamic.length === 2 && typeof dynamic[0] === "number") {
await bili.shareVideo(...dynamic)
} else {
return true
await bili.createDynamic(dynamic)
}
})
}
}
)
}
module.exports = { randomDynamic }
+1 -2
View File
@@ -1,7 +1,6 @@
const { isMe } = require('./check');
const { clear } = require('./clear');
const { start } = require('./lottery');
const { update } = require('./update');
const global_var = require('./data/global_var')
const bili = require('./net/bili')
const { log } = require('./utils')
@@ -24,4 +23,4 @@ async function checkCookie(num) {
}
module.exports = { start, isMe, clear, update, checkCookie }
module.exports = { start, isMe, clear, checkCookie }
+19 -6
View File
@@ -5,13 +5,20 @@ const { Searcher } = require('./core/searcher');
const { Monitor } = require('./core/monitor');
const config = require('./data/config');
const { randomDynamic } = require('./helper/randomDynamic');
const { sendNotify } = require('./helper/notify');
const { log } = utils;
async function createRandomDynamic(num) {
if (config.create_dy) {
log.info('随机动态', `准备创建${num}条随机动态`);
const Dynamic = await Searcher.checkAllDynamic(global_var.get("myUID"), 1);
if ((Dynamic.allModifyDynamicResArray[0] || { type: 0 }).type === 1) {
const
{ allModifyDynamicResArray } = (await utils.retryfn(
3,
[null],
() => Searcher.checkAllDynamic(global_var.get("myUID"), 1)
)) || { allModifyDynamicResArray: [] },
{ type, orig_type } = allModifyDynamicResArray[0] || {};
if (type === 1 && orig_type !== 8) {
await randomDynamic(num)
} else {
log.info('随机动态', '已有非抽奖动态故无需创建');
@@ -21,10 +28,10 @@ async function createRandomDynamic(num) {
/**
* 抽奖主函数
* @param {string} cookie
* @param {string} num
* @returns {Promise<void>}
*/
function start() {
function start(num) {
return new Promise(resolve => {
let times = utils.counter();
/* 注册事件 */
@@ -32,7 +39,7 @@ function start() {
const lotterys = global_var.get("Lottery");
if (lotterys.length === 0) {
log.info('抽奖', '抽奖信息为空');
resolve();
event_bus.emit('Turn_off_the_Monitor', '抽奖信息为空')
return;
}
if (times.value() === lotterys.length) {
@@ -46,8 +53,14 @@ function start() {
await (new Monitor(lottery)).init();
});
event_bus.on('Turn_off_the_Monitor', async (msg) => {
await createRandomDynamic(config.create_dy_num);
log.info('结束抽奖', '原因: ' + msg);
if (config.notice_running_state) {
sendNotify(
`动态抽奖-帐号${num}结束抽奖`,
`${log._cache.filter(it => /抽奖\]|Error|\s抽奖信息\]/.test(it)).join('\n')}`
);
}
await createRandomDynamic(config.create_dy_num);
event_bus.flush();
resolve();
})
+4 -1
View File
@@ -1,5 +1,6 @@
module.exports = Object.freeze({
DYNAMIC_LIKE_THUMB: 'https://api.vc.bilibili.com/dynamic_like/v1/dynamic_like/thumb',
DYNAMIC_MIX_RESERVE_ATTACH_CARD_BUTTON: 'https://api.vc.bilibili.com/dynamic_mix/v1/dynamic_mix/reserve_attach_card_button',
DYNAMIC_REPOST_REPOST: 'https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/repost',
DYNAMIC_REPOST_SHARE: 'https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/share',
DYNAMIC_SVR_CREATE_DRAW: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create_draw',
@@ -7,11 +8,12 @@ module.exports = Object.freeze({
DYNAMIC_SVR_GET_DYNAMIC_DETAIL: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail',
DYNAMIC_SVR_RM_DYNAMIC: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/rm_dynamic',
DYNAMIC_SVR_SPACE_HISTORY: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history',
FETCH_SESSION_MSGS: 'https://api.vc.bilibili.com/svr_sync/v1/svr_sync/fetch_session_msgs',
FEED_GET_ATTENTION_LIST: 'https://api.vc.bilibili.com/feed/v1/feed/get_attention_list',
FEED_SETUSERFOLLOW: 'https://api.vc.bilibili.com/feed/v1/feed/SetUserFollow',
FETCH_SESSION_MSGS: 'https://api.vc.bilibili.com/svr_sync/v1/svr_sync/fetch_session_msgs',
LOTTERY_SVR_LOTTERY_NOTICE: 'https://api.vc.bilibili.com/lottery_svr/v1/lottery_svr/lottery_notice',
MSGFEED_AT: 'https://api.bilibili.com/x/msgfeed/at',
MSGFEED_REPLAY: 'https://api.bilibili.com/x/msgfeed/reply',
MSGFEED_UNREAD: 'https://api.bilibili.com/x/msgfeed/unread',
READ_CV: 'https://www.bilibili.com/read/cv{{cv}}',
RELATION_BATCH_MODIFY: 'https://api.bilibili.com/x/relation/batch/modify',
@@ -28,6 +30,7 @@ module.exports = Object.freeze({
SPACE_MYINFO: 'https://api.bilibili.com/x/space/myinfo',
TAG_INFO: 'https://api.bilibili.com/x/tag/info',
TOP_RCMD: "https://api.bilibili.com/x/web-interface/index/top/rcmd",
TOP_FEED_RCMD: "https://api.bilibili.com/x/web-interface/index/top/feed/rcmd",
TOPIC_SVR_TOPIC_HISTORY: 'https://api.vc.bilibili.com/topic_svr/v1/topic_svr/topic_history',
TOPIC_SVR_TOPIC_NEW: 'https://api.vc.bilibili.com/topic_svr/v1/topic_svr/topic_new',
WEB_INTERFACE_CARD: 'https://api.bilibili.com/x/web-interface/card',
+217 -90
View File
@@ -185,22 +185,50 @@ const bili_client = {
}
},
/**
* 获取未读@
* @returns {Promise<number>}
* 获取未读信息数量
* @returns {Promise<{at: number, reply: number}>}
*/
async getUnreadAtNum() {
async getUnreadNum() {
const
responseText = await get({
url: API.MSGFEED_UNREAD
}),
res = strToJson(responseText);
if (res.code === 0) {
const { at } = res.data;
log.info('获取未读@', `成功 数量: ${at}`);
return at;
log.info('获取未读信息', `成功`);
return res.data;
} else {
log.error('获取未读@', `失败\n${responseText}`);
return -1;
log.error('获取未读信息', `失败\n${responseText}`);
return {};
}
},
/**
* 获取一页回复
* @returns {Promise<Array<{nickname: string, source: string, uri: string, timestamp: number}>}>}
*/
async getReplyMsg() {
const
responseText = await get({
url: API.MSGFEED_REPLAY
}),
res = strToJson(responseText);
if (res.code === 0) {
const data = res.data || {},
items = data.items || [];
log.info('获取一页回复', `成功(${items.length})`);
return items
.filter(it => it.item.type === 'reply')
.map(it => {
return {
nickname: it.user.nickname,
source: it.item.source_content,
uri: it.item.uri,
timestamp: it.reply_time
}
});
} else {
log.error('获取一页回复', '失败');
return []
}
},
/**
@@ -526,6 +554,17 @@ const bili_client = {
query: {
vmid: uid
}
}),
/**
* 线路三
* @param {number} uid
* @returns {Promise<string>}
*/
(uid) => get({
url: "https://tenapi.cn/bilibilifo/",
query: {
uid
}
})
], responseText => {
const res = strToJson(responseText);
@@ -595,9 +634,9 @@ const bili_client = {
(uid) => post({
url: API.RELATION_BATCH_MODIFY,
contents: {
fid: uid,
fids: uid,
act: 1,
re_src: 0,
re_src: 1,
csrf: GlobalVar.get("csrf")
}
})
@@ -607,11 +646,13 @@ const bili_client = {
case 0:
return [false, 0, '关注+1']
case 22002:
return [false, -1, '您已被对方拉入黑名单']
return [false, 2, '您已被对方拉入黑名单']
case 22003:
return [false, -1, '黑名单用户无法关注', -1]
return [false, 3, '黑名单用户无法关注']
case 22015:
return [false, 2, '账号异常', 2]
return [false, 4, '账号异常']
case 22009:
return [false, 5, '关注已达上限']
default:
return [true, 1, `未知错误\n${responseText}`]
}
@@ -623,10 +664,12 @@ const bili_client = {
* @param {Number} uid
* 被关注者的UID
* @returns {Promise<number>}
* -1 - 黑名单
* 0 - 成功
* 1 - 失败
* 2 - 异常
* - 成功 0
* - 未知错误 1
* - 您已被对方拉入黑名单 2
* - 黑名单用户无法关注 3
* - 账号异常 4
* - 关注已达上限 5
*/
autoAttention(uid) {
return this._autoAttention.run(uid)
@@ -636,8 +679,8 @@ const bili_client = {
* @param {number} uid
* @param {number} tagid 关注分区的ID
* @returns {Promise<number>}
* 0 - 成功
* 1 - 失败
* - 成功 0
* - 失败 1
*/
async movePartition(uid, tagid) {
const responseText = await post({
@@ -689,25 +732,36 @@ const bili_client = {
* 动态自动点赞
* @param {string} dyid
* @returns {Promise<number>}
* 0 - 成功
* 1 - 失败
* - 成功 0
* - 未知错误 1
* - 点赞异常 2
* - 点赞频繁 3
*/
async autolike(dyid) {
const responseText = await post({
url: API.DYNAMIC_LIKE_THUMB,
contents: {
uid: GlobalVar.get("myUID"),
dynamic_id: dyid,
up: 1,
csrf: GlobalVar.get("csrf")
}
});
if (/^{"code":0/.test(responseText)) {
log.info('自动点赞', '点赞成功');
return 0;
} else {
log.error('自动点赞', `点赞失败\n${responseText}`);
return 1;
const
responseText = await post({
url: API.DYNAMIC_LIKE_THUMB,
contents: {
uid: GlobalVar.get("myUID"),
dynamic_id: dyid,
up: 1,
csrf: GlobalVar.get("csrf")
}
}),
res = strToJson(responseText);
switch (res.code) {
case 0:
log.info('自动点赞', '点赞成功');
return 0;
case 1000113:
log.warn('自动点赞', '点赞异常');
return 2;
case 1000001:
log.warn('自动点赞', '点赞频繁');
return 3;
default:
log.error('自动点赞', `未知错误\n${responseText}`);
return 1;
}
},
/**
@@ -719,8 +773,11 @@ const bili_client = {
* @param {string} [msg]
* 动态的ID
* @returns {Promise<number>}
* 0 - 成功
* 1 - 失败
* - 成功 0
* - 未知错误 1
* - 该动态不能转发分享 2
* - 请求数据发生错误,请刷新或稍后重试 3
* - 操作太频繁了,请稍后重试 4
*/
async autoRelay(uid, dyid, msg = '转发动态', ctrl = '[]') {
const len = msg.length;
@@ -742,15 +799,50 @@ const bili_client = {
}
}),
res = strToJson(responseText);
if (res.code === 0) {
log.info('转发动态', '成功转发一条动态');
return 0;
} else if (res.code === 1101004) {
log.warn('转发动态', '该动态不能转发分享');
return 0;
} else {
log.error('转发动态', `转发动态失败\n${responseText}`);
return 1;
switch (res.code) {
case 0:
log.info('转发动态', '成功转发一条动态');
return 0;
case 1101004:
log.warn('转发动态', '该动态不能转发分享');
return 2;
case 2201116:
log.warn('转发动态', '请求数据发生错误,请刷新或稍后重试');
return 3;
case 1101008:
log.warn('转发动态', '操作太频繁了,请稍后重试');
return 4;
default:
log.error('转发动态', `未知错误\n${responseText}`);
return 1;
}
},
/**
* 预约抽奖
* @param {number} reserve_id
* @returns
*/
async reserve_lottery(reserve_id) {
const
responseText = await post({
url: API.DYNAMIC_MIX_RESERVE_ATTACH_CARD_BUTTON,
contents: {
cur_btn_status: "1",
reserve_id,
csrf: GlobalVar.get("csrf")
}
}),
res = strToJson(responseText);
switch (res.code) {
case 0:
log.info('预约抽奖', '预约成功');
return 0;
case 7604003:
log.warn('预约抽奖', '重复预约');
return 0;
default:
log.error('预约抽奖', `未知错误\n${responseText}`);
return 1;
}
},
/**
@@ -760,13 +852,13 @@ const bili_client = {
* @property {number} img_height
* 发布一条动态
* @param { string | Picture[] } content
* @return {Promise<void>}
* @return {Promise<boolean>} isError true
*/
async createDynamic(content) {
let
contents = {
csrf: GlobalVar.get("csrf"),
extension: '{"emoji_type":1,"from":{"emoji_type":1},"flag_cfg":{}}'
extension: '{"emoji_type":1,"from":{"emoji_type":1},"flag_cfg":{}}',
},
url = '';
if (content instanceof Array) {
@@ -781,6 +873,7 @@ const bili_client = {
url = API.DYNAMIC_SVR_CREATE
contents = {
...contents,
type: 4,
content,
}
}
@@ -790,54 +883,67 @@ const bili_client = {
});
if (/^{"code":0/.test(responseText)) {
log.info('发布动态', `成功创建一条随机内容的动态\n${JSON.stringify(content)}\n`);
return false
} else {
log.error('发布动态', `发布动态失败\n${JSON.stringify(content)}\n${responseText}`);
return true
}
},
_getTopRcmd: new Line('获取推荐', [
() => get({
url: API.TOP_RCMD
}),
() => get({
url: API.TOP_FEED_RCMD
})
], responseText => {
const res = strToJson(responseText);
if (res.code === 0) {
return [false, res.data.item.map(it => {
return [it.owner.mid, it.id];
}), "成功"];
} else {
return [true, [], `获取推荐失败\n${responseText}`];
}
}),
/**
* 获取推荐
* @returns {Promise<Array<[number, number]>>}
*/
async getTopRcmd() {
const
responseText = await get(
{
url: API.TOP_RCMD,
}
),
res = strToJson(responseText);
if (res.code === 0) {
log.info('获取推荐', `成功`);
return res.data.item.map(it => {
return [it.owner.mid, it.id];
});
} else {
log.error('获取推荐', `获取推荐失败\n${responseText}`);
return [];
}
return this._getTopRcmd.run()
},
/**
* 分享视频
* @param {number} uid
* @param {number} aid
* @return {Promise<boolean>} isError true
*/
async shareVideo(uid, aid) {
const responseText = await post({
url: API.DYNAMIC_REPOST_SHARE,
contents: {
platform: "pc",
uid,
type: 8,
content: "分享视频",
repost_code: 20000,
rid: aid,
csrf_token: GlobalVar.get("csrf")
}
});
if (/^{"code":0/.test(responseText)) {
log.info('转发视频', `成功转发视频(av${aid})`);
} else {
log.error('转发视频', `转发失败\n${responseText}`);
const
responseText = await post({
url: API.DYNAMIC_REPOST_SHARE,
contents: {
platform: "pc",
uid,
type: 8,
content: "分享视频",
repost_code: 20000,
rid: aid,
csrf_token: GlobalVar.get("csrf")
}
}),
res = strToJson(responseText);
switch (res.code) {
case 0:
log.info('转发视频', `成功转发视频(av${aid})`);
return false
case 1101015:
log.warn('转发视频', `该动态不能转发分享(av${aid})`);
return false
default:
log.error('转发视频', `转发失败\n${responseText}`);
return true
}
},
/**
@@ -875,8 +981,17 @@ const bili_client = {
* 17(无图)
* @returns {Promise<number>}
* - 成功 0
* - 失败 1
* - 黑名单/评论区关闭/动态删除 -1
* - 未知错误 1
* - 动态删除 2
* - 评论区已关闭 3
* - 需要输入验证码 4
* - 已被对方拉入黑名单 5
* - 黑名单用户无法互动 6
* - UP主已关闭评论区 7
* - 评论内容包含敏感信息 8
* - 重复评论 9
* - 帐号未登录 10
* - 关注UP主7天以上的人可发评论 11
*/
async sendChat(rid, msg, type) {
const
@@ -892,26 +1007,38 @@ const bili_client = {
res = strToJson(responseText);
switch (res.code) {
case 0:
log.info('自动评论', '评论成功');
log.info('自动评论', `评论成功: ${msg}`);
return 0;
case -404:
log.error('自动评论', '原动态已删除');
return -1;
return 2;
case 12002:
log.error('自动评论', '评论区已关闭');
return -1;
return 3;
case 12015:
log.error('自动评论', '需要输入验证码');
return 1;
return 4;
case 12035:
log.error('自动评论', `已被对方拉入黑名单`);
return -1;
return 5;
case 12053:
log.error('自动评论', '黑名单用户无法互动');
return -1;
return 6;
case 12061:
log.error('自动评论', 'UP主已关闭评论区');
return -1;
return 7;
case 12016:
log.error('自动评论', '评论内容包含敏感信息');
return 8;
case 12051:
log.error('自动评论', '重复评论');
return 9;
case -101:
log.error('自动评论', '帐号未登录');
return 10;
case 12078:
log.error('自动评论', '关注UP主7天以上的人可发评论');
return 11;
default:
log.error('自动评论', `未知错误\n${responseText}`);
return 1;
+54 -43
View File
@@ -1,14 +1,26 @@
const { send } = require('./net/http')
const { strToJson, download } = require('./utils')
const { strToJson, download, try_for_each } = require('./utils')
const { version, checkVersion, log } = require('./utils')
const
platform = new Map([
['win32', 'win'],
['linux', 'linux'],
['darwin', 'macos']
]).get(process.platform),
arch = new Map([
['x64', 'x64'],
['arm', 'armv7'],
['arm64', 'arm64']
]).get(process.arch);
/**
* 获取下载链接
* @param {string} owner
* @param {string} repo
* @returns {Promise<{ download_url: string, text: string }>}
* @returns {Promise<{ tag_name:string, assets:Object, text:string }>}
*/
function getLatestReleaseDownloadUrl(owner, repo) {
function getLatestRelease(owner, repo) {
return new Promise((resolve, reject) => {
send({
url: `https://api.github.com/repos/${owner}/${repo}/releases/latest`,
@@ -19,37 +31,9 @@ function getLatestReleaseDownloadUrl(owner, repo) {
retry: false
},
success: ({ body }) => {
const { tag_name, assets, body: text } = strToJson(body)
if (tag_name) {
if (checkVersion(version) < checkVersion(tag_name)) {
const platform = new Map([
['win32', 'win'],
['linux', 'linux'],
['darwin', 'macos']
]).get(process.platform)
const arch = new Map([
['x64', 'x64'],
['arm', 'armv7'],
['arm64', 'arm64']
]).get(process.arch)
if (platform && arch) {
try {
const download_url = assets
.filter(({ name }) => name.includes(platform) && name.includes(arch))
.map(({ browser_download_url }) => browser_download_url)[0]
if (!download_url) {
reject(`未找到能在此平台(${process.platform})-(${process.arch})上运行的版本`)
}
resolve({ download_url, text })
} catch (err) {
reject(err)
}
} else {
reject(`未找到能在此平台(${process.platform})-(${process.arch})上运行的版本`)
}
} else {
reject('当前已是最新版本')
}
const release = strToJson(body);
if (release.tag_name) {
resolve(release)
} else {
reject(body)
}
@@ -61,20 +45,47 @@ function getLatestReleaseDownloadUrl(owner, repo) {
});
}
/**
* @param {string} releases
* @return {boolean}
*/
function checkPlatform(releases) {
return releases.includes(platform)
&& releases.includes(arch)
}
/**
* 半自动更新
*/
async function update() {
try {
const { download_url, text } = await getLatestReleaseDownloadUrl('shanmiteko', 'LotteryAutoScript')
let proxy_url = new URL(download_url)
proxy_url.host = 'download.fastgit.org'
await download(proxy_url.href, 'latest_version.zip')
log.info('自动下载', '成功下载到当前目录')
log.info('更新说明', '\n' + text + '\n')
const { tag_name, assets, body: text } = await getLatestRelease('shanmiteko', 'LotteryAutoScript')
if (checkVersion(version) < checkVersion(tag_name)) {
const download_url = assets
.filter(({ name }) => checkPlatform(name))
.map(({ browser_download_url }) => browser_download_url)
if (download_url.length) {
await try_for_each(download_url.entries(), async ([i, url]) => {
let proxy_url = "https://ghproxy.com/";
proxy_url += url
log.warn('自动下载', `切换代理${proxy_url}`)
await download(proxy_url, `latest_version${i}.zip`)
.catch(async err => {
log.error('自动下载', err)
proxy_url = url
log.warn('自动下载', `使用原始链接${proxy_url}`)
await download(proxy_url, `latest_version${i}.zip`)
})
return false
})
log.info('自动下载', '成功下载到当前目录')
log.info('更新说明', '\n' + text + '\n')
} else {
throw `未找到能在此平台(${process.platform})-(${process.arch})上运行的版本,建议以源码运行`
}
} else {
throw '当前已是最新版本'
}
} catch (error) {
log.error('更新脚本', error)
}
+181 -28
View File
@@ -13,6 +13,10 @@ const utils = {
env_file: path.join(process.cwd(), "env.js"),
/**配置文件 */
config_file: path.join(process.cwd(), "my_config.js"),
/**dyids存放目录 */
dyids_dir: path.join(process.cwd(), "dyids"),
/**lottery_info存放目录 */
lottery_info_dir: path.join(process.cwd(), "lottery_info"),
/**dyid长度 */
dyid_length: 18,
/**
@@ -57,6 +61,26 @@ const utils = {
if (await fn(item)) break
}
},
/**
* @template T
* @param {number} max_times
* @param {Array<T>} unexpected
* @param {() => Promise<T>} fn
* @return {Promise<T | null>}
*/
async retryfn(max_times, unexpected, fn) {
let ret = null;
for (let times = 0; times < max_times; times++) {
ret = await fn()
if (unexpected.includes(ret)) {
utils.log.warn('自动重试', `将在 ${times + 1} 分钟后再次尝试(${times + 1}/${max_times})`)
await utils.delay(60 * 1000 * (times + 1))
} else {
break
}
}
return ret;
},
/**
* 函数柯里化
* @template T
@@ -82,11 +106,7 @@ const utils = {
*/
delay(time = 1000) {
utils.log.info('时延', `${~~time}ms`);
return new Promise(resolve => {
setTimeout(() => {
resolve();
}, time);
});
return new Promise(resolve => setTimeout(resolve, time));
},
/**
* 计数器 0..Infinity
@@ -164,13 +184,19 @@ const utils = {
},
/**日志 */
log: {
level: 3,
_level: 3,
_colors: [
chalk.hex('#64B3FF'), chalk.grey, chalk.hex('#FFA500'),
chalk.hex('#0070BB'), chalk.hex('#48BB31'), chalk.hex('#BBBB23'), chalk.hex('#FF0006')
],
_iso_time: () => new Date(Date.now() + 288e5).toISOString().slice(0, -1) + '+08',
_cache: [],
/**
* 初始化默认level为3
*/
init() {
let _level = Number(process.env.LOTTERY_LOG_LEVEL);
this.level = isNaN(_level) ? 3 : _level;
this._level = isNaN(_level) ? 3 : _level;
},
/**
* @param {String|Array<String>} msg
@@ -187,29 +213,66 @@ const utils = {
* @returns
*/
rainbow(msg) {
const
colors = ['red', 'yellow', 'green', 'cyan', 'blue', 'magenta'],
colorsCount = colors.length;
this.proPrint(msg.map(it => it.split('').map((l, i) => chalk[colors[i % colorsCount]](l)).join('')), '\n')
this.proPrint(msg.map(it => it.split('').map(l => chalk.hex("#89cff0")(l)).join('')), '\n')
},
/**
* @param {number} done
* @param {number} total
* @param {number} size
*/
progress_bar(done, total, size = 30) {
let perc = done >= total ? 1 : done / total,
bar = ~~(perc * size),
status_bar = `\r[${"=".repeat(bar) + ">" + " ".repeat(size - bar)}] ${(perc * 100 + ' ').slice(0, 4)}%`
process.stdout.write(status_bar)
},
debug(context, msg) {
if (this.level > 3) {
if (this._level > 3) {
if (msg instanceof Object) msg = JSON.stringify(msg, null, 4);
this.proPrint([chalk.hex('#64B3FF')(`[${new Date(Date.now() + 288e5).toISOString()}]`), chalk.grey("[Debug]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#0070BB')(`[\n${msg}\n]`)])
let color_text_pair = [
[this._colors[0], `[${this._iso_time()}]`],
[this._colors[1], "[Debug]"],
[this._colors[2], `[帐号${process.env["NUMBER"]} ${context}]`],
[this._colors[3], `[\n${msg}\n]`],
];
this.proPrint(color_text_pair.map(([color, text]) => color(text)))
}
},
info(context, msg) {
if (this.level > 2)
this.proPrint([chalk.hex('#64B3FF')(`[${new Date(Date.now() + 288e5).toISOString()}]`), chalk.grey("[Info]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#48BB31')(`[${msg}]`)])
if (this._level > 2) {
let color_text_pair = [
[this._colors[0], `[${this._iso_time()}]`],
[this._colors[1], "[Info]"],
[this._colors[2], `[帐号${process.env["NUMBER"]} ${context}]`],
[this._colors[4], `[${msg}]`],
];
this._cache.push(color_text_pair.map(it => it[1]).join(' '));
this.proPrint(color_text_pair.map(([color, text]) => color(text)))
}
},
warn(context, msg) {
if (this.level > 1)
this.proPrint([chalk.hex('#64B3FF')(`[${new Date(Date.now() + 288e5).toISOString()}]`), chalk.grey("[Warn]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#BBBB23')(`[\n${msg}\n]`)])
if (this._level > 1) {
let color_text_pair = [
[this._colors[0], `[${this._iso_time()}]`],
[this._colors[1], "[Warn]"],
[this._colors[2], `[帐号${process.env["NUMBER"]} ${context}]`],
[this._colors[5], `[\n${msg}\n]`],
];
this._cache.push(color_text_pair.map(it => it[1]).join(' '));
this.proPrint(color_text_pair.map(([color, text]) => color(text)))
}
},
error(context, msg) {
if (this.level > 0)
this.proPrint([chalk.hex('#64B3FF')(`[${new Date(Date.now() + 288e5).toISOString()}]`), chalk.grey("[Error]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#FF0006')(`[\n${msg}\n]`)])
if (this._level > 0) {
let color_text_pair = [
[this._colors[0], `[${this._iso_time()}]`],
[this._colors[1], "[Error]"],
[this._colors[2], `[帐号${process.env["NUMBER"]} ${context}]`],
[this._colors[6], `[\n${msg}\n]`],
];
this._cache.push(color_text_pair.map(it => it[1]).join(' '));
this.proPrint(color_text_pair.map(([color, text]) => color(text)))
}
}
},
/**
@@ -227,12 +290,13 @@ const utils = {
redirect: true,
retry: false
},
success: ({ resStream }) => {
success: ({ headers, resStream }) => {
const total_len = Number(headers["content-length"]) || 16000000;
let recv_length = 0;
const wtbs = fs.createWriteStream(file_name);
resStream.on('data', chuck => {
recv_length += chuck.length
utils.log.proPrint(`已收到:${recv_length} Bytes`)
utils.log.progress_bar(recv_length, total_len)
})
resStream.pipe(wtbs)
wtbs.on('finish', () => {
@@ -240,7 +304,7 @@ const utils = {
resolve()
}).on('error', error => {
wtbs.destroy()
resolve(error)
reject(error)
})
},
failure: error => {
@@ -260,21 +324,20 @@ const utils = {
url: 'https://gitee.com/shanmite/lottery-notice/raw/master/notice.json',
headers: {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
accept: 'text/plain; charset=utf-8',
referer: 'https://gitee.com/shanmite/lottery-notice/blob/master/notice.json',
},
success: res => {
try {
const body = JSON.parse(res.body);
const body = JSON.parse(Buffer.from(res.body, "base64").toString());
if (body.node_msg) utils.log.info('公告', '\n' + body.node_msg + '\n');
resolve(body.config)
} catch (error) {
resolve(JSON.parse('{}'))
utils.log.error('获取远程设置', '获取远程设置错误: ' + error);
resolve({})
}
},
failure: err => {
utils.log.error('获取远程设置', '获取远程设置错误: ' + err);
resolve(JSON.parse('{}'));
resolve({})
}
})
})
@@ -306,6 +369,96 @@ const utils = {
resolve()
})
});
},
/**
* CreateFile
* @param {string} basename
* @param {string} filename
* @param {string} [defaultValue] 写入默认值
* @param {string} flag
* @returns {Promise<void>}
*/
createFile(basename, filename, defaultValue, flag) {
const fpath = path.join(basename, filename);
const buffer = Buffer.from(defaultValue);
return new Promise((resolve, rejects) => {
fs.open(fpath, flag, (err, fd) => {
if (err) {
rejects(err)
} else {
fs.write(fd, buffer, 0, buffer.length, 0, err => {
if (err) {
rejects(err)
} else {
resolve();
}
})
}
})
});
},
/**
* 读取dyid文件
* @param {number} num
* @returns {fs.ReadStream}
*/
readDyidFile(num) {
const fpath = num < 2 ? path.join(utils.dyids_dir, 'dyid.txt') : path.join(utils.dyids_dir, `dyid${num}.txt`);
return fs.createReadStream(fpath, { encoding: 'utf8', highWaterMark: (utils.dyid_length + 1) * 1000 })
},
/**
* 追加dyid
* @param {number} num
* @returns {fs.WriteStream}
*/
writeDyidFile(num) {
const fpath = num < 2 ? path.join(utils.dyids_dir, 'dyid.txt') : path.join(utils.dyids_dir, `dyid${num}.txt`);
return fs.createWriteStream(fpath, { flags: 'a' })
},
/**
* 追加lotteryinfo
* @param {string} from
* @param {import("./core/searcher").LotteryInfo[]} lottery_info
* @return {Promise<void>}
*/
async appendLotteryInfoFile(from, lottery_info) {
let all_lottery_info = {};
try {
all_lottery_info = utils.strToJson(fs.readFileSync(path.join(utils.lottery_info_dir, `lottery_info_${Number(process.env.NUMBER)}.json`)).toString())
} catch (_) {
all_lottery_info = {}
}
await utils.createDir(utils.lottery_info_dir);
if (all_lottery_info[from] instanceof Array) {
all_lottery_info[from].push(...lottery_info)
} else {
all_lottery_info[from] = lottery_info
}
await utils.createFile(utils.lottery_info_dir, `lottery_info_${Number(process.env.NUMBER)}.json`, JSON.stringify(all_lottery_info), "w")
},
/**
* 读取lottery_info
* @param {string} filename
* @return {Promise<import("./core/searcher").LotteryInfo[]>}
*/
readLotteryInfoFile(filename) {
return new Promise((resolve) => {
fs.readFile(path.join(utils.lottery_info_dir, filename), (err, data) => {
if (err) {
resolve([])
} else {
let all_lottery_info = utils.strToJson(data.toString('utf8'));
resolve(Object.values(all_lottery_info).flat())
}
})
});
},
/**
* 清空lottery_info file
*/
async clearLotteryInfo() {
await utils.createDir(utils.lottery_info_dir);
await utils.createFile(utils.lottery_info_dir, `lottery_info_${Number(process.env.NUMBER)}.json`, "{}", "w")
}
};
+20 -14
View File
@@ -1,4 +1,4 @@
const { version: ve, env_file, config_file, log, hasEnv, delay, hasFileOrDir } = require("./lib/utils");
const { version: ve, env_file, config_file, log, hasEnv, delay, hasFileOrDir, clearLotteryInfo } = require("./lib/utils");
const metainfo = [
` _ _ _ _____ _ _ `,
@@ -10,8 +10,7 @@ const metainfo = [
` __/ | | | `,
` |___/ |_| `,
` `,
` Verison: v${ve}`,
` Written By shanmite`,
` This: v${ve} Nodejs: ${process.version} Written By shanmite`,
]
/**多账号存储 */
let multiple_account = [];
@@ -34,6 +33,7 @@ async function main() {
process.env.COOKIE = acco.COOKIE;
process.env.NUMBER = acco.NUMBER;
process.env.CLEAR = acco.CLEAR;
process.env.NOTE = acco.NOTE;
const err_msg = await main();
if (err_msg) {
return err_msg
@@ -46,27 +46,31 @@ async function main() {
process.env.ENABLE_MULTIPLE_ACCOUNT = ENABLE_MULTIPLE_ACCOUNT;
} else if (COOKIE) {
const global_var = require("./lib/data/global_var");
await global_var.init(COOKIE, Number(NUMBER));
await global_var.init(COOKIE, NUMBER);
/**引入基础功能 */
const { start, isMe, clear, update, checkCookie } = require("./lib/index");
const { start, isMe, clear, checkCookie } = require("./lib/index");
log.info('main', '当前为第' + NUMBER + '个账号');
log._cache.length = 0
if (await checkCookie(NUMBER)) {
const mode = process.env.lottery_mode;
const help_msg = "用法: lottery [OPTIONS]\n\nOPTIONS:\n\tstart 启动抽奖\n\tcheck 中奖检查\n\tclear 清理动态和关注\n\tupdate 检查更新\n\thelp 帮助信息";
const { lottery_loop_wait, check_loop_wait, clear_loop_wait, update_loop_wait } = require("./lib/data/config");
const { lottery_loop_wait, check_loop_wait, clear_loop_wait, save_lottery_info_to_file } = require("./lib/data/config");
switch (mode) {
case 'start':
log.info('抽奖', '开始运行');
loop_wait = lottery_loop_wait;
await start();
if (save_lottery_info_to_file) {
await clearLotteryInfo()
}
await start(NUMBER);
break;
case 'check':
log.info('中奖检测', '检查是否中奖');
loop_wait = check_loop_wait;
await isMe();
await isMe(NUMBER);
break;
case 'clear':
if (CLEAR) {
@@ -75,11 +79,6 @@ async function main() {
await clear();
}
break;
case 'update':
log.info('检查更新', '开始')
loop_wait = update_loop_wait;
await update()
break;
case 'help':
return help_msg
case undefined:
@@ -89,7 +88,7 @@ async function main() {
}
} else {
log.error('Cookie已失效', '切换账号时不要点击退出账号而应直接删除Cookie退出')
return ''
return
}
} else {
return '请查看README文件, 在env.js指定位置填入cookie'
@@ -150,6 +149,13 @@ function initConfig() {
/**OPTIONS */
process.env.lottery_mode = process.argv[2]
if (process.env.lottery_mode === "update") {
log.info('检查更新', '开始')
await require("./lib/update").update()
log.info('检查更新', '请手动解压替换可执行文件')
return
}
const err_msg = await main();
if (err_msg) {
log.error('错误', err_msg);
+138 -29
View File
@@ -6,30 +6,19 @@ module.exports = Object.freeze({
/**
* 监视更转的用户uid
*/
UIDs: [
689277291,
241675899
],
/**
* 监视的专栏关键词
*/
Articles: [
'抽奖合集'
],
UIDs: [],
/**
* 监视的tag
*/
TAGs: [
'互动抽奖',
'转发抽奖',
'动态抽奖',
'抽奖',
],
TAGs: [],
/**
* 监视的专栏关键词
*/
Articles: [],
/**
* 从API接口中获取抽奖信息
* @typedef {object} LotteryInfo
* @property {string} lottery_info_type
* @property {number} create_time
@@ -38,19 +27,44 @@ module.exports = Object.freeze({
* @property {string} uname
* @property {Array<{}>} ctrl
* @property {string} dyid
* @property {string} reserve_id
* @property {string} reserve_lottery_text
* @property {string} rid
* @property {string} des
* @property {number} type
* @property {boolean} hasOfficialLottery 是否官方
* @typedef RespondBody
* @typedef {object} RespondBody
* @property {string} err_msg 错误信息
* @property {LotteryInfo[]} lottery_info
* API传回数据类型 {RespondBody}
*
* - 从API接口中获取抽奖信息
* 获取抽奖信息的链接字符串
* @example
* "https://raw.fastgit.org/spiritLHL/sync_lottery/master/archive_datas/datas.json"
* ["https://github.com/spiritLHL/sync_lottery"]
*
* - 从当前路径下符合要求的文件中获取
* 文件名
* @example
* ["file://lottery_info_1.json"]
*/
APIs: [],
APIs: ["file://lottery_info_1.json"],
/**
* 抽奖参与顺序组合
* * 0 - UIDs
* * 1 - TAGs
* * 2 - Articles
* * 3 - APIs
* @example
* [3,2,1,0]
* [1,2,1,2,1]
*/
LotteryOrder: [2, 0, 1, 3],
/**
* 保存抽奖信息至文件
*/
save_lottery_info_to_file: false,
/**
* API发送数据类型 {LotteryInfo[]}
@@ -63,8 +77,8 @@ module.exports = Object.freeze({
* 符合js正则表达式的字符串
*/
key_words: [
"[抽奖]",
"[转关].*[转关]"
"[抽奖送揪]|福利",
"[转关评粉]|参与"
],
/**
@@ -83,6 +97,42 @@ module.exports = Object.freeze({
*/
chatmodel: '01',
/**
* 不参与预约抽奖
*/
disable_reserve_lottery: false,
/**
* 检查是否重复转发
* - 不检查 -1
* - 通过是否点赞判断(自动点赞) 0
* - 检索本地dyids文件 1
* - 通过是否点赞判断(不自动点赞)+检索本地dyids文件 2
* - 通过是否点赞判断(自动点赞)+检索本地dyids文件 3
*/
check_if_duplicated: 1,
/**
* 偷塔模式不检查是否重复转发
* * 偷塔模式: 临近开奖时参与抽奖
*/
sneaktower: true,
/**
* 屏蔽动态类型
*
* | 动态类型 | type值 |
* | :------- |:----- |
* | 转发 | `1` |
* | 含图片 | `2` |
* | 无图纯文字 | `4` |
* | 视频 | `8` |
* | 番剧 | `512` |
* | 活动 | `2048` |
* | 专栏 | `64` |
*/
block_dynamic_type: [0],
/**
* - 动态创建时间
* - 多少天前
@@ -133,7 +183,6 @@ module.exports = Object.freeze({
lottery_loop_wait: 0,
check_loop_wait: 0,
clear_loop_wait: 0,
update_loop_wait: 0,
/**
* - 转发间隔时间
@@ -184,6 +233,12 @@ module.exports = Object.freeze({
*/
random_dynamic_wait: 2000,
/**
* - 预约抽奖间隔
* - 单位毫秒
*/
reserve_lottery_wait: 6000,
/**
* - up主粉丝数限制
*/
@@ -235,23 +290,39 @@ module.exports = Object.freeze({
at_users: [['转发抽奖娘', 294887687], ['你的工具人老公', 100680137]],
/**
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 动态dyid或UID
* - 英文逗号分隔 如: 1,2,3
*/
blacklist: '',
/**
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 使用公共黑名单
*/
use_public_blacklist: true,
/**
* 屏蔽词
*/
blockword: ["脚本抽奖", "恭喜", "结果", "抽奖号", "钓鱼", "涨粉"],
blockword: ["脚本", "抽奖号", "钓鱼"],
/**
* 转发并评论
* - 评论内容与转发内容相同
*/
is_repost_then_chat: false,
/**
* 转发评语
* 支持变量${uname}
*/
relay: ['转发动态'],
/**
* 评论内容
* 支持变量${uname}
* @example
* "祝${uname}早日百大!"
*/
chat: [
'[OK]', '[星星眼]', '[歪嘴]', '[喜欢]', '[偷笑]', '[笑]', '[喜极而泣]', '[辣眼睛]', '[吃瓜]', '[奋斗]',
@@ -272,6 +343,11 @@ module.exports = Object.freeze({
*/
is_exception: false,
/**
* 是否关注已达上限
*/
is_outof_maxfollow: false,
/**
* - 中奖通知关键词(满足一个就推送)
* - 符合js正则表达式的字符串
@@ -280,9 +356,21 @@ module.exports = Object.freeze({
*/
notice_key_words: [
"~预约成功|预约主题",
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员"
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员",
"~你的账号在新设备或平台登录成功",
"~你预约的直播已开始"
],
/**
* 是否发送运行状态通知
*/
notice_running_state: false,
/**
* - 获取私信页数
*/
check_session_pages: 16,
/**
* - 清理白名单uid或dyid
* - 英文逗号分隔 如: 1,2,3
@@ -346,7 +434,28 @@ module.exports = Object.freeze({
* 针对某一账号的特别设置
* config_[数字] 依次类推
*/
config_1: {},
config_1: {
/**
* 手动添加抽奖号UID
* - 抽奖动态下的二级小号
*/
UIDs: [],
TAGs: [
'互动抽奖',
'转发抽奖',
'动态抽奖',
'抽奖',
],
Articles: [
'抽奖合集'
],
APIs: [],
save_lottery_info_to_file: true,
},
config_2: {},
config_3: {}
})
+4 -12
View File
@@ -1,16 +1,16 @@
{
"name": "lottery-auto-script",
"version": "2.3.3",
"version": "2.6.9",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {
"start": "node main.js start",
"test": "node test/index.js",
"clear": "node main.js clear",
"check": "node main.js check",
"update": "node main.js update",
"pkg_x64": "PowerShell .\\script\\pkg\\pkg.ps1",
"pkg_arm64": "npx pkg -t node16-linux-arm64 -o dist/lottery main.js && cp my_config.example.js dist/my_config.js && cp env.example.js dist/env.js",
"pkg_armv7": "npx pkg -t node16-linuxstatic-armv7 -o dist/lottery main.js && cp my_config.example.js dist/my_config.js && cp env.example.js dist/env.js"
"pkg": "bash script/build/pkg.sh",
"changelog": "bash script/build/changelog.sh"
},
"files": [
"lib",
@@ -22,14 +22,6 @@
"README.md"
],
"bin": "main.js",
"pkg": {
"targets": [
"linux-x64",
"win-x64",
"macos-x64"
],
"outputPath": "dist"
},
"repository": {
"type": "git",
"url": "https://github.com/shanmiteko/AutoScript.git"
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# version: <major.minor.patch>
level=patch
npm version $level \
--no-commit-hooks \
--no-git-tag-version
OLD_VERSION_ARRAY=($(npm view lottery-auto-script version | tr '.' ' '))
major=${OLD_VERSION_ARRAY[0]}
minor=${OLD_VERSION_ARRAY[1]}
patch=${OLD_VERSION_ARRAY[2]}
case "${level}" in
"major")
((major += 1))
minor=0
patch=0
;;
"minor")
((minor += 1))
patch=0
;;
*)
((patch += 1))
;;
esac
NEW_VERSION="$major.$minor.$patch"
echo "New Version: $NEW_VERSION"
GIT_LOG="$(git log --pretty=format:"* %h %s" | sed -e '/CHANGELOG/,$d' | sed ':a;N;s/\n/\\n/g;ta')"
sed -i "/# CHANGELOG/a\## 主要变化($NEW_VERSION)\n$GIT_LOG\n\n_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_\n" CHANGELOG.md
git add .
git commit -m "docs: 更新CHANGELOG"
+74
View File
@@ -0,0 +1,74 @@
#!/usr/bin/env bash
set -e
ROOT=$PWD
README="README.md"
TEMPLATE_CONFIG_FILE="my_config.example.js"
TEMPLATE_ENV_FILE="env.example.js"
CONFIG_FILE="my_config.js"
ENV_FILE="env.js"
TARGET_DIR="dist"
BIN_NAME="lottery"
create_win_bat() {
echo "@echo off && lottery $1 && pause"
}
if [ -d "$TARGET_DIR" ]; then
rm -rf "$TARGET_DIR"
fi
if [[ -z "$1" ]]; then
$1=node18-linux-x64
fi
mkdir -p $TARGET_DIR
npm install
if [[ "$1" == *"arm"* ]]; then
OUTFILE="$TARGET_DIR/lottery-auto-script-node18-$1"
sudo podman run --rm --privileged multiarch/qemu-user-static --reset -p yes
podman run -it \
--rm \
-v ${PWD}:/root/lottery \
shanmite/pkg-arm64 -t "node18.5.0-$1" -o "$OUTFILE" .
elif [[ "$1" == *"x64"* ]]; then
OUTFILE="$TARGET_DIR/lottery-auto-script-$1"
npx pkg -t "$1" -o "$OUTFILE" .
fi
for file in "$TARGET_DIR/"*; do
TMPDIR="${file%.exe}"
TMPDIR_NAME="${TMPDIR##*/}"
REMANE_FILE="$TARGET_DIR/$BIN_NAME"
mv $file $REMANE_FILE
mkdir -p "$TMPDIR.d/"
mv $REMANE_FILE "$TMPDIR.d/"
cp $README "$TMPDIR.d/"
cp $TEMPLATE_CONFIG_FILE "$TMPDIR.d/$CONFIG_FILE"
cp $TEMPLATE_ENV_FILE "$TMPDIR.d/$ENV_FILE"
if [ "$(echo $file | grep '.exe')" ]; then
BATS=("start" "check" "clear" "update")
for item in "${BATS[@]}"; do
create_win_bat "${item}" >"$TMPDIR.d/$item.bat"
done
mv "$TMPDIR.d/$BIN_NAME" "$TMPDIR.d/$BIN_NAME.exe"
else
ZIP_NAME=latest_version0
cat >"$TMPDIR.d/update.sh" <<-EOF
#!/bin/bash
./lottery update
ZIP_NAME=$ZIP_NAME
if [[ -r "\$ZIP_NAME.zip" ]]; then
unzip \$ZIP_NAME.zip
rm \$ZIP_NAME.zip
chmod u+x lottery
fi
EOF
fi
cd $TMPDIR.d
zip -r "$TMPDIR_NAME.zip" .
mv "$TMPDIR_NAME.zip" ../
cd $ROOT
done
Regular → Executable
+86 -23
View File
@@ -29,7 +29,9 @@ if [ ! -f "$ENV_FILE" ]; then
echo "create $ENV_FILE"
curl -fsSL $ENV_EXAMPLE -o $ENV_FILE
else
echo "$ENV_FILE exists"
echo "$ENV_FILE already existed"
echo "create new_$ENV_FILE"
curl -fsSL $ENV_EXAMPLE -o "new_$ENV_FILE"
fi
# 新建配置文件
@@ -37,38 +39,99 @@ if [ ! -f "$CONFIG_FILE" ]; then
echo "create $CONFIG_FILE"
curl -fsSL $CONFIG_EXAMPLE -o $CONFIG_FILE
else
echo "$CONFIG_FILE exists"
echo "$CONFIG_FILE already existed"
echo "create new_$CONFIG_FILE"
curl -fsSL $CONFIG_EXAMPLE -o "new_$CONFIG_FILE"
fi
echo "docker pull $DOCKER_REPO"
docker -v && docker pull $DOCKER_REPO
echo "create start.sh"
echo -e "#!/bin/bash\n\
docker run \
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \
$DOCKER_REPO \
start" \
> start.sh
cat >start.sh <<EOF
#!/bin/env bash
NAME=shanmite-lottery-start
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
docker run \\
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
--name \$NAME \\
$DOCKER_REPO \\
start
else
echo "container \$NAME already existed"
echo "history logs -> docker logs \$NAME"
echo "close this -> docker stop \$NAME"
echo "start \$NAME"
docker start \$NAME
fi
EOF
chmod +x start.sh
echo "create check.sh"
echo -e "#!/bin/bash\n\
docker run \
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \
$DOCKER_REPO \
check" \
> check.sh
cat >check.sh <<EOF
#!/bin/env bash
NAME=shanmite-lottery-check
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
docker run \\
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
--name \$NAME \\
$DOCKER_REPO \\
check
else
echo "container \$NAME already existed"
echo "history logs -> docker logs \$NAME"
echo "close this -> docker stop \$NAME"
echo "start \$NAME"
docker start \$NAME
fi
EOF
chmod +x check.sh
echo "create clear.sh"
echo -e "#!/bin/bash\n\
docker run \
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \
$DOCKER_REPO \
clear" \
> clear.sh
cat >clear.sh <<EOF
#!/bin/env bash
NAME=shanmite-lottery-clear
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
docker run \\
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
--name \$NAME \\
$DOCKER_REPO \\
clear
else
echo "container \$NAME already existed"
echo "history logs -> docker logs \$NAME"
echo "close this -> docker stop \$NAME"
echo "start \$NAME"
docker start \$NAME
fi
EOF
chmod +x clear.sh
echo "create debug.sh"
cat >debug.sh <<EOF
#!/bin/env bash
NAME=shanmite-lottery-debug
echo "create temporary debug container"
docker run \\
-it \\
--name \$NAME \\
--entrypoint /bin/bash \\
$DOCKER_REPO -c bash
echo "remove temporary debug container"
docker rm -v \$NAME
EOF
chmod +x debug.sh
echo "create remove_all.sh"
cat >remove_all.sh <<EOF
#!/bin/env bash
echo "remove all containers about $DOCKER_REPO"
docker rm -v \$(docker ps -a | awk '/shanmite\/lottery_auto_docker/ {print \$1}')
echo "remove image $DOCKER_REPO"
docker image rm -f shanmite/lottery_auto_docker
echo "see you next time!"
EOF
chmod +x remove_all.sh
-57
View File
@@ -1,57 +0,0 @@
$README = "README.md"
$TEMPLATE_CONFIG_FILE = "my_config.example.js"
$TEMPLATE_ENV_FILE = "env.example.js"
$CONFIG_FILE = "my_config.js"
$ENV_FILE = "env.js"
$TARGET_DIR = ".\dist"
$NAME = 'lottery-auto-script'
$TRIARR = @(
@("$NAME-win.exe", "lottery.exe", "nlts-win-x64"),
@("$NAME-linux", "lottery", "nlts-linux-x64"),
@("$NAME-macos", "lottery", "nlts-macos-x64")
)
if((Test-Path $TARGET_DIR) -eq "True") {
Remove-Item -Path $TARGET_DIR -Recurse
}
npx pkg .
Copy-Item -Path $TEMPLATE_ENV_FILE -Destination $TARGET_DIR -Force
Copy-Item -Path $TEMPLATE_CONFIG_FILE -Destination $TARGET_DIR -Force
Copy-Item -Path $README -Destination $TARGET_DIR -Force
Set-Location -Path $TARGET_DIR
Move-Item -Path $TEMPLATE_ENV_FILE -Destination $ENV_FILE -Force
Move-Item -Path $TEMPLATE_CONFIG_FILE -Destination $CONFIG_FILE -Force
foreach ($TRI in $TRIARR) {
$PROTO_BIN,$BIN,$DIR = $TRI
New-Item -ItemType Directory -Force -Path $DIR
Move-Item -Path $PROTO_BIN -Destination $BIN -Force
Move-Item -Path $BIN -Destination $DIR -Force
Copy-Item -Path $ENV_FILE -Destination $DIR -Force
Copy-Item -Path $CONFIG_FILE -Destination $DIR -Force
Copy-Item -Path $README -Destination $DIR -Force
if ($DIR -eq "nlts-win-x64") {
New-Item -Path $DIR -Name "start.bat" -ItemType File -Value "@echo off && lottery start && pause" -Force
New-Item -Path $DIR -Name "check.bat" -ItemType File -Value "@echo off && lottery check && pause" -Force
New-Item -Path $DIR -Name "clear.bat" -ItemType File -Value "@echo off && lottery clear && pause" -Force
New-Item -Path $DIR -Name "update.bat" -ItemType File -Value "@echo off && lottery update && pause" -Force
}
Compress-Archive -Path $DIR -DestinationPath $DIR -Force
}
Remove-Item -Path $ENV_FILE
Remove-Item -Path $CONFIG_FILE
Remove-Item -Path $README
+43
View File
@@ -0,0 +1,43 @@
#!/bin/env bash
set -e
NAME=LotteryAutoScript
# 视网络情况选择链接
GIT_REPO=https://github.com/shanmiteko/${NAME}.git
# GIT_REPO=https://ghproxy.com/https://github.com/shanmiteko/${NAME}.git
if [ -d "$NAME" ]; then
cd $NAME
git pull
cd ..
else
git clone $GIT_REPO $NAME --depth=1
fi
if [ -f "$NAME/my_config.js" ]; then
echo 'my_config 已存在'
else
cp $NAME/my_config.example.js $NAME/my_config.js
fi
if [ -f "$NAME/env.js" ]; then
echo 'env.js 已存在'
else
cp $NAME/env.example.js $NAME/env.js
fi
function create() {
cat >"${NAME}_$1.sh" <<EOF
#!/bin/env bash
cd $NAME
npm run $1
EOF
}
create start
create check
create clear
cd $NAME
npm i
-8
View File
@@ -1,8 +0,0 @@
#!/bin/bash
./lottery update
if [[ -r "latest_version.zip" ]]; then
unzip latest_version.zip
rm latest_version.zip
chmod u+x lottery
fi
+40
View File
@@ -0,0 +1,40 @@
const assert = require('assert');
const bili_client = require("../lib/net/bili");
const util = require('./util');
(async () => {
assert(await bili_client.getMyinfo());
await util.par_run([
async () => {
assert.equal((await bili_client.getTopRcmd()).length, 10)
},
async () => {
assert.equal(await bili_client.sendChat(
(await bili_client.getOneDynamicByDyid("692193323569381399")).desc.rid,
"test",
11),
7
)
},
async () => {
assert.equal(await bili_client.sendChat(
(await bili_client.getOneDynamicByDyid("11229466874154064")).desc.rid,
"test",
1),
3
)
},
async () => {
assert.notEqual((await bili_client.searchArticlesByKeyword("专栏")).length, 0)
},
async () => {
assert.notEqual(await bili_client.sendChat("703886913053917267", "t", 17), 1)
},
async () => {
// assert(!await bili_client.createDynamic("123"))
}
])
console.log("api.test ... ok!");
})()
+12
View File
@@ -0,0 +1,12 @@
const env = require("../lib/data/env");
const global_var = require("../lib/data/global_var");
const { log } = require('../lib/utils');
const fs = require('fs');
log._level = 1
env.init()
global_var.init(process.env["COOKIE"], 1)
fs.readdirSync(module.path)
.filter(file => file.endsWith(".test.js"))
.forEach(file => require(`${module.path}/${file}`))
+10
View File
@@ -0,0 +1,10 @@
/**
* @param {Array<()=>any>} fns
*/
function par_run(fns) {
return Promise.all((fns.map(fn => fn())))
}
module.exports = {
par_run
}