mirror of
https://github.com/lkeme/BiliHelper-personal.git
synced 2025-12-19 09:30:10 +08:00
[update] Version 0.9.0
This commit is contained in:
parent
34bffe404f
commit
3c03757d02
12
.gitignore
vendored
12
.gitignore
vendored
@ -17,14 +17,14 @@ gen
|
|||||||
/configs/
|
/configs/
|
||||||
/tests/
|
/tests/
|
||||||
config
|
config
|
||||||
/conf/user*.conf
|
/conf/user*.ini
|
||||||
*.log
|
*.log
|
||||||
Traits/
|
Traits/
|
||||||
README1.md
|
README1.md
|
||||||
conf/user.conf
|
conf/user.ini
|
||||||
conf/user1.conf
|
conf/user1.ini
|
||||||
/conf/user.conf
|
/conf/user.ini
|
||||||
/conf/test.conf
|
/conf/test.ini
|
||||||
/conf/test1.conf
|
/conf/test1.ini
|
||||||
/log/
|
/log/
|
||||||
/src/backup/
|
/src/backup/
|
||||||
115
CHANGELOG.md
115
CHANGELOG.md
@ -1,12 +1,36 @@
|
|||||||
# Release Notes
|
# Release Notes
|
||||||
|
|
||||||
# 本项目Log
|
# 本项目Log
|
||||||
|
|
||||||
|
## v0.9.0.210517 alpha (2021-05-17)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 重大更新
|
||||||
|
-
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 懒得写描述
|
||||||
|
-
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 配置文件有变动
|
||||||
|
-
|
||||||
|
|
||||||
|
### Remarks
|
||||||
|
|
||||||
|
- 请重新配置
|
||||||
|
-
|
||||||
|
|
||||||
## v0.8.1.210423 alpha (2021-04-23)
|
## v0.8.1.210423 alpha (2021-04-23)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- 更新天选敏感词
|
- 更新天选敏感词
|
||||||
- 更新活动列表
|
- 更新活动列表
|
||||||
- 优化直播间心跳
|
- 优化直播间心跳
|
||||||
@ -21,12 +45,14 @@
|
|||||||
## v0.8.0.210327 alpha (2021-03-27)
|
## v0.8.0.210327 alpha (2021-03-27)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 增加直播扭蛋抽奖活动(可自定义)
|
- 增加直播扭蛋抽奖活动(可自定义)
|
||||||
- 增加主站九宫格抽奖活动(可自定义)
|
- 增加主站九宫格抽奖活动(可自定义)
|
||||||
- 增加多个推送消息通道
|
- 增加多个推送消息通道
|
||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- 更新过滤词独立
|
- 更新过滤词独立
|
||||||
- 更新请求中心
|
- 更新请求中心
|
||||||
- 更新日志打印
|
- 更新日志打印
|
||||||
@ -43,13 +69,15 @@
|
|||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复小心心心跳错误
|
- 修复小心心心跳错误
|
||||||
- 修复部分推送错误
|
- 修复部分推送错误
|
||||||
- 修复银瓜子换银币日志错误
|
- 修复银瓜子换银币日志错误
|
||||||
-
|
-
|
||||||
|
|
||||||
### Remarks
|
### Remarks
|
||||||
- 结构大更新,务必进行Composer等操作
|
|
||||||
|
- 结构大更新,务必进行Composer等操作
|
||||||
-
|
-
|
||||||
|
|
||||||
## v0.6.7.201117 alpha (2020-11-17)
|
## v0.6.7.201117 alpha (2020-11-17)
|
||||||
@ -58,6 +86,7 @@
|
|||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- 调整WS读取数据大小
|
- 调整WS读取数据大小
|
||||||
- 调整弹幕发送时间
|
- 调整弹幕发送时间
|
||||||
- 更新天选之子日志打印
|
- 更新天选之子日志打印
|
||||||
@ -65,52 +94,61 @@
|
|||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复小心心心跳错误
|
- 修复小心心心跳错误
|
||||||
-
|
-
|
||||||
|
|
||||||
## v0.6.5.200808 alpha (2020-08-08)
|
## v0.6.5.200808 alpha (2020-08-08)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 添加小心心支持
|
- 添加小心心支持
|
||||||
- 添加活动抽奖
|
- 添加活动抽奖
|
||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- 去掉无效双端观看
|
- 去掉无效双端观看
|
||||||
- 过期小心心赠送
|
- 过期小心心赠送
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复小心心心跳错误
|
- 修复小心心心跳错误
|
||||||
-
|
-
|
||||||
|
|
||||||
## v0.6.0.200730 alpha (2020-07-30)
|
## v0.6.0.200730 alpha (2020-07-30)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 添加小心心支持
|
- 添加小心心支持
|
||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- 更新天选过滤关键词
|
- 更新天选过滤关键词
|
||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复节奏风暴逻辑错误
|
- 修复节奏风暴逻辑错误
|
||||||
-
|
-
|
||||||
|
|
||||||
## v0.5.0.200625 alpha (2020-06-25)
|
## v0.5.0.200625 alpha (2020-06-25)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 添加破产机(赔到破产)
|
- 添加破产机(赔到破产)
|
||||||
- 添加推送KEY到期通知
|
- 添加推送KEY到期通知
|
||||||
- 添加天选自动取关(测试)
|
- 添加天选自动取关(测试)
|
||||||
- 添加收益统计
|
- 添加收益统计
|
||||||
- 添加关注投币模式
|
- 添加关注投币模式
|
||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- 更新部分信息输出
|
- 更新部分信息输出
|
||||||
- 修改日志打印前缀
|
- 修改日志打印前缀
|
||||||
- 更新活跃弹幕延迟
|
- 更新活跃弹幕延迟
|
||||||
- 重构部分统计代码
|
- 重构部分统计代码
|
||||||
- 更新视频投币逻辑
|
- 更新视频投币逻辑
|
||||||
- 更新实物抽奖API
|
- 更新实物抽奖API
|
||||||
@ -119,10 +157,11 @@
|
|||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复日志输出错误
|
- 修复日志输出错误
|
||||||
- 修复每日送礼异常
|
- 修复每日送礼异常
|
||||||
- 修复赛事逻辑错误
|
- 修复赛事逻辑错误
|
||||||
- 修复部分已知问题
|
- 修复部分已知问题
|
||||||
-
|
-
|
||||||
|
|
||||||
## v0.4.0.200505 alpha (2020-05-05)
|
## v0.4.0.200505 alpha (2020-05-05)
|
||||||
@ -131,15 +170,17 @@
|
|||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- 关闭已结束的LPL赛事任务
|
- 关闭已结束的LPL赛事任务
|
||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复日志回调空格解析异常
|
- 修复日志回调空格解析异常
|
||||||
- 修复节奏风暴回显过滤错误
|
- 修复节奏风暴回显过滤错误
|
||||||
- 修复活动抽奖重复请求问题
|
- 修复活动抽奖重复请求问题
|
||||||
- 修复主站任务获取AID异常
|
- 修复主站任务获取AID异常
|
||||||
-
|
-
|
||||||
|
|
||||||
## v0.4.0.200428 alpha (2020-04-28)
|
## v0.4.0.200428 alpha (2020-04-28)
|
||||||
|
|
||||||
@ -150,49 +191,58 @@
|
|||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复赠送礼物逻辑
|
- 修复赠送礼物逻辑
|
||||||
-
|
-
|
||||||
|
|
||||||
## v0.4.0.200426 alpha (2020-04-26)
|
## v0.4.0.200426 alpha (2020-04-26)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 赛事助手 (签到、分享)
|
- 赛事助手 (签到、分享)
|
||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复休眠机制
|
- 修复休眠机制
|
||||||
-
|
-
|
||||||
|
|
||||||
## v0.3.0.200425 alpha (2020-04-25)
|
## v0.3.0.200425 alpha (2020-04-25)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 添加调用函数
|
- 添加调用函数
|
||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- 取消一处请求头
|
- 取消一处请求头
|
||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复休眠机制
|
- 修复休眠机制
|
||||||
-
|
-
|
||||||
|
|
||||||
## v0.3.0.200424 alpha (2020-04-24)
|
## v0.3.0.200424 alpha (2020-04-24)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 抽出独立小黑屋
|
- 抽出独立小黑屋
|
||||||
- 提前引入BV2AV
|
- 提前引入BV2AV
|
||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- 优化监控推送
|
- 优化监控推送
|
||||||
- 优化登录参数
|
- 优化登录参数
|
||||||
- 同步黑屋提醒
|
- 同步黑屋提醒
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复监控输出
|
- 修复监控输出
|
||||||
-
|
-
|
||||||
|
|
||||||
@ -205,6 +255,7 @@
|
|||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复节奏风暴回显
|
- 修复节奏风暴回显
|
||||||
- 修复分区监控异常
|
- 修复分区监控异常
|
||||||
- 修复获取勋章异常
|
- 修复获取勋章异常
|
||||||
@ -216,10 +267,12 @@
|
|||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- 去除主监控
|
- 去除主监控
|
||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复风暴回显过滤
|
- 修复风暴回显过滤
|
||||||
- 修复一处舰长处理
|
- 修复一处舰长处理
|
||||||
- 修复中奖记录通知
|
- 修复中奖记录通知
|
||||||
@ -236,6 +289,7 @@
|
|||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复备用监控无法获取
|
- 修复备用监控无法获取
|
||||||
- 修复获取分区ID异常
|
- 修复获取分区ID异常
|
||||||
-
|
-
|
||||||
@ -243,6 +297,7 @@
|
|||||||
## v0.3.0.200404 alpha (2020-04-04)
|
## v0.3.0.200404 alpha (2020-04-04)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 添加ISSUE模板
|
- 添加ISSUE模板
|
||||||
- 添加处理监控端命令
|
- 添加处理监控端命令
|
||||||
-
|
-
|
||||||
@ -251,6 +306,7 @@
|
|||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复主监控内存溢出
|
- 修复主监控内存溢出
|
||||||
- 修复活动礼物提醒
|
- 修复活动礼物提醒
|
||||||
-
|
-
|
||||||
@ -258,10 +314,12 @@
|
|||||||
## v0.3.0.200318 alpha (2020-03-18)
|
## v0.3.0.200318 alpha (2020-03-18)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 添加日常任务定时执行(AM10:00)
|
- 添加日常任务定时执行(AM10:00)
|
||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Sleep->Schedule
|
- Sleep->Schedule
|
||||||
- 优化异常通知
|
- 优化异常通知
|
||||||
- 优化异常重试数
|
- 优化异常重试数
|
||||||
@ -270,6 +328,7 @@
|
|||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复日志回调
|
- 修复日志回调
|
||||||
- 修复response为null
|
- 修复response为null
|
||||||
- 修复PC端心跳
|
- 修复PC端心跳
|
||||||
@ -279,13 +338,15 @@
|
|||||||
## v0.3.0.200316 alpha (2020-03-16)
|
## v0.3.0.200316 alpha (2020-03-16)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 添加异常处理(通知)
|
- 添加异常处理(通知)
|
||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复活跃弹幕
|
- 修复活跃弹幕
|
||||||
- 修复风纪测试
|
- 修复风纪测试
|
||||||
- 修复部分已知
|
- 修复部分已知
|
||||||
@ -294,16 +355,19 @@
|
|||||||
## v0.3.0.200312 alpha (2020-03-12)
|
## v0.3.0.200312 alpha (2020-03-12)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 引入风纪 (不稳定测试)
|
- 引入风纪 (不稳定测试)
|
||||||
- 引入新库 (需要重新Composer)
|
- 引入新库 (需要重新Composer)
|
||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- 重构部分公用方法
|
- 重构部分公用方法
|
||||||
- 重构CURL请求
|
- 重构CURL请求
|
||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复登录繁忙
|
- 修复登录繁忙
|
||||||
- 修复实物抽奖
|
- 修复实物抽奖
|
||||||
- 修复日志输出
|
- 修复日志输出
|
||||||
@ -319,18 +383,21 @@
|
|||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复节奏风暴
|
- 修复节奏风暴
|
||||||
- 修复双端心跳
|
- 修复双端心跳
|
||||||
-
|
-
|
||||||
|
|
||||||
## v0.2.0.200224 alpha (2020-02-24)
|
## v0.2.0.200224 alpha (2020-02-24)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 新增工具类
|
- 新增工具类
|
||||||
- 引入新库(需要重新Composer)
|
- 引入新库(需要重新Composer)
|
||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- 优化数据过滤条件
|
- 优化数据过滤条件
|
||||||
- 更新PC端心跳API
|
- 更新PC端心跳API
|
||||||
- 优化实物抽奖
|
- 优化实物抽奖
|
||||||
@ -338,9 +405,10 @@
|
|||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复内存异常
|
- 修复内存异常
|
||||||
- 修复重复投币
|
- 修复重复投币
|
||||||
-
|
-
|
||||||
|
|
||||||
## v0.2.0.200214 alpha (2020-02-14)
|
## v0.2.0.200214 alpha (2020-02-14)
|
||||||
|
|
||||||
@ -348,10 +416,12 @@
|
|||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- 优化实物抽奖流程
|
- 优化实物抽奖流程
|
||||||
- 优化延迟礼物抽奖
|
- 优化延迟礼物抽奖
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修正部分函数名称
|
- 修正部分函数名称
|
||||||
- 尝试减少静态占用
|
- 尝试减少静态占用
|
||||||
-
|
-
|
||||||
@ -359,20 +429,24 @@
|
|||||||
## v0.2.0.200208 alpha (2020-02-08)
|
## v0.2.0.200208 alpha (2020-02-08)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 哔哩哔哩漫画助手(可选)
|
- 哔哩哔哩漫画助手(可选)
|
||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- 补充部分过滤关键字
|
- 补充部分过滤关键字
|
||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复一处内存异常
|
- 修复一处内存异常
|
||||||
-
|
-
|
||||||
|
|
||||||
## v0.1.0.200111 alpha (2020-01-11)
|
## v0.1.0.200111 alpha (2020-01-11)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 天选时刻奖品过滤
|
- 天选时刻奖品过滤
|
||||||
-
|
-
|
||||||
|
|
||||||
@ -385,6 +459,7 @@
|
|||||||
## v0.1.0.200128 alpha (2020-01-28)
|
## v0.1.0.200128 alpha (2020-01-28)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 增加推送消息过滤
|
- 增加推送消息过滤
|
||||||
-
|
-
|
||||||
|
|
||||||
@ -392,12 +467,14 @@
|
|||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复抽奖推送错误
|
- 修复抽奖推送错误
|
||||||
-
|
-
|
||||||
|
|
||||||
## v0.1.0.200111 alpha (2020-01-11)
|
## v0.1.0.200111 alpha (2020-01-11)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 天选时刻奖品过滤
|
- 天选时刻奖品过滤
|
||||||
-
|
-
|
||||||
|
|
||||||
@ -410,40 +487,47 @@
|
|||||||
## v0.1.0.200103 alpha (2020-01-03)
|
## v0.1.0.200103 alpha (2020-01-03)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 增加并发请求
|
- 增加并发请求
|
||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- 更新抽奖逻辑
|
- 更新抽奖逻辑
|
||||||
- 更新部分API
|
- 更新部分API
|
||||||
- 减少重复请求
|
- 减少重复请求
|
||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复部分回显错误
|
- 修复部分回显错误
|
||||||
-
|
-
|
||||||
|
|
||||||
## v0.1.0.200101 alpha (2020-01-01)
|
## v0.1.0.200101 alpha (2020-01-01)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 任务逻辑引入协程
|
- 任务逻辑引入协程
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复礼物赠送异常
|
- 修复礼物赠送异常
|
||||||
-
|
-
|
||||||
|
|
||||||
## v0.1.0.191227 alpha (2019-12-27)
|
## v0.1.0.191227 alpha (2019-12-27)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 新增备用官方分区监控
|
- 新增备用官方分区监控
|
||||||
- 新增按勋章亲密度赠送
|
- 新增按勋章亲密度赠送
|
||||||
- 新增天选时刻获奖推送
|
- 新增天选时刻获奖推送
|
||||||
-
|
-
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- 优化部分架构
|
- 优化部分架构
|
||||||
- 优化独立监控
|
- 优化独立监控
|
||||||
- 优化监控逻辑
|
- 优化监控逻辑
|
||||||
@ -453,6 +537,7 @@
|
|||||||
-
|
-
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 修复部分日志显示
|
- 修复部分日志显示
|
||||||
- 修复数据统计异常
|
- 修复数据统计异常
|
||||||
- 修复瓜子宝箱异常
|
- 修复瓜子宝箱异常
|
||||||
@ -462,7 +547,7 @@
|
|||||||
- 修复部分已知BUG
|
- 修复部分已知BUG
|
||||||
- 修复获奖推送通知
|
- 修复获奖推送通知
|
||||||
- 修复休眠中心异常
|
- 修复休眠中心异常
|
||||||
- 修复礼物赠送异常
|
- 修复礼物赠送异常
|
||||||
-
|
-
|
||||||
|
|
||||||
## v0.0.5.191223 alpha (2019-12-23)
|
## v0.0.5.191223 alpha (2019-12-23)
|
||||||
|
|||||||
227
DOC.md
227
DOC.md
@ -1,68 +1,8 @@
|
|||||||
|
|
||||||
<p align="center"><img width="300px" src="https://i.loli.net/2018/04/20/5ad97bd395912.jpeg"></p>
|
|
||||||
|
|
||||||
<p align="center">
|
|
||||||
<img src="https://img.shields.io/badge/version-0.8.1.210423 alpha-green.svg?longCache=true&style=for-the-badge">
|
|
||||||
<img src="https://img.shields.io/badge/license-mit-blue.svg?longCache=true&style=for-the-badge">
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
# BiliHelper
|
|
||||||
|
|
||||||
B 站直播实用脚本
|
|
||||||
|
|
||||||
## 功能组件
|
|
||||||
|
|
||||||
|plugin |version |description |
|
|
||||||
|--------------------|--------------------|--------------------|
|
|
||||||
|Login |21.03.27 |账号登录 |
|
|
||||||
|Schedule |21.03.27 |休眠控制 |
|
|
||||||
|MainSite |21.03.27 |主站助手 |
|
|
||||||
|Daily |21.03.27 |每日礼包 |
|
|
||||||
|Heart |21.03.27 |双端心跳 |
|
|
||||||
|DailyTask |21.03.27 |每日任务 |
|
|
||||||
|Silver |21.03.27 |银瓜子宝箱 |
|
|
||||||
|Barrage |21.03.27 |活跃弹幕 |
|
|
||||||
|Silver2Coin |21.03.27 |银瓜子换硬币 |
|
|
||||||
|GiftSend |21.03.27 |礼物赠送 |
|
|
||||||
|Judge |21.03.27 |风纪 |
|
|
||||||
|GroupSignIn |21.03.27 |友爱社签到 |
|
|
||||||
|ManGa |21.03.27 |漫画签到分享 |
|
|
||||||
|GameMatch |21.03.27 |赛事签到分享 |
|
|
||||||
|GiftHeart |21.03.27 |心跳礼物 |
|
|
||||||
|MaterialObject |21.03.27 |实物抽奖 |
|
|
||||||
|AloneTcpClient |21.03.27 |独立监控 |
|
|
||||||
|ZoneTcpClient |21.03.27 |分区监控 |
|
|
||||||
|StormRaffle |21.03.27 |节奏风暴 |
|
|
||||||
|GiftRaffle |21.03.27 |活动礼物 |
|
|
||||||
|PkRaffle |21.03.27 |大乱斗 |
|
|
||||||
|GuardRaffle |21.03.27 |舰长总督 |
|
|
||||||
|AnchorRaffle |21.03.27 |天选时刻 |
|
|
||||||
|AwardRecord |21.03.27 |获奖通知 |
|
|
||||||
|Statistics |21.03.27 |数据统计 |
|
|
||||||
|Competition |21.03.27 |赛事竞猜 |
|
|
||||||
|SmallHeart |21.03.27 |小心心 |
|
|
||||||
|ActivityLottery |21.03.27 |主站活动 |
|
|
||||||
|CapsuleLottery |21.03.27 |直播扭蛋活动 |
|
|
||||||
|Forward |21.03.27 |动态抽奖转发 |
|
|
||||||
|
|
||||||
## 打赏赞助
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
> 待添加
|
|
||||||
|
|
||||||
## 未完成功能
|
|
||||||
|
|
||||||
|待续 |
|
|
||||||
|-----------|
|
|
||||||
|多用户 |
|
|
||||||
|
|
||||||
## 环境依赖
|
## 环境依赖
|
||||||
|
|
||||||
|Requirement |
|
|Requirement |
|
||||||
|--------------------|
|
|--------------------|
|
||||||
|PHP >=7.0 |
|
|PHP >=7.3 |
|
||||||
|php_curl |
|
|php_curl |
|
||||||
|php_sockets |
|
|php_sockets |
|
||||||
|php_openssl |
|
|php_openssl |
|
||||||
@ -70,61 +10,129 @@ B 站直播实用脚本
|
|||||||
|php_zlib |
|
|php_zlib |
|
||||||
|php_mbstring |
|
|php_mbstring |
|
||||||
|
|
||||||
通常使用 `composer` 工具会自动检测上述依赖问题。
|
> 通常使用 `composer` 工具会自动检测上述依赖问题。
|
||||||
|
|
||||||
## Composer
|
## Composer
|
||||||
* 项目 `composer.lock` 基于阿里云Composer镜像生成
|
|
||||||
+ 阿里云(推荐)
|
+ [Composer 安装与使用](https://www.runoob.com/w3cnote/composer-install-and-usage.html)
|
||||||
```
|
|
||||||
|
+ [Composer 下载](https://getcomposer.org/download/)
|
||||||
|
|
||||||
|
+ 当前项目 `composer.lock` 基于阿里云 Composer镜像生成
|
||||||
|
|
||||||
|
+ 阿里云(全量镜像)
|
||||||
|
|
||||||
|
```bash
|
||||||
# 使用帮助
|
# 使用帮助
|
||||||
https://developer.aliyun.com/composer
|
> https://developer.aliyun.com/composer
|
||||||
# 使用命令
|
# 使用命令
|
||||||
> composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
|
> composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
|
||||||
```
|
```
|
||||||
* 腾讯云(备用)
|
|
||||||
|
+ 恢复默认镜像|Composer.phar加速下载
|
||||||
|
|
||||||
|
```bash
|
||||||
|
> composer config -g --unset repos.packagist
|
||||||
|
|
||||||
|
> https://mirrors.cloud.tencent.com/composer/composer.phar
|
||||||
|
> https://mirrors.aliyun.com/composer/composer.phar
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>其余镜像 展开查看</summary>
|
||||||
|
<pre><code>
|
||||||
|
+ cnpkg(全量镜像)
|
||||||
|
```bash
|
||||||
# 使用帮助
|
# 使用帮助
|
||||||
https://mirrors.cloud.tencent.com/composer/
|
> https://php.cnpkg.org/
|
||||||
# 使用命令
|
# 使用命令
|
||||||
composer config -g repos.packagist composer https://mirrors.cloud.tencent.com/composer/
|
> composer config -g repos.packagist composer https://php.cnpkg.org
|
||||||
```
|
```
|
||||||
|
|
||||||
|
+ 腾讯云(全量镜像)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 使用帮助
|
||||||
|
> https://mirrors.cloud.tencent.com/help/composer.html
|
||||||
|
# 使用命令
|
||||||
|
> composer config -g repos.packagist composer https://mirrors.cloud.tencent.com/composer/
|
||||||
|
```
|
||||||
|
|
||||||
|
+ phpcomposer(全量镜像)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 使用帮助
|
||||||
|
> https://pkg.phpcomposer.com/
|
||||||
|
# 使用命令
|
||||||
|
> composer config -g repo.packagist composer https://packagist.phpcomposer.com
|
||||||
|
```
|
||||||
|
|
||||||
|
+ 华为云(全量镜像)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 使用帮助
|
||||||
|
> https://mirrors.huaweicloud.com/repository/php/
|
||||||
|
# 使用命令
|
||||||
|
> composer config -g repos.packagist composer https://mirrors.huaweicloud.com/repository/php/
|
||||||
|
```
|
||||||
|
|
||||||
|
+ 交通大学(非全量镜像)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 使用帮助
|
||||||
|
> https://packagist.mirrors.sjtug.sjtu.edu.cn/
|
||||||
|
# 使用命令
|
||||||
|
> composer config -g repos.packagist composer https://packagist.mirrors.sjtug.sjtu.edu.cn
|
||||||
|
```
|
||||||
|
|
||||||
|
</code></pre>
|
||||||
|
</details>
|
||||||
|
|
||||||
## 使用指南
|
## 使用指南
|
||||||
|
|
||||||
1. 下载(克隆)项目代码,初始化项目
|
1. 下载(克隆)项目代码,初始化项目
|
||||||
|
|
||||||
```
|
```
|
||||||
$ git clone https://github.com/lkeme/BiliHelper-personal.git
|
$ git clone https://github.com/lkeme/BiliHelper-personal.git
|
||||||
$ cd BiliHelper-personal/conf
|
$ cd BiliHelper-personal/conf
|
||||||
$ cp user.conf.example user.conf
|
$ cp user.ini.example user.ini
|
||||||
```
|
```
|
||||||
2. 使用 [composer](https://getcomposer.org/download/) 工具进行安装
|
|
||||||
|
2. 使用 [composer](https://getcomposer.org/download/) 工具进行安装
|
||||||
|
|
||||||
```
|
```
|
||||||
$ composer install
|
$ composer install
|
||||||
|
$ composer dump-autoload
|
||||||
```
|
```
|
||||||
3. 按照说明修改配置文件 `user.conf`
|
|
||||||
|
3. 按照说明修改配置文件 `user.ini`
|
||||||
|
|
||||||
```
|
```
|
||||||
# 默认只需填写帐号密码,按需求开启其他功能即可
|
# 默认只需填写帐号密码,按需求开启其他功能即可
|
||||||
```
|
```
|
||||||
4. 运行测试
|
|
||||||
|
4. 运行测试
|
||||||
|
|
||||||
```
|
```
|
||||||
$ php index.php
|
$ php index.php
|
||||||
```
|
```
|
||||||
|
|
||||||
> 以下是`多账户多开方案`,单个账户可以无视
|
> 以下是`多账户多开方案`,单个账户可以无视
|
||||||
5. 复制一份example配置文件,修改账号密码即可
|
|
||||||
|
5. 复制一份example配置文件,修改账号密码即可
|
||||||
|
|
||||||
```
|
```
|
||||||
$ php index.php example.conf
|
$ php index.php example.ini
|
||||||
```
|
```
|
||||||
6. 请保证配置文件存在,否则默认加载`user.conf`配置文件
|
|
||||||
|
6. 请保证配置文件存在,否则默认加载`user.ini`配置文件
|
||||||
|
|
||||||
<p align="center"><img width="680px" src="https://i.loli.net/2018/04/21/5adb497dc3ece.png"></p>
|
<p align="center"><img width="680px" src="https://i.loli.net/2018/04/21/5adb497dc3ece.png"></p>
|
||||||
|
|
||||||
## Docker使用指南
|
## Docker使用指南
|
||||||
|
|
||||||
1. 安装好[Docker](https://yeasy.gitbooks.io/docker_practice/content/install/)
|
1. 安装好[Docker](https://yeasy.gitbooks.io/docker_practice/content/install/)
|
||||||
2. 直接命令行拉取镜像后运行
|
2. 直接命令行拉取镜像后运行
|
||||||
|
|
||||||
|
|
||||||
### 传入的参数方式有两种(二选一,如果同时传入则优先选择配置文件)
|
### 传入的参数方式有两种(二选一,如果同时传入则优先选择配置文件)
|
||||||
|
|
||||||
@ -136,12 +144,12 @@ $ php index.php
|
|||||||
|
|
||||||
- 通过配置文件进行传入
|
- 通过配置文件进行传入
|
||||||
|
|
||||||
1. 下载[配置文件](https://raw.githubusercontent.com/lkeme/BiliHelper-personal/master/conf/user.conf.example)
|
1. 下载[配置文件](https://raw.githubusercontent.com/lkeme/BiliHelper-personal/master/conf/user.ini.example)
|
||||||
2. 修改
|
2. 修改
|
||||||
3. 通过下面的命令进行挂载并运行
|
3. 通过下面的命令进行挂载并运行
|
||||||
|
|
||||||
```shell script
|
```shell script
|
||||||
docker run -itd --rm -v /path/to/your/confFileName.conf:/app/conf/user.conf zsnmwy/bilihelper-personal
|
docker run -itd --rm -v /path/to/your/confFileName.ini:/app/conf/user.ini zsnmwy/bilihelper-personal
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -155,20 +163,29 @@ docker run -itd --rm -v /path/to/your/confFileName.conf:/app/conf/user.conf zsnm
|
|||||||
- 注意: Docker镜像已经包含了所有所需的运行环境,无需在本地环境弄composer。每次启动容器时,都会与项目进行同步以确保版本最新。
|
- 注意: Docker镜像已经包含了所有所需的运行环境,无需在本地环境弄composer。每次启动容器时,都会与项目进行同步以确保版本最新。
|
||||||
|
|
||||||
## 升级指南
|
## 升级指南
|
||||||
|
|
||||||
> 注意新版本的配置文件是否变动,则需要重新覆盖配置文件,并重新填写设置
|
> 注意新版本的配置文件是否变动,则需要重新覆盖配置文件,并重新填写设置
|
||||||
1. 进入项目目录
|
|
||||||
|
1. 进入项目目录
|
||||||
|
|
||||||
```
|
```
|
||||||
$ cd BiliHelper-personal
|
$ cd BiliHelper-personal
|
||||||
```
|
```
|
||||||
2. 拉取最新代码
|
|
||||||
|
2. 拉取最新代码
|
||||||
|
|
||||||
```
|
```
|
||||||
$ git pull
|
$ git pull
|
||||||
```
|
```
|
||||||
3. 更新依赖库
|
|
||||||
|
3. 更新依赖库
|
||||||
|
|
||||||
```
|
```
|
||||||
$ composer install
|
$ composer install
|
||||||
```
|
```
|
||||||
4. 如果使用 systemd 等,需要重启服务
|
|
||||||
|
4. 如果使用 systemd 等,需要重启服务
|
||||||
|
|
||||||
```
|
```
|
||||||
$ systemctl restart bilibili
|
$ systemctl restart bilibili
|
||||||
```
|
```
|
||||||
@ -178,10 +195,11 @@ $ systemctl restart bilibili
|
|||||||
如果你将 BiliHelper-personal 部署到线上服务器时,则需要配置一个进程监控器来监测 `php index.php` 命令,在它意外退出时自动重启。
|
如果你将 BiliHelper-personal 部署到线上服务器时,则需要配置一个进程监控器来监测 `php index.php` 命令,在它意外退出时自动重启。
|
||||||
|
|
||||||
通常可以使用以下的方式
|
通常可以使用以下的方式
|
||||||
- systemd (推荐)
|
|
||||||
- Supervisor
|
- systemd (推荐)
|
||||||
- screen (自用)
|
- Supervisor
|
||||||
- nohup
|
- screen (自用)
|
||||||
|
- nohup
|
||||||
|
|
||||||
## systemd 脚本
|
## systemd 脚本
|
||||||
|
|
||||||
@ -189,7 +207,7 @@ $ systemctl restart bilibili
|
|||||||
# /usr/lib/systemd/system/bilibili.service
|
# /usr/lib/systemd/system/bilibili.service
|
||||||
|
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Bili Helper Manager
|
Description=BiliHelper Manager
|
||||||
Documentation=https://github.com/lkeme/BiliHelper-personal
|
Documentation=https://github.com/lkeme/BiliHelper-personal
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
@ -223,6 +241,7 @@ stdout_logfile=/tmp/bilibili.log
|
|||||||
|TelegramBot|https://core.telegram.org/bots/api|
|
|TelegramBot|https://core.telegram.org/bots/api|
|
||||||
|
|
||||||
示范如下
|
示范如下
|
||||||
|
|
||||||
```
|
```
|
||||||
# Server酱
|
# Server酱
|
||||||
# 自行替换 <SCKEY>
|
# 自行替换 <SCKEY>
|
||||||
@ -235,10 +254,9 @@ APP_CALLBACK="https://api.telegram.org/bot<TOKEN>/sendMessage?chat_id=<CHAR_ID>&
|
|||||||
|
|
||||||
`{message}` 部分会自动替换成错误信息,接口采用 get 方式发送
|
`{message}` 部分会自动替换成错误信息,接口采用 get 方式发送
|
||||||
|
|
||||||
|
|
||||||
## 直播间 ID 问题
|
## 直播间 ID 问题
|
||||||
|
|
||||||
文件 `user.conf` 里
|
文件 `user.ini` 里
|
||||||
|
|
||||||
`ROOM_ID` 配置,填写此项可以清空临过期礼物给指定直播间。
|
`ROOM_ID` 配置,填写此项可以清空临过期礼物给指定直播间。
|
||||||
|
|
||||||
@ -249,11 +267,13 @@ APP_CALLBACK="https://api.telegram.org/bot<TOKEN>/sendMessage?chat_id=<CHAR_ID>&
|
|||||||
`SOCKET_ROOM_ID` 配置,监控使用,暂时没用到。
|
`SOCKET_ROOM_ID` 配置,监控使用,暂时没用到。
|
||||||
|
|
||||||
通常可以在直播间页面的 url 获取到它
|
通常可以在直播间页面的 url 获取到它
|
||||||
|
|
||||||
```
|
```
|
||||||
http://live.bilibili.com/9522051
|
http://live.bilibili.com/9522051
|
||||||
```
|
```
|
||||||
|
|
||||||
长位直播间ID获取
|
长位直播间ID获取
|
||||||
|
|
||||||
```
|
```
|
||||||
https://api.live.bilibili.com/room/v1/Room/room_init?id=3
|
https://api.live.bilibili.com/room/v1/Room/room_init?id=3
|
||||||
```
|
```
|
||||||
@ -261,24 +281,3 @@ https://api.live.bilibili.com/room/v1/Room/room_init?id=3
|
|||||||
所有直播间号码小于 1000 的直播间为短号,部分4位直播间也为短号,
|
所有直播间号码小于 1000 的直播间为短号,部分4位直播间也为短号,
|
||||||
|
|
||||||
该脚本在每次启动会自动修正部分功能,特殊标注的请留意。
|
该脚本在每次启动会自动修正部分功能,特殊标注的请留意。
|
||||||
|
|
||||||
## 相关
|
|
||||||
|
|
||||||
> [BilibiliHelper](https://github.com/metowolf/BilibiliHelper)
|
|
||||||
|
|
||||||
> [BiliHelper](https://github.com/lkeme/BiliHelper)
|
|
||||||
|
|
||||||
> [Github](https://github.com/)
|
|
||||||
|
|
||||||
|
|
||||||
## License 许可证
|
|
||||||
|
|
||||||
BiliHelper is under the MIT license.
|
|
||||||
|
|
||||||
本项目基于 MIT 协议发布,并增加了 SATA 协议。
|
|
||||||
|
|
||||||
当你使用了使用 SATA 的开源软件或文档的时候,在遵守基础许可证的前提下,你必须马不停蹄地给你所使用的开源项目 “点赞” ,比如在 GitHub 上 star,然后你必须感谢这个帮助了你的开源项目的作者,作者信息可以在许可证头部的版权声明部分找到。
|
|
||||||
|
|
||||||
本项目的所有代码文件、配置项,除另有说明外,均基于上述介绍的协议发布,具体请看分支下的 LICENSE。
|
|
||||||
|
|
||||||
此处的文字仅用于说明,条款以 LICENSE 文件中的内容为准。
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ MAINTAINER zsnmwy <szlszl35622@gmail.com>
|
|||||||
|
|
||||||
ENV USER_NAME='' \
|
ENV USER_NAME='' \
|
||||||
USER_PASSWORD='' \
|
USER_PASSWORD='' \
|
||||||
CONIFG_PATH='/app/conf/user.conf' \
|
CONIFG_PATH='/app/conf/user.ini' \
|
||||||
Green="\\033[32m" \
|
Green="\\033[32m" \
|
||||||
Red="\\033[31m" \
|
Red="\\033[31m" \
|
||||||
GreenBG="\\033[42;37m" \
|
GreenBG="\\033[42;37m" \
|
||||||
@ -35,4 +35,4 @@ ENTRYPOINT echo -e "\n ======== \n ${Info} ${GreenBG} 正使用 git pull 同步
|
|||||||
echo -e "\n ======== \n ${Info} ${GreenBG} 安装/更新 项目运行依赖 ${Font} \n ======== \n" && \
|
echo -e "\n ======== \n ${Info} ${GreenBG} 安装/更新 项目运行依赖 ${Font} \n ======== \n" && \
|
||||||
php composer.phar install && \
|
php composer.phar install && \
|
||||||
echo -e "\n \n \n \n" && \
|
echo -e "\n \n \n \n" && \
|
||||||
if [[ -f ${CONIFG_PATH} ]]; then echo -e "\n ======== \n ${GreenBG} 正在使用外部配置文件 ${Font} \n ======== \n" && php index.php ; else echo -e "${OK} ${GreenBG} 正在使用传入的环境变量进行用户配置。\n 如果需要配置更多选择项,请通过挂载配置文件来传入。具体参考项目中的README。\n https://github.com/lkeme/BiliHelper-personal.git ${Font} \n ======== \n " && cp /app/conf/user.conf.example /app/conf/user.conf && sed -i ''"$(cat /app/conf/user.conf -n | grep "APP_USER=" | awk '{print $1}')"'c '"$(echo "APP_USER=${USER_NAME}")"'' ${CONIFG_PATH} && sed -i ''"$(cat /app/conf/user.conf -n | grep "APP_PASS=" | awk '{print $1}')"'c '"$(echo "APP_PASS=${USER_PASSWORD}")"'' ${CONIFG_PATH} && php index.php; fi
|
if [[ -f ${CONIFG_PATH} ]]; then echo -e "\n ======== \n ${GreenBG} 正在使用外部配置文件 ${Font} \n ======== \n" && php index.php ; else echo -e "${OK} ${GreenBG} 正在使用传入的环境变量进行用户配置。\n 如果需要配置更多选择项,请通过挂载配置文件来传入。具体参考项目中的README。\n https://github.com/lkeme/BiliHelper-personal.git ${Font} \n ======== \n " && cp /app/conf/user.ini.example /app/conf/user.ini && sed -i ''"$(cat /app/conf/user.ini -n | grep "APP_USER=" | awk '{print $1}')"'c '"$(echo "APP_USER=${USER_NAME}")"'' ${CONIFG_PATH} && sed -i ''"$(cat /app/conf/user.ini -n | grep "APP_PASS=" | awk '{print $1}')"'c '"$(echo "APP_PASS=${USER_PASSWORD}")"'' ${CONIFG_PATH} && php index.php; fi
|
||||||
|
|||||||
102
README.md
102
README.md
@ -1,31 +1,113 @@
|
|||||||
# BiliHelper
|
<p align="center"><img width="300px" src="https://i.loli.net/2018/04/20/5ad97bd395912.jpeg"></p>
|
||||||
B 站直播实用脚本
|
|
||||||
|
|
||||||
## 交流
|
<div align="center">
|
||||||
|
|
||||||
Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg) | **仅用于BUG提交反馈**
|
[](https://github.com/lkeme/ )
|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
## 公告
|
</div>
|
||||||
|
|
||||||
> Personal Edition **0.8.1.210423 alpha**
|
<p align="center">
|
||||||
|
|
||||||
|
<img src="https://img.shields.io/badge/Version-0.9.0.210517-orange.svg?longCache=true&style=for-the-badge">
|
||||||
|
<img src="https://img.shields.io/badge/PHP-7.3+-green.svg?longCache=true&style=for-the-badge">
|
||||||
|
<img src="https://img.shields.io/badge/Composer-latest-blueviolet.svg?longCache=true&style=for-the-badge">
|
||||||
|
<img src="https://img.shields.io/badge/License-mit-blue.svg?longCache=true&style=for-the-badge">
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## 公告通知
|
||||||
|
|
||||||
```notice
|
```notice
|
||||||
---- 免费的东西总是得不到人的珍惜。
|
---- 免费的东西总是得不到人的珍惜。
|
||||||
---- 只有花大价钱去买到的东西,才会令人信任。
|
---- 只有花大价钱去买到的东西,才会令人信任。
|
||||||
```
|
```
|
||||||
|
|
||||||
## 文档
|
## 功能组件
|
||||||
> 有疑问一定要先看看文档或Issue里是否存在相同的问题,再考虑其他渠道咨询。
|
|
||||||
|
> 以下任务都是按设定周期自动执行,`true`为正常使用,`false`为暂停使用或抛弃。
|
||||||
|
|
||||||
|
| plugin | status | version | description |
|
||||||
|
|-----------------|--------|----------|---------------------------------------------|
|
||||||
|
| CheckUpdate | true | 21.05.17 | 程序检查更新 |
|
||||||
|
| Login | true | 21.05.17 | 账号登录、刷新、维持 |
|
||||||
|
| Schedule | true | 21.05.17 | 控制插件运行周期 |
|
||||||
|
| MainSite | true | 21.05.17 | 投币、观看、分享视频 (速升6级不是梦) |
|
||||||
|
| DailyBag | true | 21.05.17 | 双端领取日常/周常礼包 |
|
||||||
|
| ManGa | true | 21.05.17 | 漫画签到、分享 |
|
||||||
|
| ActivityLottery | true | 21.05.17 | 主站活动九宫格抽奖 |
|
||||||
|
| Competition | true | 21.05.17 | 游戏赛事竞猜 |
|
||||||
|
| DoubleHeart | true | 21.05.17 | 双端心跳 (姥爷直播经验) |
|
||||||
|
| DailyTask | true | 21.05.17 | 直播每日任务(签到、观看) |
|
||||||
|
| Barrage | true | 21.05.17 | 保持活跃弹幕 |
|
||||||
|
| Silver2Coin | true | 21.05.17 | 银瓜子兑换硬币 |
|
||||||
|
| Judge | true | 21.05.17 | 风纪委员投票 |
|
||||||
|
| GiftSend | true | 21.05.17 | 礼物赠送、维持每日勋章亲密度 |
|
||||||
|
| GroupSignIn | true | 21.05.17 | 友爱社签到 |
|
||||||
|
| GiftHeart | true | 21.05.17 | 日常心跳每日礼包礼物 |
|
||||||
|
| SmallHeart | true | 21.05.17 | 直播挂机,每日24个小心心 |
|
||||||
|
| MaterialObject | true | 21.05.17 | 直播金色宝箱实物抽奖 |
|
||||||
|
| AloneTcpClient | true | 21.05.17 | 作者的独立直播监控 |
|
||||||
|
| ZoneTcpClient | true | 21.05.17 | 官方的分区直播监控 |
|
||||||
|
| StormRaffle | true | 21.05.17 | 直播节奏风暴抽奖、亿元 |
|
||||||
|
| GiftRaffle | true | 21.05.17 | 直播礼物抽奖 |
|
||||||
|
| PkRaffle | true | 21.05.17 | 直播大乱斗抽奖 |
|
||||||
|
| GuardRaffle | true | 21.05.17 | 直播大航海抽奖 |
|
||||||
|
| AnchorRaffle | true | 21.05.17 | 直播天选时刻抽奖 |
|
||||||
|
| GiftRaffle | true | 21.05.17 | 直播礼物抽奖 |
|
||||||
|
| AwardRecord | true | 21.05.17 | 最新的中奖纪录通知 |
|
||||||
|
| Forward | true | 21.05.17 | 主站动态抽奖转发 |
|
||||||
|
| CapsuleLottery | true | 21.05.17 | 直播扭蛋活动抽奖 |
|
||||||
|
| PolishTheMedal | true | 21.05.17 | 每日自动点亮灰色勋章 |
|
||||||
|
| CapsuleLottery | true | 21.05.17 | 直播扭蛋活动抽奖 |
|
||||||
|
| VipPrivilege | true | 21.05.17 | 每月领取年度大会员特权(B币券、会员购优惠券) |
|
||||||
|
| BpConsumption | true | 21.05.17 | 每月消费使用年度大会员特权的B币券 |
|
||||||
|
| Statistics | true | 21.05.17 | 全局抽奖结果统计 |
|
||||||
|
| Silver | false | 21.03.27 | 直播银瓜子自动开启宝箱 |
|
||||||
|
|
||||||
|
## 交流反馈
|
||||||
|
|
||||||
|
> Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg) | **请不要来问如何使用, 文档齐全, 仅用于BUG提交反馈**
|
||||||
|
|
||||||
|
## 相关文档
|
||||||
|
|
||||||
|
> 有疑问一定要先看看文档或Issue里是否存在相同的问题,再考虑其他渠道咨询。
|
||||||
|
|
||||||
* [使用文档 / DOC.md](./DOC.md)
|
* [使用文档 / DOC.md](./DOC.md)
|
||||||
* [更新日志 / CHANGELOG.md](./CHANGELOG.md)
|
* [更新日志 / CHANGELOG.md](./CHANGELOG.md)
|
||||||
* [配置文档 / WIKI.md](https://github.com/lkeme/BiliHelper-personal/wiki/%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%A6%E8%A7%A3)
|
* [配置文档 / WIKI.md](https://github.com/lkeme/BiliHelper-personal/wiki/%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%A6%E8%A7%A3)
|
||||||
* [常见问题 / WIKI.md](https://github.com/lkeme/BiliHelper-personal/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)
|
* [常见问题 / WIKI.md](https://github.com/lkeme/BiliHelper-personal/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)
|
||||||
|
|
||||||
## 打赏
|
## 打赏支持
|
||||||
|
|
||||||
|
> 如果觉得本项目好用,对你有所帮助,欢迎打赏支持。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 效果
|
## 运行效果
|
||||||
|
|
||||||
|
> 不代表当前版本,以当前最新版本运行结果为准
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## 项目相关
|
||||||
|
|
||||||
|
* [BilibiliHelper](https://github.com/metowolf/BilibiliHelper)
|
||||||
|
* [BiliHelper](https://github.com/lkeme/BiliHelper)
|
||||||
|
* [Github](https://github.com/)
|
||||||
|
|
||||||
|
## License 许可证
|
||||||
|
|
||||||
|
BiliHelper is under the MIT license.
|
||||||
|
|
||||||
|
本项目基于 MIT 协议发布,并增加了 SATA 协议。
|
||||||
|
|
||||||
|
当你使用了使用 SATA 的开源软件或文档的时候,在遵守基础许可证的前提下,你必须马不停蹄地给你所使用的开源项目 “点赞” ,比如在 GitHub 上
|
||||||
|
star,然后你必须感谢这个帮助了你的开源项目的作者,作者信息可以在许可证头部的版权声明部分找到。
|
||||||
|
|
||||||
|
本项目的所有代码文件、配置项,除另有说明外,均基于上述介绍的协议发布,具体请看分支下的 LICENSE。
|
||||||
|
|
||||||
|
此处的文字仅用于说明,条款以 LICENSE 文件中的内容为准。
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
"description": "B 站自动领瓜子、直播助手、直播挂机脚本、主站助手 - PHP 版(Personal)",
|
"description": "B 站自动领瓜子、直播助手、直播挂机脚本、主站助手 - PHP 版(Personal)",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.0.0",
|
"php": ">=7.3.0",
|
||||||
"ext-curl": "*",
|
"ext-curl": "*",
|
||||||
"ext-openssl": "*",
|
"ext-openssl": "*",
|
||||||
"ext-sockets": "*",
|
"ext-sockets": "*",
|
||||||
@ -19,7 +19,8 @@
|
|||||||
"mathieuviossat/arraytotexttable": "^1.0.8",
|
"mathieuviossat/arraytotexttable": "^1.0.8",
|
||||||
"klkvsk/json-decode-stream": "^1.0",
|
"klkvsk/json-decode-stream": "^1.0",
|
||||||
"sven/file-config": "^3.1",
|
"sven/file-config": "^3.1",
|
||||||
"hassankhan/config": "^2.2"
|
"hassankhan/config": "^2.2",
|
||||||
|
"lkeme/inifile": "^3.4"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
@ -36,6 +37,9 @@
|
|||||||
"BiliHelper\\Util\\": "src/util",
|
"BiliHelper\\Util\\": "src/util",
|
||||||
"BiliHelper\\Tool\\": "src/tool",
|
"BiliHelper\\Tool\\": "src/tool",
|
||||||
"BiliHelper\\Backup\\": "src/backup"
|
"BiliHelper\\Backup\\": "src/backup"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"src/core/Helpers.php"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
68
composer.lock
generated
68
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "7b0e5cfde9ebb70a16c941f59fd2a71d",
|
"content-hash": "e70802004e3c9d66674b79cba60e91ad",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "amphp/amp",
|
"name": "amphp/amp",
|
||||||
@ -958,6 +958,70 @@
|
|||||||
],
|
],
|
||||||
"time": "2021-02-25T21:54:58+00:00"
|
"time": "2021-02-25T21:54:58+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "lkeme/inifile",
|
||||||
|
"version": "v3.4.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/lkeme/inifile.git",
|
||||||
|
"reference": "bebdcced93b92ad929f6b05cb7cc305d72169a37"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/lkeme/inifile/zipball/bebdcced93b92ad929f6b05cb7cc305d72169a37",
|
||||||
|
"reference": "bebdcced93b92ad929f6b05cb7cc305d72169a37",
|
||||||
|
"shasum": "",
|
||||||
|
"mirrors": [
|
||||||
|
{
|
||||||
|
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||||
|
"preferred": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.0.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "4.8.*"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Jelix\\IniFile\\": "lib/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"LGPL-2.1"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Laurent Jouanneau",
|
||||||
|
"email": "laurent@jelix.org"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Loic Mathaud"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Riccardo Mazzei",
|
||||||
|
"email": "riccardo.mazzei@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Lkeme",
|
||||||
|
"email": "Useri@live.cn"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "classes to read and modify ini files by preserving comments and empty lines",
|
||||||
|
"homepage": "https://github.com/lkeme/inifile",
|
||||||
|
"keywords": [
|
||||||
|
"files",
|
||||||
|
"ini"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/lkeme/inifile/tree/v3.4.0"
|
||||||
|
},
|
||||||
|
"time": "2021-05-13T10:44:17+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "mathieuviossat/arraytotexttable",
|
"name": "mathieuviossat/arraytotexttable",
|
||||||
"version": "v1.0.8",
|
"version": "v1.0.8",
|
||||||
@ -1904,7 +1968,7 @@
|
|||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": ">=7.0.0",
|
"php": ">=7.3.0",
|
||||||
"ext-curl": "*",
|
"ext-curl": "*",
|
||||||
"ext-openssl": "*",
|
"ext-openssl": "*",
|
||||||
"ext-sockets": "*",
|
"ext-sockets": "*",
|
||||||
|
|||||||
@ -14,7 +14,7 @@ class ConfigGenerator
|
|||||||
public $filename;
|
public $filename;
|
||||||
public $template;
|
public $template;
|
||||||
private $options = ['APP_USER', 'APP_PASS'];
|
private $options = ['APP_USER', 'APP_PASS'];
|
||||||
private $default_filename = 'user.conf.example';
|
private $default_filename = 'user.ini.example';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ConfigGenerator constructor.
|
* ConfigGenerator constructor.
|
||||||
@ -64,8 +64,8 @@ class ConfigGenerator
|
|||||||
$value = $this->cliInput("请输入{$option}: ");
|
$value = $this->cliInput("请输入{$option}: ");
|
||||||
$this->template = $this->envReplace($option, $value, $this->template);
|
$this->template = $this->envReplace($option, $value, $this->template);
|
||||||
}
|
}
|
||||||
file_put_contents(__DIR__ . "\\$this->filename.conf", $this->template);
|
file_put_contents(__DIR__ . "\\$this->filename.ini", $this->template);
|
||||||
echo "生成配置文件 $this->filename.conf 成功~";
|
echo "生成配置文件 $this->filename.ini 成功~";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,196 +0,0 @@
|
|||||||
#######################
|
|
||||||
# 账户设置 #
|
|
||||||
#######################
|
|
||||||
|
|
||||||
# 帐号|密码
|
|
||||||
APP_USER=
|
|
||||||
APP_PASS=
|
|
||||||
|
|
||||||
# 登录模式|[1.账密模式 2.短信验证码模式 3.行为验证码模式(暂未开放)]
|
|
||||||
LOGIN_MODE=1
|
|
||||||
|
|
||||||
# 令牌(自动生成)
|
|
||||||
ACCESS_TOKEN=
|
|
||||||
REFRESH_TOKEN=
|
|
||||||
COOKIE=
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 功能设置 #
|
|
||||||
#######################
|
|
||||||
|
|
||||||
# 主站每日任务(每日登录、观看、投币、分享)
|
|
||||||
USE_MAIN_SITE=true
|
|
||||||
|
|
||||||
# 直播大乱斗
|
|
||||||
USE_PK=true
|
|
||||||
|
|
||||||
# 直播箱子实物抽奖
|
|
||||||
USE_LIVE_BOX=true
|
|
||||||
|
|
||||||
# 每日24个小心心|依赖加密心跳服务器
|
|
||||||
USE_HEARTBEAT=true
|
|
||||||
|
|
||||||
# 直播扭蛋活动抽奖|依赖加密心跳服务器
|
|
||||||
USE_CAPSULE=true
|
|
||||||
|
|
||||||
# 主站九宫格抽奖活动助手
|
|
||||||
USE_ACTIVITY=true
|
|
||||||
|
|
||||||
# 银瓜子兑换硬币
|
|
||||||
USE_SILVER2COIN=true
|
|
||||||
|
|
||||||
# 风纪委员
|
|
||||||
USE_JUDGE=false
|
|
||||||
|
|
||||||
# 直播统一活动
|
|
||||||
USE_ACTIVE=false
|
|
||||||
|
|
||||||
# 直播舰长总督
|
|
||||||
USE_GUARD=false
|
|
||||||
|
|
||||||
# 漫画助手
|
|
||||||
USE_MANGA=false
|
|
||||||
|
|
||||||
# 赛事助手
|
|
||||||
USE_MATCH=false
|
|
||||||
|
|
||||||
# 节奏风暴|丢弃率(0-100)|尝试数(范围值)
|
|
||||||
USE_STORM=false
|
|
||||||
STORM_DROPRATE=0
|
|
||||||
STORM_ATTEMPT=10,20
|
|
||||||
|
|
||||||
# 破产机|每日竞猜次数|每次竞猜硬币(1-10)|下注(1.压大,2.压小,3.随机)
|
|
||||||
USE_COMPETITION=false
|
|
||||||
COMPET_MAX_NUM=20
|
|
||||||
COMPET_MAX_COIN=10
|
|
||||||
COMPET_STAKE=1
|
|
||||||
|
|
||||||
# 天选时刻|抽取类型(0: 无限制; 1: 关注主播; 2: 粉丝勋章; 3大航海; 4用户等级;5主站等级)|自动取关(测试功能)|过滤关键词|逗号分隔
|
|
||||||
USE_ANCHOR=false
|
|
||||||
ANCHOR_UNFOLLOW=false
|
|
||||||
ANCHOR_TYPE=0,1
|
|
||||||
ANCHOR_FILTER_WORDS=
|
|
||||||
|
|
||||||
# 活跃弹幕|弹幕房间(为空则随机)|弹幕内容(为空则随机)
|
|
||||||
USE_DANMU=true
|
|
||||||
DANMU_ROOMID=9522051
|
|
||||||
DANMU_CONTENT=
|
|
||||||
|
|
||||||
# 视频投币|random(随机热门)/fixed(关注列表)|投币稿件数(每日任务最大5)
|
|
||||||
USE_ADD_COIN=false
|
|
||||||
ADD_COIN_MODE=random
|
|
||||||
ADD_COIN_NUM=5
|
|
||||||
|
|
||||||
# 自动转发抽奖动态
|
|
||||||
AUTO_DYNAMIC = false
|
|
||||||
# 自动取关未中奖动态
|
|
||||||
CLEAR_DYNAMIC = false
|
|
||||||
# 强制清除抽奖组关注
|
|
||||||
CLEAR_GROUP_FOLLOW = false
|
|
||||||
# 更改自动回复语言
|
|
||||||
AUTO_REPLY_TEXT = 从未中奖,从未放弃[doge]
|
|
||||||
|
|
||||||
# 休眠时间|时间区间(0-23)|逗号分隔
|
|
||||||
USE_SLEEP=true
|
|
||||||
SLEEP_SECTION=2,3,4,5,6
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 通知设置 #
|
|
||||||
#######################
|
|
||||||
|
|
||||||
# 消息推送|消息推送过滤词|逗号分割|优先级从上到下
|
|
||||||
USE_NOTIFY=false
|
|
||||||
NOTIFY_FILTER_WORDS=
|
|
||||||
## Dingtalk机器人|token|依赖USE_NOTIFY
|
|
||||||
NOTIFY_DINGTALK_TOKEN=
|
|
||||||
## Tele机器人|token|chatid|依赖USE_NOTIFY
|
|
||||||
NOTIFY_TELE_BOTTOKEN=
|
|
||||||
NOTIFY_TELE_CHATID=
|
|
||||||
## Pushplus酱|token|依赖USE_NOTIFY
|
|
||||||
NOTIFY_PUSHPLUS_TOKEN=
|
|
||||||
## Sever酱(原版)|令牌Key|依赖USE_NOTIFY
|
|
||||||
NOTIFY_SCKEY=
|
|
||||||
## Server酱(Turbo版)|令牌Key|依赖USE_NOTIFY
|
|
||||||
NOTIFY_SCTKEY=
|
|
||||||
## GoCqhttp|url|token|qq|依赖USE_NOTIFY
|
|
||||||
NOTIFY_CQ_URL=
|
|
||||||
NOTIFY_CQ_TOKEN=
|
|
||||||
NOTIFY_CQ_QQ=
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 基础设置 #
|
|
||||||
#######################
|
|
||||||
|
|
||||||
# 独立推送服务(主)|主备冲突
|
|
||||||
USE_ALONE_SERVER=false
|
|
||||||
ALONE_SERVER_ADDR=tcp://livecmt-1.mudew.com:10088
|
|
||||||
ALONE_SERVER_KEY=
|
|
||||||
|
|
||||||
# 分区推送服务(备)|主备冲突
|
|
||||||
USE_ZONE_SERVER=true
|
|
||||||
ZONE_SERVER_ADDR=tcp://broadcastlv.chat.bilibili.com:2243/sub
|
|
||||||
|
|
||||||
# 加密心跳服务器(开源)|如失效自行搭建
|
|
||||||
ENC_SERVER=http://heartbeat-1.mudew.com:3000/enc
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 房间设置 #
|
|
||||||
#######################
|
|
||||||
|
|
||||||
# 直播间ID,用于礼物赠送
|
|
||||||
ROOM_ID=9522051
|
|
||||||
|
|
||||||
# 勋章亲密度,测试功能,有短位使用短位反之长位,左侧优先,仅支持辣条和亿元
|
|
||||||
# 当列表中所有ID都已达到每日上限,剩余礼物赠送ROOM_ID指定的直播间
|
|
||||||
# 是否填满(按时间投喂正常礼物,否则过期礼物)|直播间ID列表|逗号分隔|
|
|
||||||
FEED_FILL=false
|
|
||||||
ROOM_LIST=9522051
|
|
||||||
|
|
||||||
# 弹幕监控房间(为空则随机)
|
|
||||||
SOCKET_ROOM_ID=9522051
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 网络设置 #
|
|
||||||
#######################
|
|
||||||
|
|
||||||
# 验证SSL证书|请求时验证SSL证书行为
|
|
||||||
VERIFY_SSL=true
|
|
||||||
|
|
||||||
# 是否使用代理|(http\https)
|
|
||||||
USE_PROXY=false
|
|
||||||
NETWORK_PROXY=http://127.0.0.1:8888
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# 程序设置 #
|
|
||||||
#######################
|
|
||||||
|
|
||||||
# 写入日志
|
|
||||||
APP_WRITE_LOG=false
|
|
||||||
|
|
||||||
# 日志路径
|
|
||||||
APP_LOG_PATH=log
|
|
||||||
|
|
||||||
# 调试模式
|
|
||||||
APP_DEBUG=false
|
|
||||||
|
|
||||||
# 用户名,可自定义
|
|
||||||
APP_UNAME=
|
|
||||||
|
|
||||||
# 多账号区别输出
|
|
||||||
APP_MULTIPLE=false
|
|
||||||
|
|
||||||
# 账号别名,如果为空则默认使用登录账号作为标示
|
|
||||||
APP_USER_IDENTITY=
|
|
||||||
|
|
||||||
# 日志回调地址
|
|
||||||
APP_CALLBACK="http://www.example.com/api.send?text={account}[{level}]: {message}"
|
|
||||||
|
|
||||||
# 错误回调级别
|
|
||||||
#
|
|
||||||
# DEBUG 100
|
|
||||||
# INFO 200
|
|
||||||
# NOTICE 250
|
|
||||||
# WARNING 300
|
|
||||||
# ERROR 400
|
|
||||||
#
|
|
||||||
APP_CALLBACK_LEVEL=400
|
|
||||||
279
conf/user.ini.example
Normal file
279
conf/user.ini.example
Normal file
@ -0,0 +1,279 @@
|
|||||||
|
#######################
|
||||||
|
# 账户设置 #
|
||||||
|
#######################
|
||||||
|
|
||||||
|
[login.account]
|
||||||
|
; 帐号|密码
|
||||||
|
username = ""
|
||||||
|
password = ""
|
||||||
|
|
||||||
|
; 登录模式|[1.账密模式 2.短信验证码模式 3.行为验证码模式(暂未开放)]
|
||||||
|
[login.mode]
|
||||||
|
mode = 1
|
||||||
|
|
||||||
|
; UID|CSRF|令牌|(当前区域自动生成)
|
||||||
|
[login.auth]
|
||||||
|
uid =
|
||||||
|
csrf =
|
||||||
|
cookie =
|
||||||
|
access_token =
|
||||||
|
refresh_token =
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# 功能设置 #
|
||||||
|
#######################
|
||||||
|
|
||||||
|
; 主站每日任务(每日登录、观看、投币、分享)
|
||||||
|
[main_site]
|
||||||
|
enable = true
|
||||||
|
; 每日观看
|
||||||
|
watch = true
|
||||||
|
; 每日分享
|
||||||
|
share = true
|
||||||
|
; 每日视频投币|random(随机热门)/fixed(关注列表)|投币稿件数(每日任务最大5)
|
||||||
|
add_coin = true
|
||||||
|
add_coin_mode = random
|
||||||
|
add_coin_num = 5
|
||||||
|
|
||||||
|
; 日常/周常礼物
|
||||||
|
[daily_bag]
|
||||||
|
enable = true
|
||||||
|
|
||||||
|
; 双端心跳
|
||||||
|
[double_heart]
|
||||||
|
enable = true
|
||||||
|
|
||||||
|
; 友爱社签到
|
||||||
|
[love_club]
|
||||||
|
enable = true
|
||||||
|
|
||||||
|
; 领取心跳礼物
|
||||||
|
[gift_heart]
|
||||||
|
enable = true
|
||||||
|
|
||||||
|
; 直播每日任务|每日签到|每日登录
|
||||||
|
[daily_task]
|
||||||
|
enable = true
|
||||||
|
|
||||||
|
; 直播箱子实物抽奖
|
||||||
|
[live_box]
|
||||||
|
enable = true
|
||||||
|
|
||||||
|
; 每日24个小心心|依赖加密心跳服务器
|
||||||
|
[small_heart]
|
||||||
|
enable = true
|
||||||
|
|
||||||
|
; 直播扭蛋活动抽奖|依赖加密心跳服务器
|
||||||
|
[live_capsule]
|
||||||
|
enable = true
|
||||||
|
|
||||||
|
; 点亮灰色勋章
|
||||||
|
[polish_the_medal]
|
||||||
|
enable = true
|
||||||
|
|
||||||
|
; 主站九宫格抽奖活动助手
|
||||||
|
[main_activity]
|
||||||
|
enable = true
|
||||||
|
|
||||||
|
; 银瓜子兑换硬币
|
||||||
|
[silver2coin]
|
||||||
|
enable = true
|
||||||
|
|
||||||
|
; 直播大乱斗
|
||||||
|
[live_pk]
|
||||||
|
enable = false
|
||||||
|
|
||||||
|
; 直播舰长总督
|
||||||
|
[live_guard]
|
||||||
|
enable = false
|
||||||
|
|
||||||
|
; 直播其他礼物
|
||||||
|
[live_gift]
|
||||||
|
enable = false
|
||||||
|
|
||||||
|
; 直播节奏风暴|丢弃率(0-100)|尝试次数(范围值)
|
||||||
|
[live_storm]
|
||||||
|
enable = false
|
||||||
|
drop_rate = 0
|
||||||
|
attempt = "10,20"
|
||||||
|
|
||||||
|
; 直播天选时刻|抽取类型(0: 无限制; 1: 关注主播; 2: 粉丝勋章; 3大航海; 4用户等级;5主站等级)|自动取关(测试功能)|过滤关键词|逗号分隔
|
||||||
|
[live_anchor]
|
||||||
|
enable = false
|
||||||
|
limit_type = "0,1"
|
||||||
|
auto_unfollow = true
|
||||||
|
filter_words =
|
||||||
|
|
||||||
|
; 获取最新的中奖纪录
|
||||||
|
[award_record]
|
||||||
|
enable = true
|
||||||
|
|
||||||
|
; 活跃弹幕|弹幕房间(为空则随机)|弹幕内容(为空则随机)
|
||||||
|
[barrage]
|
||||||
|
enable = true
|
||||||
|
room_id = 9522051
|
||||||
|
content =
|
||||||
|
|
||||||
|
; 漫画助手
|
||||||
|
[manga]
|
||||||
|
enable = false
|
||||||
|
|
||||||
|
; 风纪委员投票|需要实名认证
|
||||||
|
[judgement]
|
||||||
|
enable = false
|
||||||
|
|
||||||
|
; 大会员权益|年度大会员专享
|
||||||
|
[vip_privilege]
|
||||||
|
enable = false
|
||||||
|
|
||||||
|
; B币券消费|年度大会员专享|每月默认充值数量5B币|消费方式优先级从上到下
|
||||||
|
[bp_consumption]
|
||||||
|
enable = false
|
||||||
|
# 消费B币充电|充电的目标UID|可充值自己的UID
|
||||||
|
bp2charge = false
|
||||||
|
bp2charge_uid = 6580464
|
||||||
|
# 消费B币充值金瓜子|5000金瓜子
|
||||||
|
bp2gold = false
|
||||||
|
|
||||||
|
; 自动转发抽奖动态|自动取关未中奖动态|强制清除抽奖组关注|更改自动回复语言
|
||||||
|
[dynamic]
|
||||||
|
enable = false
|
||||||
|
clear_dynamic = false
|
||||||
|
clear_group_follow = false
|
||||||
|
auto_reply_text = "从未中奖,从未放弃[doge]"
|
||||||
|
|
||||||
|
; 游戏赛事竞猜预测|破产机|每日竞猜次数|每次竞猜硬币(1-10)|下注(1.压大,2.压小,3.随机)
|
||||||
|
[match_forecast]
|
||||||
|
enable = false
|
||||||
|
max_num = 20
|
||||||
|
max_coin = 10
|
||||||
|
bet = 1
|
||||||
|
|
||||||
|
; 休眠时间|时间区间(0-23)|逗号分隔
|
||||||
|
[sleep]
|
||||||
|
enable = true
|
||||||
|
section = "2,3,4,5,6"
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# 通知设置 #
|
||||||
|
#######################
|
||||||
|
|
||||||
|
; 消息推送|消息推送过滤词|逗号分割|优先级从上到下
|
||||||
|
[notify]
|
||||||
|
enable = false
|
||||||
|
filter_words =
|
||||||
|
|
||||||
|
; Dingtalk机器人|token|依赖USE_NOTIFY
|
||||||
|
[notify.dingtalk]
|
||||||
|
token =
|
||||||
|
|
||||||
|
; Tele机器人|token|chatid|依赖USE_NOTIFY
|
||||||
|
[notify.telegram]
|
||||||
|
bottoken =
|
||||||
|
chatid =
|
||||||
|
|
||||||
|
; Pushplus酱|token|依赖USE_NOTIFY
|
||||||
|
[notify.pushplus]
|
||||||
|
token =
|
||||||
|
|
||||||
|
; Sever酱(原版)|令牌Key|依赖USE_NOTIFY
|
||||||
|
[notify.sc]
|
||||||
|
sckey =
|
||||||
|
|
||||||
|
; Server酱(Turbo版)|令牌Key|依赖USE_NOTIFY
|
||||||
|
[notify.sct]
|
||||||
|
sctkey =
|
||||||
|
|
||||||
|
; GoCqhttp|url|token|目标qq|依赖USE_NOTIFY
|
||||||
|
[notify.gocqhttp]
|
||||||
|
url = ""
|
||||||
|
token =
|
||||||
|
target_qq =
|
||||||
|
|
||||||
|
; Debug|个人调试推送|url|token|
|
||||||
|
[notify.debug]
|
||||||
|
url = ""
|
||||||
|
token =
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# 基础设置 #
|
||||||
|
#######################
|
||||||
|
|
||||||
|
; 独立推送服务(主)|主备冲突
|
||||||
|
[alone_monitor]
|
||||||
|
enable = false
|
||||||
|
server_addr = "tcp://livecmt-1.mudew.com:10088"
|
||||||
|
server_key = ""
|
||||||
|
|
||||||
|
; 分区推送服务(备)|主备冲突
|
||||||
|
[zone_monitor]
|
||||||
|
enable = true
|
||||||
|
server_addr = "tcp://broadcastlv.chat.bilibili.com:2243/sub"
|
||||||
|
|
||||||
|
; 加密心跳服务器(开源)|如失效自行搭建
|
||||||
|
[heartbeat_enc]
|
||||||
|
server = "http://heartbeat-1.mudew.com:3000/enc"
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# 房间设置 #
|
||||||
|
#######################
|
||||||
|
|
||||||
|
; 直播间ID,全局房间,用于礼物赠送、心跳等等.
|
||||||
|
[global_room]
|
||||||
|
room_id = 9522051
|
||||||
|
|
||||||
|
; 弹幕监控房间(为空则随机)
|
||||||
|
[socket]
|
||||||
|
room_id = 9522051
|
||||||
|
|
||||||
|
; 勋章亲密度,测试功能,有短位使用短位反之长位,左侧优先,仅支持辣条和亿元
|
||||||
|
; 当列表中所有ID都已达到每日上限,剩余礼物赠送ROOM_ID指定的直播间
|
||||||
|
; 是否填满(按时间投喂正常礼物,否则过期礼物)|直播间ID列表|逗号分隔|
|
||||||
|
[intimacy]
|
||||||
|
feed_fill = false
|
||||||
|
room_list = 9522051
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# 网络设置 #
|
||||||
|
#######################
|
||||||
|
|
||||||
|
; 验证SSL证书|请求时验证SSL证书行为
|
||||||
|
[network.ssl]
|
||||||
|
verify_ssl = true
|
||||||
|
|
||||||
|
; 是否使用代理|(http\https)
|
||||||
|
[network.proxy]
|
||||||
|
enable = false
|
||||||
|
proxy = "http://127.0.0.1:8888"
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# 程序设置 #
|
||||||
|
#######################
|
||||||
|
|
||||||
|
; 调试模式|采集完整日志
|
||||||
|
[debug]
|
||||||
|
enable = false
|
||||||
|
|
||||||
|
; 记录日志|日志路径|日志回调地址
|
||||||
|
[log]
|
||||||
|
enable = false
|
||||||
|
path = log
|
||||||
|
callback = "http://www.example.com/api.send?text={account}[{level}]: {message}"
|
||||||
|
# 错误回调级别
|
||||||
|
#
|
||||||
|
# DEBUG 100
|
||||||
|
# INFO 200
|
||||||
|
# NOTICE 250
|
||||||
|
# WARNING 300
|
||||||
|
# ERROR 400
|
||||||
|
#
|
||||||
|
callback_level = 400
|
||||||
|
|
||||||
|
; app设置
|
||||||
|
[print]
|
||||||
|
; 用户名,可自定义
|
||||||
|
uname =
|
||||||
|
; 账号别名,如果为空则默认使用登录账号作为标示
|
||||||
|
user_identity =
|
||||||
|
; 多账号区别输出
|
||||||
|
multiple = false
|
||||||
@ -5,9 +5,9 @@
|
|||||||
"data": [
|
"data": [
|
||||||
{
|
{
|
||||||
"_url": "注释: 活动地址",
|
"_url": "注释: 活动地址",
|
||||||
"url": "https://www.bilibili.com/blackboard/activity-c_fu2inm-.html",
|
"url": "https://www.bilibili.com/blackboard/activity-raop07Ymhm.html",
|
||||||
"_title": "注释: 活动标题",
|
"_title": "注释: 活动标题",
|
||||||
"title": "原神1.4版本「风花的邀约」激励计划",
|
"title": "原神1.5版本UP主激励计划",
|
||||||
"_description": "注释: 活动描述",
|
"_description": "注释: 活动描述",
|
||||||
"description": "每日在原神分区任意直播间观看,20分钟1张、1小时2张、2小时3张,每日最高6张。",
|
"description": "每日在原神分区任意直播间观看,20分钟1张、1小时2张、2小时3张,每日最高6张。",
|
||||||
"_room_id": "注释: 活动直播间,如果为0,则取分区随机一个",
|
"_room_id": "注释: 活动直播间,如果为0,则取分区随机一个",
|
||||||
@ -17,25 +17,13 @@
|
|||||||
"_parent_area_id": "注释: 主分区id",
|
"_parent_area_id": "注释: 主分区id",
|
||||||
"parent_area_id": 3,
|
"parent_area_id": 3,
|
||||||
"_coin_id": "注释: 抽奖id",
|
"_coin_id": "注释: 抽奖id",
|
||||||
"coin_id": 112,
|
"coin_id": 135,
|
||||||
"_watch_time": "注释: 观看时长 单位秒",
|
"_watch_time": "注释: 观看时长 单位秒",
|
||||||
"watch_time": 7320,
|
"watch_time": 7320,
|
||||||
"_draw_times": "注释: 抽奖次数",
|
"_draw_times": "注释: 抽奖次数",
|
||||||
"draw_times": 1,
|
"draw_times": 1,
|
||||||
"_expire_at": "注释: 活动有效时间",
|
"_expire_at": "注释: 活动有效时间",
|
||||||
"expire_at": "2021-04-27 23:59:59"
|
"expire_at": "2021-06-08 23:59:59"
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://www.bilibili.com/blackboard/activity-MHRISE.html",
|
|
||||||
"title": "《怪物猎人:崛起》直播挑战",
|
|
||||||
"description": "每日在怪物猎人分区任意直播间观看,10分钟1张、30分钟3张、60分钟5张",
|
|
||||||
"room_id": 0,
|
|
||||||
"area_id": 412,
|
|
||||||
"parent_area_id": 6,
|
|
||||||
"coin_id": 121,
|
|
||||||
"watch_time": 3720,
|
|
||||||
"draw_times": 2,
|
|
||||||
"expire_at": "2021-04-26 23:59:59"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "https://live.bilibili.com/11218604",
|
"url": "https://live.bilibili.com/11218604",
|
||||||
@ -47,7 +35,7 @@
|
|||||||
"coin_id": 129,
|
"coin_id": 129,
|
||||||
"watch_time": 3720,
|
"watch_time": 3720,
|
||||||
"draw_times": 3,
|
"draw_times": 3,
|
||||||
"expire_at": "2021-05-31 23:59:59"
|
"expire_at": "2021-05-30 23:59:59"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "https://live.bilibili.com/6",
|
"url": "https://live.bilibili.com/6",
|
||||||
@ -63,7 +51,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "https://live.bilibili.com/23",
|
"url": "https://live.bilibili.com/23",
|
||||||
"title": "PEI亚洲邀请赛",
|
"title": "PEL和平精英职业联赛",
|
||||||
"description": "每日在PEL直播间观看,5分钟1张",
|
"description": "每日在PEL直播间观看,5分钟1张",
|
||||||
"room_id": 13242892,
|
"room_id": 13242892,
|
||||||
"area_id": 0,
|
"area_id": 0,
|
||||||
@ -71,7 +59,7 @@
|
|||||||
"coin_id": 109,
|
"coin_id": 109,
|
||||||
"watch_time": 3720,
|
"watch_time": 3720,
|
||||||
"draw_times": 2,
|
"draw_times": 2,
|
||||||
"expire_at": "2021-05-31 23:59:59"
|
"expire_at": "2021-06-13 23:59:59"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -3,8 +3,8 @@
|
|||||||
"project":"BiliHelper-personal",
|
"project":"BiliHelper-personal",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"source": "https://github.com/lkeme/BiliHelper-personal",
|
"source": "https://github.com/lkeme/BiliHelper-personal",
|
||||||
"raw_url": "https://cdn.jsdelivr.net/gh/lkeme/BiliHelper-personal@master/data/latest.json",
|
"raw_url": "https://cdn.jsdelivr.net/gh/lkeme/BiliHelper-personal@master/data/latest_version.json",
|
||||||
"version": "0.8.1.210423",
|
"version": "0.9.0.210517",
|
||||||
"des": "程序有更新哦,请及时线上查看。",
|
"des": "程序有更新,请及时线上查看更新哦~",
|
||||||
"time": '2021年5月6日15:42:40'
|
"time": "2021年5月17日17:44:47"
|
||||||
}
|
}
|
||||||
@ -12,8 +12,9 @@
|
|||||||
require 'vendor/autoload.php';
|
require 'vendor/autoload.php';
|
||||||
|
|
||||||
|
|
||||||
$filename = isset($argv[1]) ? $argv[1] : 'user.conf';
|
$filename = $argv[1] ?? 'user.ini';
|
||||||
|
|
||||||
$app = new BiliHelper\Core\App(__DIR__);
|
$app = new BiliHelper\Core\App(__DIR__);
|
||||||
$app->load($filename);
|
$app->load($filename)
|
||||||
$app->start();
|
->inspect()
|
||||||
|
->start();
|
||||||
|
|||||||
@ -12,8 +12,6 @@ namespace BiliHelper\Core;
|
|||||||
|
|
||||||
use Amp\Loop;
|
use Amp\Loop;
|
||||||
use function Amp\asyncCall;
|
use function Amp\asyncCall;
|
||||||
use BiliHelper\Plugin\Notice;
|
|
||||||
|
|
||||||
|
|
||||||
class App
|
class App
|
||||||
{
|
{
|
||||||
@ -26,7 +24,16 @@ class App
|
|||||||
define('APP_CONF_PATH', $app_path . "/conf/");
|
define('APP_CONF_PATH', $app_path . "/conf/");
|
||||||
define('APP_DATA_PATH', $app_path . "/data/");
|
define('APP_DATA_PATH', $app_path . "/data/");
|
||||||
define('APP_LOG_PATH', $app_path . "/log/");
|
define('APP_LOG_PATH', $app_path . "/log/");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 检查环境
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function inspect(): App
|
||||||
|
{
|
||||||
(new Env())->inspect_configure()->inspect_extension();
|
(new Env())->inspect_configure()->inspect_extension();
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +41,7 @@ class App
|
|||||||
* @param string $load_file
|
* @param string $load_file
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function load($load_file = 'user.conf')
|
public function load($load_file = 'user.ini'): App
|
||||||
{
|
{
|
||||||
Config::load($load_file);
|
Config::load($load_file);
|
||||||
return $this;
|
return $this;
|
||||||
@ -70,12 +77,11 @@ class App
|
|||||||
'Login',
|
'Login',
|
||||||
'Schedule',
|
'Schedule',
|
||||||
'MainSite',
|
'MainSite',
|
||||||
'Daily',
|
'DailyBag',
|
||||||
'ManGa',
|
'ManGa',
|
||||||
'GameMatch',
|
|
||||||
'ActivityLottery',
|
'ActivityLottery',
|
||||||
'Competition',
|
'Competition',
|
||||||
'Heart',
|
'DoubleHeart',
|
||||||
'DailyTask',
|
'DailyTask',
|
||||||
'Barrage',
|
'Barrage',
|
||||||
'Silver2Coin',
|
'Silver2Coin',
|
||||||
@ -93,10 +99,13 @@ class App
|
|||||||
'GuardRaffle',
|
'GuardRaffle',
|
||||||
'AnchorRaffle',
|
'AnchorRaffle',
|
||||||
'AwardRecord',
|
'AwardRecord',
|
||||||
'Statistics',
|
|
||||||
'Forward',
|
'Forward',
|
||||||
'CapsuleLottery',
|
'CapsuleLottery',
|
||||||
// 'Silver',
|
'PolishTheMedal',
|
||||||
|
'VipPrivilege',
|
||||||
|
'BpConsumption',
|
||||||
|
// 'Silver', // Abandoned
|
||||||
|
'Statistics',
|
||||||
|
|
||||||
];
|
];
|
||||||
foreach ($plugins as $plugin) {
|
foreach ($plugins as $plugin) {
|
||||||
|
|||||||
@ -10,16 +10,37 @@
|
|||||||
|
|
||||||
namespace BiliHelper\Core;
|
namespace BiliHelper\Core;
|
||||||
|
|
||||||
use Dotenv\Dotenv;
|
use Jelix\IniFile\IniModifier;
|
||||||
|
|
||||||
|
|
||||||
class Config
|
class Config
|
||||||
{
|
{
|
||||||
private static $app_config;
|
private static $app_config;
|
||||||
private static $config_path;
|
|
||||||
private static $instance;
|
private static $instance;
|
||||||
|
|
||||||
public static function getInstance()
|
/**
|
||||||
|
* 不允许从外部调用以防止创建多个实例
|
||||||
|
* 要使用单例,必须通过 Singleton::getInstance() 方法获取实例
|
||||||
|
*/
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 防止实例被克隆(这会创建实例的副本)
|
||||||
|
*/
|
||||||
|
private function __clone()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 防止反序列化(这将创建它的副本)
|
||||||
|
*/
|
||||||
|
public function __wakeup()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getInstance(): Config
|
||||||
{
|
{
|
||||||
if (is_null(self::$instance)) {
|
if (is_null(self::$instance)) {
|
||||||
self::$instance = new static;
|
self::$instance = new static;
|
||||||
@ -27,72 +48,43 @@ class Config
|
|||||||
return self::$instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function load($load_file)
|
|
||||||
{
|
|
||||||
return self::getInstance()::_load($load_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function put($key, $val = null)
|
|
||||||
{
|
|
||||||
return self::getInstance()::_put($key, $val);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function get($key = null)
|
|
||||||
{
|
|
||||||
return self::getInstance()::_get($key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 加载配置文件
|
* @use 加载配置
|
||||||
* @param string $load_file
|
* @param string $load_file
|
||||||
*/
|
*/
|
||||||
private static function _load($load_file)
|
public static function load(string $load_file)
|
||||||
{
|
{
|
||||||
$config_path = str_replace("\\", "/", APP_CONF_PATH . $load_file);
|
$config_path = str_replace("\\", "/", APP_CONF_PATH . $load_file);
|
||||||
if (!is_file($config_path)) {
|
if (!is_file($config_path)) {
|
||||||
die("配置文件 {$load_file} 加载错误,请参照文档添加配置文件!");
|
die("配置文件 {$load_file} 加载错误,请参照文档添加配置文件!");
|
||||||
}
|
}
|
||||||
$app_config = Dotenv::createImmutable(dirname($config_path), $load_file);
|
// $config_path = dirname($config_path).DIRECTORY_SEPARATOR.$load_file;
|
||||||
$app_config->load();
|
self::$app_config = new IniModifier($config_path);
|
||||||
self::$app_config = $app_config;
|
|
||||||
self::$config_path = $config_path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
public static function _set($name, $value, $section = 0, $key = null)
|
||||||
* @use 写入配置
|
|
||||||
* @param $key
|
|
||||||
* @param $val
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private static function _put($key, $val)
|
|
||||||
{
|
{
|
||||||
if (!is_null($val)) {
|
$_instance = self::getInstance();
|
||||||
if (!empty(self::$config_path)) {
|
$_instance::$app_config->setValue($name, $value, $section, $key);
|
||||||
file_put_contents(self::$config_path, preg_replace(
|
$_instance::$app_config->save();
|
||||||
'/^' . $key . '=\S*/m',
|
|
||||||
$key . '=' . $val,
|
|
||||||
file_get_contents(self::$config_path)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
putenv($key . '=' . $val);
|
|
||||||
// self::$app_config->load();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static function _get($name, $section = 0, $key = null)
|
||||||
* @use 读出配置
|
|
||||||
* @param string|null $key
|
|
||||||
* @return mixed|null
|
|
||||||
*/
|
|
||||||
private static function _get($key)
|
|
||||||
{
|
{
|
||||||
if (self::$app_config->required($key)) {
|
$_instance = self::getInstance();
|
||||||
return getenv($key);
|
return $_instance::$app_config->getValue($name, $section, $key);
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function _put()
|
||||||
|
{
|
||||||
|
$_instance = self::getInstance();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function _del()
|
||||||
|
{
|
||||||
|
$_instance = self::getInstance();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ class Curl
|
|||||||
* @param int $timeout
|
* @param int $timeout
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function async($os, $url, $tasks = [], $headers = [], $timeout = 30)
|
public static function async($os, $url, $tasks = [], $headers = [], $timeout = 30): array
|
||||||
{
|
{
|
||||||
self::$async_opt = [
|
self::$async_opt = [
|
||||||
'tasks' => $tasks,
|
'tasks' => $tasks,
|
||||||
@ -155,7 +155,7 @@ class Curl
|
|||||||
);
|
);
|
||||||
$result = $url ? @file_get_contents($url, false, stream_context_create($options)) : null;
|
$result = $url ? @file_get_contents($url, false, stream_context_create($options)) : null;
|
||||||
Log::debug($result);
|
Log::debug($result);
|
||||||
return $result ? $result : null;
|
return $result ?: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -167,18 +167,16 @@ class Curl
|
|||||||
self::$async_opt['counter']++;
|
self::$async_opt['counter']++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
# 请求结束!
|
// 请求结束
|
||||||
self::$async_opt = [];
|
self::$async_opt = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 请求中心异常处理
|
* @use 请求中心异常处理
|
||||||
* @param string $url
|
* @param string $url
|
||||||
* @param string $method
|
* @param string $method
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
private static function clientHandle(string $url, string $method, array $options)
|
private static function clientHandle(string $url, string $method, array $options)
|
||||||
{
|
{
|
||||||
@ -209,17 +207,17 @@ class Curl
|
|||||||
* @param float $timeout
|
* @param float $timeout
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private static function getClientOpt(array $add_options, array $headers = [], float $timeout = 30.0)
|
private static function getClientOpt(array $add_options, array $headers = [], float $timeout = 30.0): array
|
||||||
{
|
{
|
||||||
self::$client = new \GuzzleHttp\Client();
|
self::$client = new \GuzzleHttp\Client();
|
||||||
$default_options = [
|
$default_options = [
|
||||||
'headers' => $headers,
|
'headers' => $headers,
|
||||||
'timeout' => $timeout,
|
'timeout' => $timeout,
|
||||||
'http_errors' => false,
|
'http_errors' => false,
|
||||||
'verify' => getenv('VERIFY_SSL') == 'false' ? false : true,
|
'verify' => getConf('verify_ssl', 'network.ssl'),
|
||||||
];
|
];
|
||||||
if (getenv('USE_PROXY') == 'true') {
|
if (getConf('enable', 'network.proxy')) {
|
||||||
$default_options['proxy'] = getenv('NETWORK_PROXY');
|
$default_options['proxy'] = getConf('proxy', 'network.proxy');
|
||||||
}
|
}
|
||||||
return array_merge($default_options, $add_options);
|
return array_merge($default_options, $add_options);
|
||||||
}
|
}
|
||||||
@ -245,7 +243,7 @@ class Curl
|
|||||||
'Connection' => 'keep-alive',
|
'Connection' => 'keep-alive',
|
||||||
// 'Content-Type' => 'application/x-www-form-urlencoded',
|
// 'Content-Type' => 'application/x-www-form-urlencoded',
|
||||||
// 'User-Agent' => 'Mozilla/5.0 BiliDroid/5.51.1 (bbcallen@gmail.com)',
|
// 'User-Agent' => 'Mozilla/5.0 BiliDroid/5.51.1 (bbcallen@gmail.com)',
|
||||||
'User-Agent' => 'Mozilla/5.0 BiliDroid/6.20.5 (bbcallen@gmail.com) os/android model/MuMu mobi_app/android build/6205500 channel/bili innerVer/6205500 osVer/6.0.1 network/2',
|
'User-Agent' => 'Mozilla/5.0 BiliDroid/6.24.0 (bbcallen@gmail.com) os/android model/MuMu mobi_app/android build/6240300 channel/bili innerVer/6240300 osVer/6.0.1 network/2',
|
||||||
// 'Referer' => 'https://live.bilibili.com/',
|
// 'Referer' => 'https://live.bilibili.com/',
|
||||||
];
|
];
|
||||||
$pc_headers = [
|
$pc_headers = [
|
||||||
@ -259,37 +257,14 @@ class Curl
|
|||||||
$other_headers = [
|
$other_headers = [
|
||||||
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4450.0 Safari/537.36',
|
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4450.0 Safari/537.36',
|
||||||
];
|
];
|
||||||
$default_headers = isset(${$os . "_headers"}) ? ${$os . "_headers"} : $other_headers;
|
$default_headers = ${$os . "_headers"} ?? $other_headers;
|
||||||
if (in_array($os, ['app', 'pc']) && getenv('COOKIE') != "") {
|
if (in_array($os, ['app', 'pc']) && getCookie() != "") {
|
||||||
$default_headers['Cookie'] = getenv('COOKIE');
|
$default_headers['Cookie'] = getCookie();
|
||||||
}
|
}
|
||||||
// return self::formatHeaders(array_merge($default_headers, $headers));
|
// return self::formatHeaders(array_merge($default_headers, $headers));
|
||||||
return array_merge($default_headers, $headers);
|
return array_merge($default_headers, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @use 格式化Headers
|
|
||||||
* @param $headers
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private static function formatHeaders(array $headers): array
|
|
||||||
{
|
|
||||||
return array_map(function ($k, $v) {
|
|
||||||
return $k . ': ' . $v;
|
|
||||||
}, array_keys($headers), $headers);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @use 字符串or其他
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private static function getResult()
|
|
||||||
{
|
|
||||||
$result = self::$result;
|
|
||||||
self::$result = [];
|
|
||||||
return array_shift($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 数组
|
* @use 数组
|
||||||
* @return array
|
* @return array
|
||||||
@ -336,4 +311,27 @@ class Curl
|
|||||||
Log::debug("获取Headers");
|
Log::debug("获取Headers");
|
||||||
return $request->getHeaders();
|
return $request->getHeaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 格式化Headers
|
||||||
|
* @param array $headers
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private static function formatHeaders(array $headers): array
|
||||||
|
{
|
||||||
|
return array_map(function ($k, $v) {
|
||||||
|
return $k . ': ' . $v;
|
||||||
|
}, array_keys($headers), $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 字符串or其他
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private static function getResult(): array
|
||||||
|
{
|
||||||
|
$result = self::$result;
|
||||||
|
self::$result = [];
|
||||||
|
return array_shift($result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,10 +10,17 @@
|
|||||||
|
|
||||||
namespace BiliHelper\Core;
|
namespace BiliHelper\Core;
|
||||||
|
|
||||||
|
use Noodlehaus\Config;
|
||||||
|
|
||||||
class Env
|
class Env
|
||||||
{
|
{
|
||||||
private $app_name = 'BiliHelper Personal';
|
private $app_name;
|
||||||
private $app_version = '0.8.1.*';
|
private $app_version;
|
||||||
|
private $app_branch;
|
||||||
|
private $app_source;
|
||||||
|
|
||||||
|
private $repository = APP_DATA_PATH . 'latest_version.json';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Env constructor.
|
* Env constructor.
|
||||||
@ -26,6 +33,8 @@ class Env
|
|||||||
date_default_timezone_set('Asia/Shanghai');
|
date_default_timezone_set('Asia/Shanghai');
|
||||||
ini_set('display_errors', 'on');
|
ini_set('display_errors', 'on');
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
$this->loadJsonData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,7 +47,7 @@ class Env
|
|||||||
if (!extension_loaded($extension)) {
|
if (!extension_loaded($extension)) {
|
||||||
Log::error("检查到项目依赖 {$extension} 扩展未加载。");
|
Log::error("检查到项目依赖 {$extension} 扩展未加载。");
|
||||||
Log::error("请在 php.ini中启用 {$extension} 扩展后重试。");
|
Log::error("请在 php.ini中启用 {$extension} 扩展后重试。");
|
||||||
Log::error("程序常见问题请移步 https://github.com/lkeme/BiliHelper-personal 文档部分查看。");
|
Log::error("程序常见问题请移步 {$this->app_source} 文档部分查看。");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,20 +56,32 @@ class Env
|
|||||||
/**
|
/**
|
||||||
* @use 检查环境
|
* @use 检查环境
|
||||||
*/
|
*/
|
||||||
public function inspect_configure()
|
public function inspect_configure(): Env
|
||||||
{
|
{
|
||||||
Log::info("欢迎使用 {$this->app_name} 当前版本 {$this->app_version}");
|
Log::info("欢迎使用 项目: {$this->app_name}@{$this->app_branch} 版本: {$this->app_version}");
|
||||||
Log::info("使用说明请移步 https://github.com/lkeme/BiliHelper-personal 查看。");
|
Log::info("使用说明请移步 {$this->app_source} 查看");
|
||||||
|
|
||||||
if (PHP_SAPI != 'cli') {
|
if (PHP_SAPI != 'cli') {
|
||||||
die("Please run this script from command line .");
|
die("Please run this script from command line .");
|
||||||
}
|
}
|
||||||
if (version_compare(PHP_VERSION, '7.0.0', '<')) {
|
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
|
||||||
die("Please upgrade PHP version > 7.0.0 .");
|
die("Please upgrade PHP version > 7.3.0 .");
|
||||||
}
|
}
|
||||||
// if (version_compare(PHP_VERSION, '8.0.0', '>')) {
|
// if (version_compare(PHP_VERSION, '8.0.0', '>')) {
|
||||||
// die("Please upgrade PHP version < 8.0.0 .");
|
// die("Please upgrade PHP version < 8.0.0 .");
|
||||||
// }
|
// }
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 加载本地JSON DATA
|
||||||
|
*/
|
||||||
|
private function loadJsonData()
|
||||||
|
{
|
||||||
|
$conf = new Config($this->repository);
|
||||||
|
$this->app_name = $conf->get('project');
|
||||||
|
$this->app_version = $conf->get('version');
|
||||||
|
$this->app_branch = $conf->get('branch');
|
||||||
|
$this->app_source = $conf->get('source');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
106
src/core/Helpers.php
Normal file
106
src/core/Helpers.php
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Website: https://mudew.com/
|
||||||
|
* Author: Lkeme
|
||||||
|
* License: The MIT License
|
||||||
|
* Email: Useri@live.cn
|
||||||
|
* Updated: 2021 ~ 2022
|
||||||
|
*/
|
||||||
|
|
||||||
|
use BiliHelper\Core\Config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 读取
|
||||||
|
* @param $name
|
||||||
|
* @param int $section
|
||||||
|
* @param null $key
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function getConf($name, $section = 0, $key = null)
|
||||||
|
{
|
||||||
|
return Config::_get($name, $section, $key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 写入
|
||||||
|
* @param $name
|
||||||
|
* @param $value
|
||||||
|
* @param int $section
|
||||||
|
* @param null $key
|
||||||
|
*/
|
||||||
|
function setConf($name, $value, $section = 0, $key = null)
|
||||||
|
{
|
||||||
|
Config::_set($name, $value, $section, $key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 更新
|
||||||
|
*/
|
||||||
|
function putConf()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 删除
|
||||||
|
*/
|
||||||
|
function delConf()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 开关
|
||||||
|
* @param string $plugin
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function getEnable(string $plugin): bool
|
||||||
|
{
|
||||||
|
return getConf('enable', $plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 获取ACCESS_TOKEN
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function getAccessToken(): string
|
||||||
|
{
|
||||||
|
return getConf('access_token', 'login.auth');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 获取REFRESH_TOKEN
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function getRefreshToken(): string
|
||||||
|
{
|
||||||
|
return getConf('refresh_token', 'login.auth');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 获取COOKIE
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function getCookie(): string
|
||||||
|
{
|
||||||
|
return getConf('cookie', 'login.auth');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 获取UID
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
function getUid(): int
|
||||||
|
{
|
||||||
|
return getConf('uid', 'login.auth');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 获取CSRF
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function getCsrf(): string
|
||||||
|
{
|
||||||
|
return getConf('csrf', 'login.auth');
|
||||||
|
}
|
||||||
@ -18,6 +18,9 @@ class Log
|
|||||||
{
|
{
|
||||||
protected static $instance;
|
protected static $instance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 实体
|
||||||
|
*/
|
||||||
static public function getLogger()
|
static public function getLogger()
|
||||||
{
|
{
|
||||||
if (!self::$instance) {
|
if (!self::$instance) {
|
||||||
@ -26,53 +29,79 @@ class Log
|
|||||||
return self::$instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 单例
|
||||||
|
*/
|
||||||
private static function configureInstance()
|
private static function configureInstance()
|
||||||
{
|
{
|
||||||
$logger = new Logger('BH');
|
$logger = new Logger('BH');
|
||||||
$handler = new StreamHandler('php://stdout', getenv('APP_DEBUG') == 'true' ? Logger::DEBUG : Logger::INFO);
|
$handler = new StreamHandler('php://stdout', getConf('enable', 'debug') ? Logger::DEBUG : Logger::INFO);
|
||||||
$handler->setFormatter(new ColoredLineFormatter());
|
$handler->setFormatter(new ColoredLineFormatter());
|
||||||
$logger->pushHandler($handler);
|
$logger->pushHandler($handler);
|
||||||
self::$instance = $logger;
|
self::$instance = $logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function prefix()
|
/**
|
||||||
|
* @use 前缀
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private static function prefix(): string
|
||||||
{
|
{
|
||||||
if (getenv('APP_MULTIPLE') == 'true') {
|
if (getConf('multiple', 'print')) {
|
||||||
return '[' . (empty($t = getenv('APP_USER_IDENTITY')) ? getenv('APP_USER') : $t) . ']';
|
return '[' . getConf('user_identity', 'print') ?? getConf('username', 'login.account') . ']';
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 写日志
|
||||||
|
* @param $type
|
||||||
|
* @param $message
|
||||||
|
*/
|
||||||
private static function writeLog($type, $message)
|
private static function writeLog($type, $message)
|
||||||
{
|
{
|
||||||
if (getenv('APP_WRITE_LOG') == 'true') {
|
if (getConf('enable', 'log')) {
|
||||||
if ($type == 'DEBUG' && getenv("APP_DEBUG") != 'true') {
|
if ($type == 'DEBUG' && !getConf('enable', 'debug')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$path = './' . getenv("APP_LOG_PATH") . '/';
|
$path = './' . getConf('path', 'log') . '/';
|
||||||
if (!file_exists($path)) {
|
if (!file_exists($path)) {
|
||||||
mkdir($path);
|
mkdir($path);
|
||||||
chmod($path, 0777);
|
chmod($path, 0777);
|
||||||
}
|
}
|
||||||
$filename = $path . getenv('APP_USER') . ".log";
|
$filename = $path . getConf('username', 'login.account') . ".log";
|
||||||
$date = date('[Y-m-d H:i:s] ');
|
$date = date('[Y-m-d H:i:s] ');
|
||||||
$data = $date . ' Log.' . $type . ' ' . $message . PHP_EOL;
|
$data = $date . ' Log.' . $type . ' ' . $message . PHP_EOL;
|
||||||
file_put_contents($filename, $data, FILE_APPEND);
|
file_put_contents($filename, $data, FILE_APPEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 堆栈
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
private static function backtrace(): string
|
private static function backtrace(): string
|
||||||
{
|
{
|
||||||
$backtraces = debug_backtrace();
|
$backtraces = debug_backtrace();
|
||||||
return "(" . pathinfo(basename($backtraces[1]['file']))['filename'] . ") => ";
|
return "(" . pathinfo(basename($backtraces[1]['file']))['filename'] . ") => ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 调试
|
||||||
|
* @param $message
|
||||||
|
* @param array $context
|
||||||
|
*/
|
||||||
public static function debug($message, array $context = [])
|
public static function debug($message, array $context = [])
|
||||||
{
|
{
|
||||||
self::writeLog('DEBUG', $message);
|
self::writeLog('DEBUG', $message);
|
||||||
self::getLogger()->addDebug($message, $context);
|
self::getLogger()->addDebug($message, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 信息
|
||||||
|
* @param $message
|
||||||
|
* @param array $context
|
||||||
|
*/
|
||||||
public static function info($message, array $context = [])
|
public static function info($message, array $context = [])
|
||||||
{
|
{
|
||||||
$message = self::prefix() . self::backtrace() . $message;
|
$message = self::prefix() . self::backtrace() . $message;
|
||||||
@ -81,6 +110,11 @@ class Log
|
|||||||
self::callback(Logger::INFO, 'INFO', $message);
|
self::callback(Logger::INFO, 'INFO', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 提醒
|
||||||
|
* @param $message
|
||||||
|
* @param array $context
|
||||||
|
*/
|
||||||
public static function notice($message, array $context = [])
|
public static function notice($message, array $context = [])
|
||||||
{
|
{
|
||||||
$message = self::prefix() . self::backtrace() . $message;
|
$message = self::prefix() . self::backtrace() . $message;
|
||||||
@ -89,6 +123,11 @@ class Log
|
|||||||
self::callback(Logger::NOTICE, 'NOTICE', $message);
|
self::callback(Logger::NOTICE, 'NOTICE', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 警告
|
||||||
|
* @param $message
|
||||||
|
* @param array $context
|
||||||
|
*/
|
||||||
public static function warning($message, array $context = [])
|
public static function warning($message, array $context = [])
|
||||||
{
|
{
|
||||||
$message = self::prefix() . self::backtrace() . $message;
|
$message = self::prefix() . self::backtrace() . $message;
|
||||||
@ -97,6 +136,11 @@ class Log
|
|||||||
self::callback(Logger::WARNING, 'WARNING', $message);
|
self::callback(Logger::WARNING, 'WARNING', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 错误
|
||||||
|
* @param $message
|
||||||
|
* @param array $context
|
||||||
|
*/
|
||||||
public static function error($message, array $context = [])
|
public static function error($message, array $context = [])
|
||||||
{
|
{
|
||||||
$message = self::prefix() . self::backtrace() . $message;
|
$message = self::prefix() . self::backtrace() . $message;
|
||||||
@ -105,11 +149,18 @@ class Log
|
|||||||
self::callback(Logger::ERROR, 'ERROR', $message);
|
self::callback(Logger::ERROR, 'ERROR', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 回调
|
||||||
|
* @param $levelId
|
||||||
|
* @param $level
|
||||||
|
* @param $message
|
||||||
|
*/
|
||||||
public static function callback($levelId, $level, $message)
|
public static function callback($levelId, $level, $message)
|
||||||
{
|
{
|
||||||
$callback_level = (('APP_CALLBACK_LEVEL') == '') ? (Logger::ERROR) : intval(getenv('APP_CALLBACK_LEVEL'));
|
// $callback_level = Logger::ERROR ?? getConf('callback_level', 'log');
|
||||||
|
$callback_level = getConf('callback_level', 'log') ?? Logger::ERROR;
|
||||||
if ($levelId >= $callback_level) {
|
if ($levelId >= $callback_level) {
|
||||||
$url = str_replace('{account}', self::prefix(), getenv('APP_CALLBACK'));
|
$url = str_replace('{account}', self::prefix(), getConf('callback', 'log'));
|
||||||
$url = str_replace('{level}', $level, $url);
|
$url = str_replace('{level}', $level, $url);
|
||||||
$url = str_replace('{message}', urlencode($message), $url);
|
$url = str_replace('{message}', urlencode($message), $url);
|
||||||
Curl::request('get', str_replace(' ', '%20', $url));
|
Curl::request('get', str_replace(' ', '%20', $url));
|
||||||
|
|||||||
@ -22,9 +22,15 @@ class ActivityLottery
|
|||||||
|
|
||||||
private static $repository = APP_DATA_PATH . 'activity_infos.json';
|
private static $repository = APP_DATA_PATH . 'activity_infos.json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \JsonDecodeStream\Exception\TokenizerException
|
||||||
|
* @throws \JsonDecodeStream\Exception\SelectorException
|
||||||
|
* @throws \JsonDecodeStream\Exception\CollectorException
|
||||||
|
* @throws \JsonDecodeStream\Exception\ParserException
|
||||||
|
*/
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (self::getLock() > time() || getenv('USE_ACTIVITY') == 'false') {
|
if (self::getLock() > time() || !getEnable('main_activity')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self::allotTasks();
|
self::allotTasks();
|
||||||
@ -35,7 +41,6 @@ class ActivityLottery
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 分配任务
|
* @use 分配任务
|
||||||
* @return bool
|
* @return bool
|
||||||
@ -86,7 +91,7 @@ class ActivityLottery
|
|||||||
* @use 执行任务
|
* @use 执行任务
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private static function workTask()
|
private static function workTask(): bool
|
||||||
{
|
{
|
||||||
if (self::$work_status['work_completed'] == date("Y/m/d")) {
|
if (self::$work_status['work_completed'] == date("Y/m/d")) {
|
||||||
return false;
|
return false;
|
||||||
@ -119,7 +124,6 @@ class ActivityLottery
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取抽奖机会
|
* @use 获取抽奖机会
|
||||||
* @param string $sid
|
* @param string $sid
|
||||||
@ -140,7 +144,7 @@ class ActivityLottery
|
|||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
// {"code":0,"message":"0","ttl":1,"data":{"times":2}}
|
// {"code":0,"message":"0","ttl":1,"data":{"times":2}}
|
||||||
if ($de_raw['code'] == 0) {
|
if ($de_raw['code'] == 0) {
|
||||||
Log::info("获取抽奖机会成功 {$raw}");
|
Log::notice("获取抽奖机会成功 {$raw}");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Log::warning("获取抽奖机会失败 {$raw}");
|
Log::warning("获取抽奖机会失败 {$raw}");
|
||||||
@ -161,16 +165,15 @@ class ActivityLottery
|
|||||||
'origin' => 'https://www.bilibili.com',
|
'origin' => 'https://www.bilibili.com',
|
||||||
'referer' => $referer
|
'referer' => $referer
|
||||||
];
|
];
|
||||||
$user_info = User::parseCookies();
|
|
||||||
// $action_type 4 关注 3 分享
|
// $action_type 4 关注 3 分享
|
||||||
$payload = [
|
$payload = [
|
||||||
'sid' => $sid,
|
'sid' => $sid,
|
||||||
'action_type' => $action_type,
|
'action_type' => $action_type,
|
||||||
'csrf' => $user_info['token']
|
'csrf' => getCsrf()
|
||||||
];
|
];
|
||||||
$raw = Curl::post('pc', $url, $payload, $headers);
|
$raw = Curl::post('pc', $url, $payload, $headers);
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
Log::info("增加抽奖机会#{$action_type} {$raw}");
|
Log::notice("增加抽奖机会#{$action_type} {$raw}");
|
||||||
// {"code":0,"message":"0","ttl":1}
|
// {"code":0,"message":"0","ttl":1}
|
||||||
if ($de_raw['code'] == 0) {
|
if ($de_raw['code'] == 0) {
|
||||||
return true;
|
return true;
|
||||||
@ -192,11 +195,10 @@ class ActivityLottery
|
|||||||
'origin' => 'https://www.bilibili.com',
|
'origin' => 'https://www.bilibili.com',
|
||||||
'referer' => $referer
|
'referer' => $referer
|
||||||
];
|
];
|
||||||
$user_info = User::parseCookies();
|
|
||||||
$payload = [
|
$payload = [
|
||||||
'sid' => $sid,
|
'sid' => $sid,
|
||||||
'type' => 1,
|
'type' => 1,
|
||||||
'csrf' => $user_info['token']
|
'csrf' => getCsrf()
|
||||||
];
|
];
|
||||||
$raw = Curl::post('pc', $url, $payload, $headers);
|
$raw = Curl::post('pc', $url, $payload, $headers);
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
|
|||||||
@ -32,7 +32,7 @@ class AloneTcpClient
|
|||||||
*/
|
*/
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (self::getLock() > time() || getenv('USE_ALONE_SERVER') == 'false') {
|
if (self::getLock() > time() || !getEnable('alone_monitor')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self::setPauseStatus();
|
self::setPauseStatus();
|
||||||
@ -41,36 +41,33 @@ class AloneTcpClient
|
|||||||
self::receive();
|
self::receive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 初始化
|
* @use 初始化
|
||||||
*/
|
*/
|
||||||
private static function init()
|
private static function init()
|
||||||
{
|
{
|
||||||
if (empty(getenv('ALONE_SERVER_ADDR')) || empty(getenv('ALONE_SERVER_KEY'))) {
|
if (empty(getConf('server_addr', 'alone_monitor')) || empty(getConf('server_key', 'alone_monitor'))) {
|
||||||
exit('推送服务器信息不完整, 请检查配置文件!');
|
exit('推送服务器信息不完整, 请检查配置文件!');
|
||||||
}
|
}
|
||||||
if (!self::$server_addr || !self::$server_key) {
|
if (!self::$server_addr || !self::$server_key) {
|
||||||
self::$server_addr = getenv('ALONE_SERVER_ADDR');
|
self::$server_addr = getConf('server_addr', 'alone_monitor');
|
||||||
self::$server_key = getenv('ALONE_SERVER_KEY');
|
self::$server_key = getConf('server_key', 'alone_monitor');
|
||||||
}
|
}
|
||||||
if (!self::$client) {
|
if (!self::$client) {
|
||||||
self::openConnect();
|
self::openConnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 数据封装
|
* @use 数据封装
|
||||||
* @param $value
|
* @param $value
|
||||||
* @param $fmt
|
* @param $fmt
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function packMsg($value, $fmt = "N")
|
private static function packMsg($value, $fmt = "N"): string
|
||||||
{
|
{
|
||||||
$head = pack($fmt, strlen($value));
|
$head = pack($fmt, strlen($value));
|
||||||
$data = $head . $value;
|
return $head . $value;
|
||||||
return $data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,7 +114,7 @@ class AloneTcpClient
|
|||||||
/**
|
/**
|
||||||
* @use 读数据
|
* @use 读数据
|
||||||
* @param $length
|
* @param $length
|
||||||
* @return array|bool|false
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
private static function reader($length)
|
private static function reader($length)
|
||||||
{
|
{
|
||||||
@ -142,7 +139,7 @@ class AloneTcpClient
|
|||||||
* @param $data
|
* @param $data
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private static function writer($data)
|
private static function writer($data): bool
|
||||||
{
|
{
|
||||||
$status = false;
|
$status = false;
|
||||||
try {
|
try {
|
||||||
@ -157,7 +154,6 @@ class AloneTcpClient
|
|||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 打开连接
|
* @use 打开连接
|
||||||
*/
|
*/
|
||||||
@ -202,7 +198,6 @@ class AloneTcpClient
|
|||||||
self::$client = null;
|
self::$client = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 读取数据
|
* @use 读取数据
|
||||||
*/
|
*/
|
||||||
@ -260,7 +255,6 @@ class AloneTcpClient
|
|||||||
// 服务器发布命令
|
// 服务器发布命令
|
||||||
Log::error("服务器发布退出命令 {$raw_data['data']['msg']}");
|
Log::error("服务器发布退出命令 {$raw_data['data']['msg']}");
|
||||||
exit();
|
exit();
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
// 未知信息
|
// 未知信息
|
||||||
var_dump($raw_data);
|
var_dump($raw_data);
|
||||||
@ -269,7 +263,6 @@ class AloneTcpClient
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 写入log
|
* @use 写入log
|
||||||
* @param $message
|
* @param $message
|
||||||
@ -281,7 +274,7 @@ class AloneTcpClient
|
|||||||
mkdir($path);
|
mkdir($path);
|
||||||
chmod($path, 0777);
|
chmod($path, 0777);
|
||||||
}
|
}
|
||||||
$filename = $path . getenv('APP_USER') . ".log";
|
$filename = $path . getConf('username', 'login.account') . ".log";
|
||||||
$date = date('[Y-m-d H:i:s] ');
|
$date = date('[Y-m-d H:i:s] ');
|
||||||
$data = "[{$date}]{$message}" . PHP_EOL;
|
$data = "[{$date}]{$message}" . PHP_EOL;
|
||||||
file_put_contents($filename, $data, FILE_APPEND);
|
file_put_contents($filename, $data, FILE_APPEND);
|
||||||
|
|||||||
@ -12,13 +12,12 @@ namespace BiliHelper\Plugin;
|
|||||||
|
|
||||||
use BiliHelper\Core\Log;
|
use BiliHelper\Core\Log;
|
||||||
use BiliHelper\Core\Curl;
|
use BiliHelper\Core\Curl;
|
||||||
use BiliHelper\Util\TimeLock;
|
|
||||||
use BiliHelper\Util\BaseRaffle;
|
use BiliHelper\Util\BaseRaffle;
|
||||||
|
|
||||||
class AnchorRaffle extends BaseRaffle
|
class AnchorRaffle extends BaseRaffle
|
||||||
{
|
{
|
||||||
const ACTIVE_TITLE = '天选时刻';
|
const ACTIVE_TITLE = '天选时刻';
|
||||||
const ACTIVE_SWITCH = 'USE_ANCHOR';
|
const ACTIVE_SWITCH = 'live_anchor';
|
||||||
|
|
||||||
protected static $wait_list = [];
|
protected static $wait_list = [];
|
||||||
protected static $finish_list = [];
|
protected static $finish_list = [];
|
||||||
@ -62,7 +61,7 @@ class AnchorRaffle extends BaseRaffle
|
|||||||
$tags = User::fetchTags();
|
$tags = User::fetchTags();
|
||||||
$tag_id = array_search(self::$group_name, $tags);
|
$tag_id = array_search(self::$group_name, $tags);
|
||||||
// 如果不存在则调用创建
|
// 如果不存在则调用创建
|
||||||
self::$group_id = $tag_id ? $tag_id : User::createRelationTag(self::$group_name);
|
self::$group_id = $tag_id ?: User::createRelationTag(self::$group_name);
|
||||||
}
|
}
|
||||||
// 获取需要关注的
|
// 获取需要关注的
|
||||||
$data = Live::getRoomInfoV1($room_id);
|
$data = Live::getRoomInfoV1($room_id);
|
||||||
@ -102,7 +101,6 @@ class AnchorRaffle extends BaseRaffle
|
|||||||
self::$wait_un_follows = $new_list;
|
self::$wait_un_follows = $new_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取默认关注
|
* @use 获取默认关注
|
||||||
* @return array
|
* @return array
|
||||||
@ -120,7 +118,6 @@ class AnchorRaffle extends BaseRaffle
|
|||||||
return self::$default_follows;
|
return self::$default_follows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 过滤奖品
|
* @use 过滤奖品
|
||||||
* @param string $prize_name
|
* @param string $prize_name
|
||||||
@ -129,7 +126,7 @@ class AnchorRaffle extends BaseRaffle
|
|||||||
protected static function filterPrizeWords(string $prize_name): bool
|
protected static function filterPrizeWords(string $prize_name): bool
|
||||||
{
|
{
|
||||||
$default_words = self::$store->get("Anchor.default");
|
$default_words = self::$store->get("Anchor.default");
|
||||||
$custom_words = empty(getenv('ANCHOR_FILTER_WORDS')) ? [] : explode(',', getenv('ANCHOR_FILTER_WORDS'));
|
$custom_words = empty($words = getConf('filter_words', 'live_anchor')) ? [] : explode(',', $words);
|
||||||
$total_words = array_merge($default_words, $custom_words);
|
$total_words = array_merge($default_words, $custom_words);
|
||||||
foreach ($total_words as $word) {
|
foreach ($total_words as $word) {
|
||||||
if (strpos($prize_name, $word) !== false) {
|
if (strpos($prize_name, $word) !== false) {
|
||||||
@ -160,7 +157,7 @@ class AnchorRaffle extends BaseRaffle
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 过滤抽奖范围
|
// 过滤抽奖范围
|
||||||
self::$filter_type = empty(self::$filter_type) ? explode(',', getenv('ANCHOR_TYPE')) : self::$filter_type;
|
self::$filter_type = empty(self::$filter_type) ? explode(',', getConf('limit_type', 'live_anchor')) : self::$filter_type;
|
||||||
if (!in_array((string)$de_raw['require_type'], self::$filter_type)) {
|
if (!in_array((string)$de_raw['require_type'], self::$filter_type)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -173,7 +170,7 @@ class AnchorRaffle extends BaseRaffle
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 分组操作
|
// 分组操作
|
||||||
if (getenv('ANCHOR_UNFOLLOW') == 'true' && $de_raw['require_text'] == '关注主播') {
|
if (getConf('auto_unfollow', 'live_anchor') && $de_raw['require_text'] == '关注主播') {
|
||||||
self::addToGroup($room_id, $de_raw['id'], time() + $de_raw['time'] + 5);
|
self::addToGroup($room_id, $de_raw['id'], time() + $de_raw['time'] + 5);
|
||||||
}
|
}
|
||||||
// 推入列表
|
// 推入列表
|
||||||
@ -189,7 +186,6 @@ class AnchorRaffle extends BaseRaffle
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 创建抽奖任务
|
* @use 创建抽奖任务
|
||||||
* @param array $raffles
|
* @param array $raffles
|
||||||
@ -199,15 +195,13 @@ class AnchorRaffle extends BaseRaffle
|
|||||||
{
|
{
|
||||||
$url = 'https://api.live.bilibili.com/xlive/lottery-interface/v1/Anchor/Join';
|
$url = 'https://api.live.bilibili.com/xlive/lottery-interface/v1/Anchor/Join';
|
||||||
$tasks = [];
|
$tasks = [];
|
||||||
$results = [];
|
|
||||||
$user_info = User::parseCookies();
|
|
||||||
foreach ($raffles as $raffle) {
|
foreach ($raffles as $raffle) {
|
||||||
$payload = [
|
$payload = [
|
||||||
'id' => $raffle['raffle_id'],
|
'id' => $raffle['raffle_id'],
|
||||||
'roomid' => $raffle['room_id'],
|
'roomid' => $raffle['room_id'],
|
||||||
'platform' => 'pc',
|
'platform' => 'pc',
|
||||||
'csrf_token' => $user_info['token'],
|
'csrf_token' => getCsrf(),
|
||||||
'csrf' => $user_info['token'],
|
'csrf' => getCsrf(),
|
||||||
'visit_id' => ''
|
'visit_id' => ''
|
||||||
];
|
];
|
||||||
array_push($tasks, [
|
array_push($tasks, [
|
||||||
@ -219,15 +213,14 @@ class AnchorRaffle extends BaseRaffle
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$results = Curl::async('app', $url, $tasks);
|
|
||||||
// print_r($results);
|
// print_r($results);
|
||||||
return $results;
|
return Curl::async('app', $url, $tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 解析抽奖信息
|
* @use 解析抽奖信息
|
||||||
* @param array $results
|
* @param array $results
|
||||||
* @return mixed|void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected static function parseLottery(array $results)
|
protected static function parseLottery(array $results)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -25,10 +25,9 @@ class AwardRecord
|
|||||||
private static $gift_lock = 0;
|
private static $gift_lock = 0;
|
||||||
private static $gift_list = [];
|
private static $gift_list = [];
|
||||||
|
|
||||||
|
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (self::getLock() > time()) {
|
if (self::getLock() > time() || !getEnable('award_record')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (self::$anchor_lock < time()) {
|
if (self::$anchor_lock < time()) {
|
||||||
@ -43,7 +42,6 @@ class AwardRecord
|
|||||||
self::setLock(5 * 60);
|
self::setLock(5 * 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取天选时刻中奖纪录
|
* @use 获取天选时刻中奖纪录
|
||||||
*/
|
*/
|
||||||
@ -83,7 +81,7 @@ class AwardRecord
|
|||||||
}
|
}
|
||||||
if (in_array($wait_un_follow['anchor_id'], self::$anchor_list)) {
|
if (in_array($wait_un_follow['anchor_id'], self::$anchor_list)) {
|
||||||
AnchorRaffle::delToGroup($wait_un_follow['uid'], $wait_un_follow['anchor_id'], false);
|
AnchorRaffle::delToGroup($wait_un_follow['uid'], $wait_un_follow['anchor_id'], false);
|
||||||
}else{
|
} else {
|
||||||
AnchorRaffle::delToGroup($wait_un_follow['uid'], $wait_un_follow['anchor_id'], true);
|
AnchorRaffle::delToGroup($wait_un_follow['uid'], $wait_un_follow['anchor_id'], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,7 +89,6 @@ class AwardRecord
|
|||||||
self::$anchor_lock = time() + 6 * 60 * 60;
|
self::$anchor_lock = time() + 6 * 60 * 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取实物抽奖中奖纪录
|
* @use 获取实物抽奖中奖纪录
|
||||||
*/
|
*/
|
||||||
@ -129,7 +126,6 @@ class AwardRecord
|
|||||||
self::$raffle_lock = time() + 6 * 60 * 60;
|
self::$raffle_lock = time() + 6 * 60 * 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取活动礼物中奖纪录
|
* @use 获取活动礼物中奖纪录
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -20,58 +20,30 @@ class Barrage
|
|||||||
|
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (self::getLock() > time() || getenv('USE_DANMU') == 'false') {
|
if (self::getLock() > time() || !getEnable('barrage')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self::setPauseStatus();
|
self::setPauseStatus();
|
||||||
$room_id = empty(getenv('DANMU_ROOMID')) ? Live::getUserRecommend() : Live::getRealRoomID(getenv('DANMU_ROOMID'));
|
if (self::sendMsg()) {
|
||||||
$msg = empty(getenv('DANMU_CONTENT')) ? self::getMsgInfo() : getenv('DANMU_CONTENT');
|
|
||||||
|
|
||||||
$info = [
|
|
||||||
'roomid' => $room_id,
|
|
||||||
'content' => $msg,
|
|
||||||
];
|
|
||||||
|
|
||||||
if (self::privateSendMsg($info)) {
|
|
||||||
self::setLock(mt_rand(40, 80) * 60);
|
self::setLock(mt_rand(40, 80) * 60);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
self::setLock(15 * 60);
|
||||||
self::setLock(10 * 60);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取颜文字信息
|
* 获取一言api消息
|
||||||
|
* @param bool $sep
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function getEmojiMsg(): string
|
private static function getMsgInfo(bool $sep = true): string
|
||||||
{
|
|
||||||
$emoji_list = [
|
|
||||||
"(⌒▽⌒)", "( ̄▽ ̄)", "(=・ω・=)", "(`・ω・´)", "(〜 ̄△ ̄)〜", "(・∀・)",
|
|
||||||
"(°∀°)ノ", "( ̄3 ̄)", "╮( ̄▽ ̄)╭", "_(:3」∠)_", "( ´_ゝ`)", "←_←", "→_→",
|
|
||||||
"(<_<)", "(>_>)", "(;¬_¬)", '("▔□▔)/', "(゚Д゚≡゚д゚)!?", "Σ(゚д゚;)", "Σ(  ̄□ ̄||)",
|
|
||||||
"(´;ω;`)", "(/TДT)/", "(^・ω・^ )", "(。・ω・。)", "(● ̄(エ) ̄●)", "ε=ε=(ノ≧∇≦)ノ",
|
|
||||||
"(´・_・`)", "(-_-#)", "( ̄へ ̄)", "( ̄ε(# ̄) Σ", "ヽ(`Д´)ノ", "(#-_-)┯━┯",
|
|
||||||
"(╯°口°)╯(┴—┴", "←◡←", "( ♥д♥)", "Σ>―(〃°ω°〃)♡→", "⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄",
|
|
||||||
"(╬゚д゚)▄︻┻┳═一", "・*・:≡( ε:)", "(打卡)", "(签到)"
|
|
||||||
];
|
|
||||||
shuffle($emoji_list);
|
|
||||||
return $emoji_list[array_rand($emoji_list)];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @use 获取一言api消息
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private static function getMsgInfo(): string
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 整理一部分API,收集于网络,侵权麻烦联系我删除.
|
* 整理一部分API,收集于网络,侵权麻烦联系我删除.
|
||||||
* 如果设置项不能用可以选择,只保证代码发布时正常.
|
* 如果设置项不能用可以选择,只保证代码发布时正常.
|
||||||
* 格式全部为TEXT,可以自己替换.
|
* 格式全部为TEXT,可以自己替换.
|
||||||
*/
|
*/
|
||||||
$punctuations = [',', ',', '。', '!', '.', ';', '——'];
|
$punctuations = $sep ? [',', ',', '。', '!', '.', ';', '——'] : [];
|
||||||
$apis = [
|
$apis = [
|
||||||
'https://api.ly522.com/yan.php?format=text',
|
'https://api.ly522.com/yan.php?format=text',
|
||||||
'https://v1.hitokoto.cn/?encode=text',
|
'https://v1.hitokoto.cn/?encode=text',
|
||||||
@ -81,8 +53,8 @@ class Barrage
|
|||||||
'https://api.guoch.xyz/',
|
'https://api.guoch.xyz/',
|
||||||
'https://api.gushi.ci/rensheng.txt',
|
'https://api.gushi.ci/rensheng.txt',
|
||||||
'https://api.itswincer.com/hitokoto/v2/',
|
'https://api.itswincer.com/hitokoto/v2/',
|
||||||
// 'http://www.ooomg.cn/dutang/',
|
// 'http://www.ooomg.cn/dutang/',
|
||||||
// 'http://api.dsecret.com/yiyan/',
|
// 'http://api.dsecret.com/yiyan/',
|
||||||
];
|
];
|
||||||
shuffle($apis);
|
shuffle($apis);
|
||||||
try {
|
try {
|
||||||
@ -102,45 +74,23 @@ class Barrage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 弹幕通用模块
|
* @use 活跃弹幕
|
||||||
* @param $info
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private static function sendMsg($info): array
|
|
||||||
{
|
|
||||||
$user_info = User::parseCookies();
|
|
||||||
$url = 'https://api.live.bilibili.com/msg/send';
|
|
||||||
$data = Live::getRoomInfoV1($info['roomid']);
|
|
||||||
$payload = [
|
|
||||||
'color' => '16777215',
|
|
||||||
'fontsize' => 25,
|
|
||||||
'mode' => 1,
|
|
||||||
'msg' => $info['content'],
|
|
||||||
'rnd' => 0,
|
|
||||||
'roomid' => $data['data']['room_id'],
|
|
||||||
'csrf' => $user_info['token'],
|
|
||||||
'csrf_token' => $user_info['token'],
|
|
||||||
];
|
|
||||||
$raw = Curl::post('app', $url, Sign::common($payload));
|
|
||||||
return json_decode($raw, true) ?? ['code' => 404, 'msg' => '上层数据为空!'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @use 发送弹幕模块
|
|
||||||
* @param $info
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private static function privateSendMsg($info): bool
|
private static function sendMsg(): bool
|
||||||
{
|
{
|
||||||
//TODO 短期功能 有需求就修改 // todo 加入直播间
|
$room_id = empty($room_id = getConf('room_id', 'barrage')) ? Live::getUserRecommend() : Live::getRealRoomID($room_id);
|
||||||
$response = self::sendMsg($info);
|
$content = empty($msg = getConf('content', 'barrage')) ? self::getMsgInfo() : $msg;
|
||||||
if (isset($response['code']) && $response['code'] == 0) {
|
|
||||||
Log::info('弹幕发送成功');
|
$response = Live::sendBarragePC($room_id, $content);
|
||||||
|
// {"code":0,"data":[],"message":"","msg":""}
|
||||||
|
// {"code":0,"message":"你被禁言啦","msg":"你被禁言啦"}
|
||||||
|
if (isset($response['code']) && $response['code'] == 0 && isset($response['data'])) {
|
||||||
|
Log::notice("在直播间@{$room_id} 发送活跃弹幕成功 CODE -> {$response['code']}");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Log::warning("弹幕发送失败, CODE -> {$response['code']} MSG -> {$response['message']} ");
|
Log::warning("在直播间@{$room_id} 发送活跃弹幕失败 CODE -> {$response['code']} MSG -> {$response['message']} ");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
148
src/plugin/BpConsumption.php
Normal file
148
src/plugin/BpConsumption.php
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Website: https://mudew.com/
|
||||||
|
* Author: Lkeme
|
||||||
|
* License: The MIT License
|
||||||
|
* Email: Useri@live.cn
|
||||||
|
* Updated: 2021 ~ 2022
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace BiliHelper\Plugin;
|
||||||
|
|
||||||
|
use BiliHelper\Core\Curl;
|
||||||
|
use BiliHelper\Core\Log;
|
||||||
|
use BiliHelper\Tool\Common;
|
||||||
|
use BiliHelper\Util\TimeLock;
|
||||||
|
|
||||||
|
class BpConsumption
|
||||||
|
{
|
||||||
|
|
||||||
|
use TimeLock;
|
||||||
|
|
||||||
|
public static function run()
|
||||||
|
{
|
||||||
|
if (self::getLock() > time() || !getEnable('bp_consumption')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 定时14点 + 随机120分钟| 根据逻辑前置
|
||||||
|
self::setLock(self::timing(14) + mt_rand(1, 120) * 60);
|
||||||
|
|
||||||
|
// 如果为年度大会员
|
||||||
|
if (User::isYearVip()) {
|
||||||
|
// 获取B币余额
|
||||||
|
$bp_balance = self::getUserWallet();
|
||||||
|
// 最大支持5
|
||||||
|
if ($bp_balance != 5) return;
|
||||||
|
// 消费B币充电
|
||||||
|
if (getConf('bp2charge', 'bp_consumption')) {
|
||||||
|
// UID为空就切换成自己的
|
||||||
|
$uid = empty($uid = getConf('bp2charge_uid', 'bp_consumption')) ? getUid() : $uid;
|
||||||
|
self::BP2charge($uid, $bp_balance);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 消费B币充值金瓜子
|
||||||
|
if (getConf('bp2gold', 'bp_consumption')) {
|
||||||
|
self::BP2gold($bp_balance);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 获取钱包B币券余额
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private static function getUserWallet(): int
|
||||||
|
{
|
||||||
|
$url = 'https://pay.bilibili.com/paywallet/wallet/getUserWallet';
|
||||||
|
$headers = [
|
||||||
|
'Content-Type' => 'application/json;charset=utf-8',
|
||||||
|
'origin' => 'https://pay.bilibili.com',
|
||||||
|
'referer' => 'https://pay.bilibili.com/paywallet-fe/bb_balance.html'
|
||||||
|
];
|
||||||
|
$ts = Common::getMillisecond();
|
||||||
|
$payload = [
|
||||||
|
'panelType' => 3,
|
||||||
|
'platformType' => 3,
|
||||||
|
'timestamp' => $ts,
|
||||||
|
'traceId' => $ts,
|
||||||
|
'version' => "1.0",
|
||||||
|
];
|
||||||
|
$raw = Curl::put('pc', $url, $payload, $headers);
|
||||||
|
// {"errno":0,"msg":"SUCCESS","showMsg":"","errtag":0,"data":{"mid":1234,"totalBp":5.00,"defaultBp":0.00,"iosBp":0.00,"couponBalance":5.00,"availableBp":5.00,"unavailableBp":0.00,"unavailableReason":"苹果设备上充值的B币不能在其他平台的设备上进行使用","tip":null}}
|
||||||
|
$de_raw = json_decode($raw, true);
|
||||||
|
if ($de_raw['errno'] == 0 && isset($de_raw['data']['couponBalance'])) {
|
||||||
|
Log::notice('获取钱包成功 B币券余额剩余' . $de_raw['data']['couponBalance']);
|
||||||
|
return intval($de_raw['data']['couponBalance']);
|
||||||
|
} else {
|
||||||
|
Log::warning("获取钱包失败 {$raw}");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use B币充电
|
||||||
|
* @param int $uid
|
||||||
|
* @param int $num
|
||||||
|
*/
|
||||||
|
private static function BP2charge(int $uid, int $num = 5)
|
||||||
|
{
|
||||||
|
$url = 'https://api.bilibili.com/x/ugcpay/web/v2/trade/elec/pay/quick';
|
||||||
|
$payload = [
|
||||||
|
'bp_num' => $num, // 数量
|
||||||
|
'is_bp_remains_prior' => true, // 是否优先扣除B币余额
|
||||||
|
'up_mid' => $uid, // 目标UID
|
||||||
|
'otype' => 'up', // 来源 up:空间充电 archive:视频充电
|
||||||
|
'oid' => $uid, // 目标UID or 稿件avid
|
||||||
|
'csrf' => getCsrf()
|
||||||
|
];
|
||||||
|
$raw = Curl::post('pc', $url, $payload);
|
||||||
|
// {"code":0,"message":"0","ttl":1,"data":{"mid":12324,"up_mid":1234,"order_no":"ABCD","bp_num":2,"exp":2,"status":4,"msg":""}}
|
||||||
|
$de_raw = json_decode($raw, true);
|
||||||
|
if ($de_raw['code'] == 0) {
|
||||||
|
// data.status 4 成功 -2:低于20电池下限 -4:B币不足
|
||||||
|
if ($de_raw['data']['status'] == 4) {
|
||||||
|
Log::notice("给{$uid}B币充电成功 NUM -> {$de_raw['data']['elec_num']} ORDER -> {$de_raw['data']['order_no']}");
|
||||||
|
} else {
|
||||||
|
Log::warning("给{$uid}B币充电失败 STATUS -> {$de_raw['data']['status']} MSG -> {$de_raw['data']['msg']}");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log::warning("给{$uid}B币充电失败 CODE -> {$de_raw['code']} MSG -> {$de_raw['message']} ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* B币充值金瓜子
|
||||||
|
* @param int $num
|
||||||
|
*/
|
||||||
|
private static function BP2gold(int $num)
|
||||||
|
{
|
||||||
|
$url = 'https://api.live.bilibili.com/xlive/revenue/v1/order/createOrder';
|
||||||
|
$headers = [
|
||||||
|
'origin' => 'https://link.bilibili.com',
|
||||||
|
'referer' => 'https://link.bilibili.com/p/center/index'
|
||||||
|
];
|
||||||
|
$payload = [
|
||||||
|
'platform' => 'pc',
|
||||||
|
'pay_bp' => $num * 1000, // 瓜子数量
|
||||||
|
'context_id' => 1, // 直播间
|
||||||
|
'context_type' => 11,
|
||||||
|
'goods_id' => 1, // 商品ID
|
||||||
|
'goods_num' => $num, // B币数量
|
||||||
|
'csrf_token' => getCsrf(),
|
||||||
|
'csrf' => getCsrf(),
|
||||||
|
'visit_id' => '',
|
||||||
|
];
|
||||||
|
$raw = Curl::post('pc', $url, $payload, $headers);
|
||||||
|
// {"code":1300014,"message":"b币余额不足","ttl":1,"data":null}
|
||||||
|
// {"code":0,"message":"0","ttl":1,"data":{"status":2,"order_id":"1234171134577071132741234","gold":0,"bp":5000}}
|
||||||
|
$de_raw = json_decode($raw, true);
|
||||||
|
if ($de_raw['code'] == 0) {
|
||||||
|
Log::notice("B币充值金瓜子成功 NUM -> {$de_raw['data']['bp']} ORDER -> {$de_raw['data']['order_id']}");
|
||||||
|
} else {
|
||||||
|
Log::warning("B币充值金瓜子失败 CODE -> {$de_raw['code']} MSG -> {$de_raw['message']}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
@ -16,14 +16,13 @@ use BiliHelper\Core\Log;
|
|||||||
use BiliHelper\Core\Curl;
|
use BiliHelper\Core\Curl;
|
||||||
use BiliHelper\Util\TimeLock;
|
use BiliHelper\Util\TimeLock;
|
||||||
|
|
||||||
|
|
||||||
class CheckUpdate
|
class CheckUpdate
|
||||||
{
|
{
|
||||||
use TimeLock;
|
use TimeLock;
|
||||||
|
|
||||||
private static $conf;
|
private static $current_conf;
|
||||||
private static $latest_conf;
|
private static $latest_conf;
|
||||||
private static $repository = APP_DATA_PATH . 'latest.json';
|
private static $repository = APP_DATA_PATH . 'latest_version.json';
|
||||||
|
|
||||||
|
|
||||||
public static function run()
|
public static function run()
|
||||||
@ -62,10 +61,10 @@ class CheckUpdate
|
|||||||
*/
|
*/
|
||||||
private static function fetchLatest()
|
private static function fetchLatest()
|
||||||
{
|
{
|
||||||
$url = self::$conf->get('raw_url');
|
$url = self::$current_conf->get('raw_url');
|
||||||
$payload = [];
|
$payload = [];
|
||||||
$raw = Curl::get('other', $url, $payload);
|
$raw = Curl::get('other', $url, $payload);
|
||||||
self::$latest_conf = new Config($raw, new Json, true);
|
self::$latest_conf = Config::load($raw, new Json, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,7 +72,7 @@ class CheckUpdate
|
|||||||
*/
|
*/
|
||||||
private static function loadJsonData()
|
private static function loadJsonData()
|
||||||
{
|
{
|
||||||
self::$conf = new Config(self::$repository);
|
self::$current_conf = Config::load(self::$repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,7 +81,7 @@ class CheckUpdate
|
|||||||
*/
|
*/
|
||||||
private static function compareVersion(): bool
|
private static function compareVersion(): bool
|
||||||
{
|
{
|
||||||
$current_version = self::$conf->get('version');
|
$current_version = self::$current_conf->get('version');
|
||||||
$latest_version = self::$latest_conf->get('version');
|
$latest_version = self::$latest_conf->get('version');
|
||||||
// true 有更新 false 无更新
|
// true 有更新 false 无更新
|
||||||
return !($current_version == $latest_version);
|
return !($current_version == $latest_version);
|
||||||
|
|||||||
@ -23,22 +23,20 @@ class Competition
|
|||||||
*/
|
*/
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (getenv('USE_COMPETITION') == 'false' || self::getLock() > time()) {
|
if (self::getLock() > time() || !getEnable('match_forecast')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self::startStake();
|
self::startStake();
|
||||||
|
self::setLock(self::timing(1, 30));
|
||||||
self::setLock(self::timing(1,30));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 开始破产
|
* @use 开始破产
|
||||||
*/
|
*/
|
||||||
private static function startStake()
|
private static function startStake()
|
||||||
{
|
{
|
||||||
$questions = self::fetchQuestions();
|
$questions = self::fetchQuestions();
|
||||||
$max_guess = intval(getenv('COMPET_MAX_NUM'));
|
$max_guess = getConf('max_num', 'match_forecast');
|
||||||
foreach ($questions as $index => $question) {
|
foreach ($questions as $index => $question) {
|
||||||
if ($index >= $max_guess) {
|
if ($index >= $max_guess) {
|
||||||
break;
|
break;
|
||||||
@ -56,7 +54,6 @@ class Competition
|
|||||||
{
|
{
|
||||||
Log::info($guess['title']);
|
Log::info($guess['title']);
|
||||||
Log::info($guess['estimate']);
|
Log::info($guess['estimate']);
|
||||||
$user_info = User::parseCookies();
|
|
||||||
$url = 'https://api.bilibili.com/x/esports/guess/add';
|
$url = 'https://api.bilibili.com/x/esports/guess/add';
|
||||||
$payload = [
|
$payload = [
|
||||||
'oid' => $guess['oid'],
|
'oid' => $guess['oid'],
|
||||||
@ -64,7 +61,7 @@ class Competition
|
|||||||
'detail_id' => $guess['detail_id'],
|
'detail_id' => $guess['detail_id'],
|
||||||
'count' => $guess['count'],
|
'count' => $guess['count'],
|
||||||
'is_fav' => 0,
|
'is_fav' => 0,
|
||||||
'csrf' => $user_info['token']
|
'csrf' => getCsrf()
|
||||||
];
|
];
|
||||||
$headers = [
|
$headers = [
|
||||||
'origin' => 'https://www.bilibili.com',
|
'origin' => 'https://www.bilibili.com',
|
||||||
@ -80,7 +77,6 @@ class Competition
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 预计猜测结果
|
* @use 预计猜测结果
|
||||||
* @param array $question
|
* @param array $question
|
||||||
@ -92,13 +88,13 @@ class Competition
|
|||||||
$guess['oid'] = $question['contest']['id'];
|
$guess['oid'] = $question['contest']['id'];
|
||||||
$guess['main_id'] = $question['questions'][0]['id'];
|
$guess['main_id'] = $question['questions'][0]['id'];
|
||||||
$details = $question['questions'][0]['details'];
|
$details = $question['questions'][0]['details'];
|
||||||
$guess['count'] = intval(in_array(getenv('COMPET_MAX_COIN'), range(1, 10)) ? getenv('COMPET_MAX_COIN') : 10);
|
$guess['count'] = ($count = getConf('max_coin', 'match_forecast') <= 10) ? $count : 10;
|
||||||
$guess['title'] = $question['questions'][0]['title'];
|
$guess['title'] = $question['questions'][0]['title'];
|
||||||
foreach ($details as $detail) {
|
foreach ($details as $detail) {
|
||||||
$guess['title'] .= " 队伍: {$detail['option']} 赔率: {$detail['odds']}";
|
$guess['title'] .= " 队伍: {$detail['option']} 赔率: {$detail['odds']}";
|
||||||
}
|
}
|
||||||
array_multisort(array_column($details, "odds"), SORT_ASC, $details);
|
array_multisort(array_column($details, "odds"), SORT_ASC, $details);
|
||||||
switch (intval(getenv('COMPET_STAKE'))) {
|
switch (getConf('bet', 'match_forecast')) {
|
||||||
case 1:
|
case 1:
|
||||||
// 压大
|
// 压大
|
||||||
$detail = array_pop($details);
|
$detail = array_pop($details);
|
||||||
|
|||||||
@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Website: https://mudew.com/
|
|
||||||
* Author: Lkeme
|
|
||||||
* License: The MIT License
|
|
||||||
* Email: Useri@live.cn
|
|
||||||
* Updated: 2021 ~ 2022
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace BiliHelper\Plugin;
|
|
||||||
|
|
||||||
use BiliHelper\Core\Log;
|
|
||||||
use BiliHelper\Core\Curl;
|
|
||||||
use BiliHelper\Util\TimeLock;
|
|
||||||
|
|
||||||
class Daily
|
|
||||||
{
|
|
||||||
use TimeLock;
|
|
||||||
|
|
||||||
public static function run()
|
|
||||||
{
|
|
||||||
if (self::getLock() > time()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self::dailyBag();
|
|
||||||
self::setLock(8 * 60 * 60);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @use 领取每日包裹
|
|
||||||
*/
|
|
||||||
private static function dailyBag()
|
|
||||||
{
|
|
||||||
$url = 'https://api.live.bilibili.com/gift/v2/live/receive_daily_bag';
|
|
||||||
$payload = [];
|
|
||||||
$data = Curl::get('app', $url, Sign::common($payload));
|
|
||||||
$data = json_decode($data, true);
|
|
||||||
|
|
||||||
if (isset($data['code']) && $data['code']) {
|
|
||||||
Log::warning('每日礼包领取失败!', ['msg' => $data['message']]);
|
|
||||||
} else {
|
|
||||||
Log::notice('每日礼包领取成功');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
67
src/plugin/DailyBag.php
Normal file
67
src/plugin/DailyBag.php
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Website: https://mudew.com/
|
||||||
|
* Author: Lkeme
|
||||||
|
* License: The MIT License
|
||||||
|
* Email: Useri@live.cn
|
||||||
|
* Updated: 2021 ~ 2022
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace BiliHelper\Plugin;
|
||||||
|
|
||||||
|
use BiliHelper\Core\Log;
|
||||||
|
use BiliHelper\Core\Curl;
|
||||||
|
use BiliHelper\Util\TimeLock;
|
||||||
|
|
||||||
|
class DailyBag
|
||||||
|
{
|
||||||
|
use TimeLock;
|
||||||
|
|
||||||
|
public static function run()
|
||||||
|
{
|
||||||
|
if (self::getLock() > time() || !getEnable('daily_bag')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self::dailyBagPC();
|
||||||
|
self::dailyBagAPP();
|
||||||
|
self::setLock(12 * 60 * 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 领取每日包裹PC
|
||||||
|
*/
|
||||||
|
private static function dailyBagPC()
|
||||||
|
{
|
||||||
|
sleep(1);
|
||||||
|
$url = 'https://api.live.bilibili.com/gift/v2/live/receive_daily_bag';
|
||||||
|
$payload = [];
|
||||||
|
$data = Curl::get('app', $url, Sign::common($payload));
|
||||||
|
$data = json_decode($data, true);
|
||||||
|
|
||||||
|
if (isset($data['code']) && $data['code']) {
|
||||||
|
Log::warning('[PC] 日常/周常礼包领取失败', ['msg' => $data['message']]);
|
||||||
|
} else {
|
||||||
|
Log::notice('[PC] 日常/周常礼包领取成功');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 领取每日包裹APP
|
||||||
|
*/
|
||||||
|
private static function dailyBagAPP()
|
||||||
|
{
|
||||||
|
sleep(1);
|
||||||
|
$url = 'https://api.live.bilibili.com/AppBag/sendDaily';
|
||||||
|
$payload = [];
|
||||||
|
$data = Curl::get('app', $url, Sign::common($payload));
|
||||||
|
$data = json_decode($data, true);
|
||||||
|
|
||||||
|
if (isset($data['code']) && $data['code']) {
|
||||||
|
Log::warning('[APP] 日常/周常礼包领取失败', ['msg' => $data['message']]);
|
||||||
|
} else {
|
||||||
|
Log::notice('[APP] 日常/周常礼包领取成功');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -20,7 +20,7 @@ class DailyTask
|
|||||||
|
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (self::getLock() > time()) {
|
if (self::getLock() > time() || !getEnable('daily_task')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,8 +31,7 @@ class DailyTask
|
|||||||
if (isset($data['data']['sign_info'])) {
|
if (isset($data['data']['sign_info'])) {
|
||||||
self::sign_info($data['data']['sign_info']);
|
self::sign_info($data['data']['sign_info']);
|
||||||
}
|
}
|
||||||
|
self::setLock(mt_rand(8, 12) * 60 * 60);
|
||||||
self::setLock(8 * 60 * 60);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,13 +42,12 @@ class DailyTask
|
|||||||
{
|
{
|
||||||
$url = 'https://api.live.bilibili.com/i/api/taskInfo';
|
$url = 'https://api.live.bilibili.com/i/api/taskInfo';
|
||||||
$payload = [];
|
$payload = [];
|
||||||
$data = Curl::get('app',$url, Sign::common($payload));
|
$data = Curl::get('app', $url, Sign::common($payload));
|
||||||
$data = json_decode($data, true);
|
$data = json_decode($data, true);
|
||||||
Log::info('正在检查每日任务...');
|
Log::info('正在检查每日任务...');
|
||||||
if (isset($data['code']) && $data['code']) {
|
if (isset($data['code']) && $data['code']) {
|
||||||
Log::warning('每日任务检查失败!', ['msg' => $data['message']]);
|
Log::warning('每日任务检查失败!', ['msg' => $data['message']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,16 +63,22 @@ class DailyTask
|
|||||||
Log::notice('该任务已完成');
|
Log::notice('该任务已完成');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$url = 'https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign';
|
||||||
|
$headers = [
|
||||||
|
'origin' => 'https://link.bilibili.com',
|
||||||
|
'referer' => 'https://link.bilibili.com/p/center/index'
|
||||||
|
];
|
||||||
$url = 'https://api.live.bilibili.com/sign/doSign';
|
$url = 'https://api.live.bilibili.com/sign/doSign';
|
||||||
$payload = [];
|
$payload = [];
|
||||||
$data = Curl::get('app',$url, Sign::common($payload));
|
$data = Curl::get('app', $url, Sign::common($payload));
|
||||||
$data = json_decode($data, true);
|
$data = json_decode($data, true);
|
||||||
// {"code":1011040,"message":"今日已签到过,无法重复签到","ttl":1,"data":null}
|
// {"code":1011040,"message":"今日已签到过,无法重复签到","ttl":1,"data":null}
|
||||||
|
// {"code":0,"message":"0","ttl":1,"data":{"text":"3000点用户经验,2根辣条","specialText":"再签到3天可以获得666银瓜子","allDays":31,"hadSignDays":2,"isBonusDay":0}}
|
||||||
// {"code":0,"message":"0","ttl":1,"data":{"text":"3000点用户经验,2根辣条,50根辣条","specialText":"","allDays":31,"hadSignDays":20,"isBonusDay":1}}
|
// {"code":0,"message":"0","ttl":1,"data":{"text":"3000点用户经验,2根辣条,50根辣条","specialText":"","allDays":31,"hadSignDays":20,"isBonusDay":1}}
|
||||||
if (isset($data['code']) && $data['code']) {
|
if (isset($data['code']) && $data['code']) {
|
||||||
Log::warning("签到失败: {$data['message']}");
|
Log::warning("签到失败: {$data['message']}");
|
||||||
} else {
|
} else {
|
||||||
Log::info("签到成功: {$data['data']['text']}");
|
Log::notice("签到成功: {$data['data']['text']}");
|
||||||
// 推送签到信息
|
// 推送签到信息
|
||||||
Notice::push('todaySign', $data['data']['text']);
|
Notice::push('todaySign', $data['data']['text']);
|
||||||
}
|
}
|
||||||
@ -100,7 +104,7 @@ class DailyTask
|
|||||||
$payload = [
|
$payload = [
|
||||||
'task_id' => 'double_watch_task',
|
'task_id' => 'double_watch_task',
|
||||||
];
|
];
|
||||||
$data = Curl::post('app',$url, Sign::common($payload));
|
$data = Curl::post('app', $url, Sign::common($payload));
|
||||||
$data = json_decode($data, true);
|
$data = json_decode($data, true);
|
||||||
|
|
||||||
if (isset($data['code']) && $data['code']) {
|
if (isset($data['code']) && $data['code']) {
|
||||||
|
|||||||
@ -14,13 +14,13 @@ use BiliHelper\Core\Log;
|
|||||||
use BiliHelper\Core\Curl;
|
use BiliHelper\Core\Curl;
|
||||||
use BiliHelper\Util\TimeLock;
|
use BiliHelper\Util\TimeLock;
|
||||||
|
|
||||||
class Heart
|
class DoubleHeart
|
||||||
{
|
{
|
||||||
use TimeLock;
|
use TimeLock;
|
||||||
|
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (self::getLock() > time()) {
|
if (self::getLock() > time() || !getEnable('double_heart')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self::setPauseStatus();
|
self::setPauseStatus();
|
||||||
@ -36,23 +36,22 @@ class Heart
|
|||||||
{
|
{
|
||||||
User::webGetUserInfo();
|
User::webGetUserInfo();
|
||||||
$url = 'https://api.live.bilibili.com/User/userOnlineHeart';
|
$url = 'https://api.live.bilibili.com/User/userOnlineHeart';
|
||||||
$user_info = User::parseCookies();
|
|
||||||
$payload = [
|
$payload = [
|
||||||
'csrf' => $user_info['token'],
|
'csrf' => getCsrf(),
|
||||||
'csrf_token' => $user_info['token'],
|
'csrf_token' => getCsrf(),
|
||||||
'room_id' => getenv('ROOM_ID'),
|
'room_id' => getConf('room_id', 'global_room'),
|
||||||
'_' => time() * 1000,
|
'_' => time() * 1000,
|
||||||
];
|
];
|
||||||
$headers = [
|
$headers = [
|
||||||
'Referer' => 'https://live.bilibili.com/' . getenv('ROOM_ID')
|
'Referer' => 'https://live.bilibili.com/' . $payload['room_id'],
|
||||||
];
|
];
|
||||||
$data = Curl::post('app', $url, $payload, $headers);
|
$data = Curl::post('app', $url, $payload, $headers);
|
||||||
$data = json_decode($data, true);
|
$data = json_decode($data, true);
|
||||||
|
|
||||||
if (isset($data['code']) && $data['code']) {
|
if (isset($data['code']) && $data['code']) {
|
||||||
Log::warning('WEB端 发送心跳异常!', ['msg' => $data['message']]);
|
Log::warning('[PC] 发送心跳异常', ['msg' => $data['message']]);
|
||||||
} else {
|
} else {
|
||||||
Log::info('WEB端 发送心跳正常!');
|
Log::notice('[PC] 发送心跳正常');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,15 +63,15 @@ class Heart
|
|||||||
User::appGetUserInfo();
|
User::appGetUserInfo();
|
||||||
$url = 'https://api.live.bilibili.com/mobile/userOnlineHeart';
|
$url = 'https://api.live.bilibili.com/mobile/userOnlineHeart';
|
||||||
$payload = [
|
$payload = [
|
||||||
'room_id' => getenv('ROOM_ID'),
|
'room_id' => getConf('room_id', 'global_room'),
|
||||||
];
|
];
|
||||||
$data = Curl::post('app', $url, Sign::common($payload));
|
$data = Curl::post('app', $url, Sign::common($payload));
|
||||||
$data = json_decode($data, true);
|
$data = json_decode($data, true);
|
||||||
|
|
||||||
if (isset($data['code']) && $data['code']) {
|
if (isset($data['code']) && $data['code']) {
|
||||||
Log::warning('APP端 发送心跳异常!', ['msg' => $data['message']]);
|
Log::warning('[APP] 发送心跳异常', ['msg' => $data['message']]);
|
||||||
} else {
|
} else {
|
||||||
Log::info('APP端 发送心跳正常!');
|
Log::notice('[APP] 发送心跳正常');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
namespace BiliHelper\Plugin;
|
namespace BiliHelper\Plugin;
|
||||||
|
|
||||||
|
|
||||||
use BiliHelper\Core\Curl;
|
use BiliHelper\Core\Curl;
|
||||||
|
|
||||||
class Dynamic
|
class Dynamic
|
||||||
@ -26,7 +25,7 @@ class Dynamic
|
|||||||
/**
|
/**
|
||||||
* 获取抽奖话题下的帖子
|
* 获取抽奖话题下的帖子
|
||||||
*/
|
*/
|
||||||
public static function getAwardTopic()
|
public static function getAwardTopic(): array
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach (self::$topic_list as $t_id => $t_name) {
|
foreach (self::$topic_list as $t_id => $t_name) {
|
||||||
@ -53,7 +52,6 @@ class Dynamic
|
|||||||
return self::$article_list;
|
return self::$article_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 动态转发
|
* 动态转发
|
||||||
* @param $rid
|
* @param $rid
|
||||||
@ -64,12 +62,11 @@ class Dynamic
|
|||||||
* @param string $extension
|
* @param string $extension
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function dynamicRepost($rid, $content = "", $type = 1, $repost_code = 3000, $from = "create.comment", $extension = '{"emoji_type":1}')
|
public static function dynamicRepost($rid, $content = "", $type = 1, $repost_code = 3000, $from = "create.comment", $extension = '{"emoji_type":1}'): bool
|
||||||
{
|
{
|
||||||
$user_info = User::parseCookies();
|
|
||||||
$url = "https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/reply";
|
$url = "https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/reply";
|
||||||
$payload = [
|
$payload = [
|
||||||
"uid" => $user_info['uid'],
|
"uid" => getUid(),
|
||||||
"rid" => $rid,
|
"rid" => $rid,
|
||||||
"type" => $type,
|
"type" => $type,
|
||||||
"content" => $content,
|
"content" => $content,
|
||||||
@ -85,7 +82,6 @@ class Dynamic
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发表评论
|
* 发表评论
|
||||||
* @param int $rid
|
* @param int $rid
|
||||||
@ -94,16 +90,15 @@ class Dynamic
|
|||||||
* @param int $plat
|
* @param int $plat
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function dynamicReplyAdd($rid, $message = "", $type = 11, $plat = 1)
|
public static function dynamicReplyAdd(int $rid, $message = "", $type = 11, $plat = 1): bool
|
||||||
{
|
{
|
||||||
$user_info = User::parseCookies();
|
|
||||||
$url = "https://api.bilibili.com/x/v2/reply/add";
|
$url = "https://api.bilibili.com/x/v2/reply/add";
|
||||||
$payload = [
|
$payload = [
|
||||||
"oid" => $rid,
|
"oid" => $rid,
|
||||||
"plat" => $plat,
|
"plat" => $plat,
|
||||||
"type" => $type,
|
"type" => $type,
|
||||||
"message" => $message,
|
"message" => $message,
|
||||||
"csrf" => $user_info['token'],
|
"csrf" => getCsrf(),
|
||||||
];
|
];
|
||||||
$raw = Curl::post('app', $url, $payload);
|
$raw = Curl::post('app', $url, $payload);
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
@ -113,19 +108,17 @@ class Dynamic
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除指定动态
|
* 删除指定动态
|
||||||
* @param $did
|
* @param $did
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function removeDynamic($did)
|
public static function removeDynamic($did): bool
|
||||||
{
|
{
|
||||||
$user_info = User::parseCookies();
|
|
||||||
$url = 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/rm_dynamic';
|
$url = 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/rm_dynamic';
|
||||||
$payload = [
|
$payload = [
|
||||||
"dynamic_id" => $did,
|
"dynamic_id" => $did,
|
||||||
"csrf_token" => $user_info['token'],
|
"csrf_token" => getCsrf(),
|
||||||
];
|
];
|
||||||
$raw = Curl::post('app', $url, $payload);
|
$raw = Curl::post('app', $url, $payload);
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
@ -135,16 +128,14 @@ class Dynamic
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取个人发布的动态
|
* 获取个人发布的动态
|
||||||
* @param int $uid
|
* @param int $uid
|
||||||
* @return mixed
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getMyDynamic($uid = 0)
|
public static function getMyDynamic($uid = 0): array
|
||||||
{
|
{
|
||||||
$user_info = User::parseCookies();
|
$uid = $uid == 0 ? getUid() : $uid;
|
||||||
$uid = $uid == 0 ? $user_info['uid'] : $uid;
|
|
||||||
$url = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history";
|
$url = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history";
|
||||||
$offset = '';
|
$offset = '';
|
||||||
$has_more = true;
|
$has_more = true;
|
||||||
@ -185,7 +176,6 @@ class Dynamic
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取抽奖动态信息
|
* 获取抽奖动态信息
|
||||||
* @param $did
|
* @param $did
|
||||||
@ -209,8 +199,7 @@ class Dynamic
|
|||||||
*/
|
*/
|
||||||
public static function getDynamicTab($uid = 0, $type_list = 268435455)
|
public static function getDynamicTab($uid = 0, $type_list = 268435455)
|
||||||
{
|
{
|
||||||
$user_info = User::parseCookies();
|
$uid = $uid == 0 ? getUid() : $uid;
|
||||||
$uid = $uid == 0 ? $user_info['uid'] : $uid;
|
|
||||||
$url = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new";
|
$url = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new";
|
||||||
$offset = '';
|
$offset = '';
|
||||||
$has_more = true;
|
$has_more = true;
|
||||||
|
|||||||
@ -12,16 +12,13 @@
|
|||||||
* @Blog http://blog.jianxiaodai.com
|
* @Blog http://blog.jianxiaodai.com
|
||||||
* @author 菜如狗怎么了
|
* @author 菜如狗怎么了
|
||||||
* @date 2020-12
|
* @date 2020-12
|
||||||
*/
|
*
|
||||||
|
|
||||||
/**
|
|
||||||
* 2021-3-14 FEAT:增加自动回复语言更改
|
* 2021-3-14 FEAT:增加自动回复语言更改
|
||||||
* @author:zymooll
|
* @author:zymooll
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace BiliHelper\Plugin;
|
namespace BiliHelper\Plugin;
|
||||||
|
|
||||||
|
|
||||||
use BiliHelper\Core\Log;
|
use BiliHelper\Core\Log;
|
||||||
use BiliHelper\Util\TimeLock;
|
use BiliHelper\Util\TimeLock;
|
||||||
|
|
||||||
@ -60,22 +57,22 @@ class Forward
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function start()
|
public static function start(): bool
|
||||||
{
|
{
|
||||||
//更改自动回复
|
//更改自动回复
|
||||||
if (getenv('AUTO_REPLY_TEXT') != self::$msg) {
|
if (getConf('auto_reply_text', 'dynamic') != self::$msg) {
|
||||||
self::changeReply();
|
self::changeReply();
|
||||||
}
|
}
|
||||||
// 取关未中奖
|
// 取关未中奖
|
||||||
if (getenv('CLEAR_DYNAMIC') == 'true') {
|
if (getConf('clear_group_follow', 'dynamic')) {
|
||||||
self::clearDynamic();
|
self::clearDynamic();
|
||||||
}
|
}
|
||||||
// 自动转发关注评论
|
// 自动转发关注评论
|
||||||
if (getenv('AUTO_DYNAMIC') == 'true') {
|
if (getConf('enable', 'dynamic')) {
|
||||||
self::autoRepost();
|
self::autoRepost();
|
||||||
}
|
}
|
||||||
// 强制清除抽奖关注组
|
// 强制清除抽奖关注组
|
||||||
if (getenv('CLEAR_GROUP_FOLLOW') == 'true') {
|
if (getConf('clear_group_follow', 'dynamic')) {
|
||||||
self::clearAllDynamic();
|
self::clearAllDynamic();
|
||||||
self::clearFollowGroup();
|
self::clearFollowGroup();
|
||||||
}
|
}
|
||||||
@ -87,7 +84,7 @@ class Forward
|
|||||||
*/
|
*/
|
||||||
public static function changeReply()
|
public static function changeReply()
|
||||||
{
|
{
|
||||||
self::$msg = getenv('AUTO_REPLY_TEXT');
|
self::$msg = getConf('auto_reply_text', 'dynamic');
|
||||||
$msg = self::$msg;
|
$msg = self::$msg;
|
||||||
Log::info("已将自动回复改为\"{$msg}\"");
|
Log::info("已将自动回复改为\"{$msg}\"");
|
||||||
}
|
}
|
||||||
@ -121,7 +118,6 @@ class Forward
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清理无效的动态
|
* 清理无效的动态
|
||||||
*/
|
*/
|
||||||
@ -198,6 +194,9 @@ class Forward
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 取关
|
||||||
|
*/
|
||||||
private static function clearFollowGroup()
|
private static function clearFollowGroup()
|
||||||
{
|
{
|
||||||
$tags = User::fetchTags();
|
$tags = User::fetchTags();
|
||||||
@ -214,6 +213,9 @@ class Forward
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 清理动态
|
||||||
|
*/
|
||||||
private static function clearAllDynamic()
|
private static function clearAllDynamic()
|
||||||
{
|
{
|
||||||
$dynamicList = Dynamic::getMyDynamic();
|
$dynamicList = Dynamic::getMyDynamic();
|
||||||
@ -227,7 +229,6 @@ class Forward
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 添加分组
|
* @use 添加分组
|
||||||
* @param int $need_follow_uid
|
* @param int $need_follow_uid
|
||||||
@ -256,7 +257,7 @@ class Forward
|
|||||||
* @use 获取默认关注
|
* @use 获取默认关注
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private static function getDefaultFollows()
|
private static function getDefaultFollows(): array
|
||||||
{
|
{
|
||||||
if (!empty(self::$default_follows)) {
|
if (!empty(self::$default_follows)) {
|
||||||
return self::$default_follows;
|
return self::$default_follows;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -20,7 +20,7 @@ class GiftHeart
|
|||||||
|
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (self::getLock() > time()) {
|
if (self::getLock() > time() || !getEnable('gift_heart')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self::setPauseStatus();
|
self::setPauseStatus();
|
||||||
@ -31,7 +31,6 @@ class GiftHeart
|
|||||||
self::setLock(5 * 60);
|
self::setLock(5 * 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 礼物心跳
|
* @use 礼物心跳
|
||||||
* @return bool
|
* @return bool
|
||||||
@ -40,7 +39,7 @@ class GiftHeart
|
|||||||
{
|
{
|
||||||
$url = 'https://api.live.bilibili.com/gift/v2/live/heart_gift_receive';
|
$url = 'https://api.live.bilibili.com/gift/v2/live/heart_gift_receive';
|
||||||
$payload = [
|
$payload = [
|
||||||
'roomid' => getenv('ROOM_ID'),
|
'roomid' => getConf('room_id', 'global_room'),
|
||||||
];
|
];
|
||||||
$raw = Curl::get('app', $url, Sign::common($payload));
|
$raw = Curl::get('app', $url, Sign::common($payload));
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
|
|||||||
@ -12,13 +12,12 @@ namespace BiliHelper\Plugin;
|
|||||||
|
|
||||||
use BiliHelper\Core\Log;
|
use BiliHelper\Core\Log;
|
||||||
use BiliHelper\Core\Curl;
|
use BiliHelper\Core\Curl;
|
||||||
use BiliHelper\Util\TimeLock;
|
|
||||||
use BiliHelper\Util\BaseRaffle;
|
use BiliHelper\Util\BaseRaffle;
|
||||||
|
|
||||||
class GiftRaffle extends BaseRaffle
|
class GiftRaffle extends BaseRaffle
|
||||||
{
|
{
|
||||||
const ACTIVE_TITLE = '活动礼物';
|
const ACTIVE_TITLE = '活动礼物';
|
||||||
const ACTIVE_SWITCH = 'USE_ACTIVE';
|
const ACTIVE_SWITCH = 'live_gift';
|
||||||
|
|
||||||
protected static $wait_list = [];
|
protected static $wait_list = [];
|
||||||
protected static $finish_list = [];
|
protected static $finish_list = [];
|
||||||
@ -62,7 +61,6 @@ class GiftRaffle extends BaseRaffle
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 创建抽奖任务
|
* @use 创建抽奖任务
|
||||||
* @param array $raffles
|
* @param array $raffles
|
||||||
@ -75,15 +73,13 @@ class GiftRaffle extends BaseRaffle
|
|||||||
// $url = 'https://api.live.bilibili.com/gift/v4/smalltv/getAward';
|
// $url = 'https://api.live.bilibili.com/gift/v4/smalltv/getAward';
|
||||||
$url = 'https://api.live.bilibili.com/xlive/lottery-interface/v5/smalltv/join';
|
$url = 'https://api.live.bilibili.com/xlive/lottery-interface/v5/smalltv/join';
|
||||||
$tasks = [];
|
$tasks = [];
|
||||||
$results = [];
|
|
||||||
$user_info = User::parseCookies();
|
|
||||||
foreach ($raffles as $raffle) {
|
foreach ($raffles as $raffle) {
|
||||||
$payload = [
|
$payload = [
|
||||||
'id' => $raffle['raffle_id'],
|
'id' => $raffle['raffle_id'],
|
||||||
'roomid' => $raffle['room_id'],
|
'roomid' => $raffle['room_id'],
|
||||||
'type' => $raffle['type'],
|
'type' => $raffle['type'],
|
||||||
'csrf_token' => $user_info['token'],
|
'csrf_token' => getCsrf(),
|
||||||
'csrf' => $user_info['token'],
|
'csrf' => getCsrf(),
|
||||||
'visit_id' => ''
|
'visit_id' => ''
|
||||||
];
|
];
|
||||||
array_push($tasks, [
|
array_push($tasks, [
|
||||||
@ -95,15 +91,14 @@ class GiftRaffle extends BaseRaffle
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$results = Curl::async('app', $url, $tasks);
|
|
||||||
// print_r($results);
|
// print_r($results);
|
||||||
return $results;
|
return Curl::async('app', $url, $tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 解析抽奖信息
|
* @use 解析抽奖信息
|
||||||
* @param array $results
|
* @param array $results
|
||||||
* @return mixed|void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected static function parseLottery(array $results)
|
protected static function parseLottery(array $results)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
namespace BiliHelper\Plugin;
|
namespace BiliHelper\Plugin;
|
||||||
|
|
||||||
|
|
||||||
use BiliHelper\Core\Log;
|
use BiliHelper\Core\Log;
|
||||||
use BiliHelper\Core\Curl;
|
use BiliHelper\Core\Curl;
|
||||||
use BiliHelper\Util\TimeLock;
|
use BiliHelper\Util\TimeLock;
|
||||||
@ -51,11 +50,10 @@ class GiftSend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 方案1
|
* @use 方案1
|
||||||
*/
|
*/
|
||||||
protected static function procOne()
|
protected static function procOne(): bool
|
||||||
{
|
{
|
||||||
if (!self::setTargetList()) {
|
if (!self::setTargetList()) {
|
||||||
return false;
|
return false;
|
||||||
@ -63,7 +61,7 @@ class GiftSend
|
|||||||
self::getMedalList();
|
self::getMedalList();
|
||||||
foreach (self::$medal_list as $room_id => $total_intimacy) {
|
foreach (self::$medal_list as $room_id => $total_intimacy) {
|
||||||
$bag_list = self::fetchBagList();
|
$bag_list = self::fetchBagList();
|
||||||
if (getenv('FEED_FILL') == 'false') {
|
if (!getConf('feed_fill', 'intimacy')) {
|
||||||
$bag_list = self::checkExpireGift($bag_list);
|
$bag_list = self::checkExpireGift($bag_list);
|
||||||
}
|
}
|
||||||
if (count($bag_list)) {
|
if (count($bag_list)) {
|
||||||
@ -116,13 +114,12 @@ class GiftSend
|
|||||||
*/
|
*/
|
||||||
protected static function setTargetList(): bool
|
protected static function setTargetList(): bool
|
||||||
{
|
{
|
||||||
$temp = empty(getenv('ROOM_LIST')) ? null : getenv('ROOM_LIST');
|
$temp = empty($temp = getConf('room_list', 'intimacy')) ? null : $temp;
|
||||||
if (is_null($temp)) return false;
|
if (is_null($temp)) return false;
|
||||||
self::$room_list = explode(',', getenv('ROOM_LIST'));
|
self::$room_list = explode(',', $temp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取背包列表
|
* @use 获取背包列表
|
||||||
* @return array
|
* @return array
|
||||||
@ -156,7 +153,6 @@ class GiftSend
|
|||||||
return $new_bag_list;
|
return $new_bag_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 查找过期礼物
|
* @use 查找过期礼物
|
||||||
* @param array $bag_list
|
* @param array $bag_list
|
||||||
@ -173,7 +169,6 @@ class GiftSend
|
|||||||
return $expire_gift_list;
|
return $expire_gift_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取勋章列表(过滤无勋章或已满)
|
* @use 获取勋章列表(过滤无勋章或已满)
|
||||||
*/
|
*/
|
||||||
@ -200,7 +195,6 @@ class GiftSend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取UID
|
* @use 获取UID
|
||||||
*/
|
*/
|
||||||
@ -225,7 +219,7 @@ class GiftSend
|
|||||||
protected static function getRoomInfo()
|
protected static function getRoomInfo()
|
||||||
{
|
{
|
||||||
Log::info('正在生成直播间信息...');
|
Log::info('正在生成直播间信息...');
|
||||||
$room_id = empty(self::$tid) ? getenv('ROOM_ID') : self::$tid;
|
$room_id = empty(self::$tid) ? getConf('room_id', 'global_room') : self::$tid;
|
||||||
$data = Live::getRoomInfoV1($room_id);
|
$data = Live::getRoomInfoV1($room_id);
|
||||||
if (isset($data['code']) && $data['code']) {
|
if (isset($data['code']) && $data['code']) {
|
||||||
Log::warning('获取主播房间号失败!', ['msg' => $data['message']]);
|
Log::warning('获取主播房间号失败!', ['msg' => $data['message']]);
|
||||||
@ -239,7 +233,6 @@ class GiftSend
|
|||||||
self::$short_id = $data['data']['short_id'] ? (string)$data['data']['short_id'] : self::$room_id;
|
self::$short_id = $data['data']['short_id'] ? (string)$data['data']['short_id'] : self::$room_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 计算赠送数量
|
* @use 计算赠送数量
|
||||||
* @param array $gift
|
* @param array $gift
|
||||||
@ -258,7 +251,6 @@ class GiftSend
|
|||||||
return ($amt < 1) ? 1 : $amt;
|
return ($amt < 1) ? 1 : $amt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 赠送礼物
|
* @use 赠送礼物
|
||||||
* @param array $value
|
* @param array $value
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class GroupSignIn
|
|||||||
|
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (self::getLock() > time()) {
|
if (self::getLock() > time() || !getEnable('love_club')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,10 +34,9 @@ class GroupSignIn
|
|||||||
self::signInGroup($group);
|
self::signInGroup($group);
|
||||||
}
|
}
|
||||||
|
|
||||||
self::setLock(8 * 60 * 60);
|
self::setLock(mt_rand(8, 12) * 60 * 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取友爱社列表
|
* @use 获取友爱社列表
|
||||||
* @return array
|
* @return array
|
||||||
@ -50,13 +49,12 @@ class GroupSignIn
|
|||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
|
|
||||||
if (empty($de_raw['data']['list'])) {
|
if (empty($de_raw['data']['list'])) {
|
||||||
Log::notice('你没有需要签到的应援团!');
|
Log::warning('你没有需要签到的应援团!');
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return $de_raw['data']['list'];
|
return $de_raw['data']['list'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 签到
|
* @use 签到
|
||||||
* @param array $groupInfo
|
* @param array $groupInfo
|
||||||
@ -73,14 +71,15 @@ class GroupSignIn
|
|||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
|
|
||||||
if ($de_raw['code'] != '0') {
|
if ($de_raw['code'] != '0') {
|
||||||
Log::warning('在应援团{' . $groupInfo['group_name'] . '}中签到失败, 原因待查');
|
|
||||||
// TODO 任务失败原因
|
// TODO 任务失败原因
|
||||||
|
print_r($de_raw);
|
||||||
|
Log::warning('在应援团{' . $groupInfo['group_name'] . '}中签到失败, 原因待查');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($de_raw['data']['status'] == '0') {
|
if ($de_raw['data']['status'] == '0') {
|
||||||
Log::info('在应援团{' . $groupInfo['group_name'] . '}中签到成功,增加{' . $de_raw['data']['add_num'] . '点}亲密度');
|
Log::notice('在应援团{' . $groupInfo['group_name'] . '}中签到成功,增加{' . $de_raw['data']['add_num'] . '点}亲密度');
|
||||||
} else {
|
} else {
|
||||||
Log::notice('在应援团{' . $groupInfo['group_name'] . '}中不要重复签到');
|
Log::warning('在应援团{' . $groupInfo['group_name'] . '}中不要重复签到');
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -12,19 +12,17 @@ namespace BiliHelper\Plugin;
|
|||||||
|
|
||||||
use BiliHelper\Core\Log;
|
use BiliHelper\Core\Log;
|
||||||
use BiliHelper\Core\Curl;
|
use BiliHelper\Core\Curl;
|
||||||
use BiliHelper\Util\TimeLock;
|
|
||||||
use BiliHelper\Util\BaseRaffle;
|
use BiliHelper\Util\BaseRaffle;
|
||||||
|
|
||||||
class GuardRaffle extends BaseRaffle
|
class GuardRaffle extends BaseRaffle
|
||||||
{
|
{
|
||||||
const ACTIVE_TITLE = '总督舰长';
|
const ACTIVE_TITLE = '总督舰长';
|
||||||
const ACTIVE_SWITCH = 'USE_GUARD';
|
const ACTIVE_SWITCH = 'live_guard';
|
||||||
|
|
||||||
protected static $wait_list = [];
|
protected static $wait_list = [];
|
||||||
protected static $finish_list = [];
|
protected static $finish_list = [];
|
||||||
protected static $all_list = [];
|
protected static $all_list = [];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 解析数据
|
* @use 解析数据
|
||||||
* @param int $room_id
|
* @param int $room_id
|
||||||
@ -80,7 +78,6 @@ class GuardRaffle extends BaseRaffle
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 创建抽奖任务
|
* @use 创建抽奖任务
|
||||||
* @param array $raffles
|
* @param array $raffles
|
||||||
@ -90,15 +87,13 @@ class GuardRaffle extends BaseRaffle
|
|||||||
{
|
{
|
||||||
$url = 'https://api.live.bilibili.com/xlive/lottery-interface/v3/guard/join';
|
$url = 'https://api.live.bilibili.com/xlive/lottery-interface/v3/guard/join';
|
||||||
$tasks = [];
|
$tasks = [];
|
||||||
$results = [];
|
|
||||||
$user_info = User::parseCookies();
|
|
||||||
foreach ($raffles as $raffle) {
|
foreach ($raffles as $raffle) {
|
||||||
$payload = [
|
$payload = [
|
||||||
'id' => $raffle['raffle_id'],
|
'id' => $raffle['raffle_id'],
|
||||||
'roomid' => $raffle['room_id'],
|
'roomid' => $raffle['room_id'],
|
||||||
"type" => "guard",
|
"type" => "guard",
|
||||||
'csrf_token' => $user_info['token'],
|
'csrf_token' => getCsrf(),
|
||||||
'csrf' => $user_info['token'],
|
'csrf' => getCsrf(),
|
||||||
'visit_id' => ''
|
'visit_id' => ''
|
||||||
];
|
];
|
||||||
array_push($tasks, [
|
array_push($tasks, [
|
||||||
@ -110,15 +105,14 @@ class GuardRaffle extends BaseRaffle
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$results = Curl::async('app', $url, $tasks);
|
|
||||||
// print_r($results);
|
// print_r($results);
|
||||||
return $results;
|
return Curl::async('app', $url, $tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 解析抽奖信息
|
* @use 解析抽奖信息
|
||||||
* @param array $results
|
* @param array $results
|
||||||
* @return mixed|void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected static function parseLottery(array $results)
|
protected static function parseLottery(array $results)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -26,11 +26,11 @@ class Judge
|
|||||||
|
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (self::getLock() > time() || self::$retry_time > time() || getenv('USE_JUDGE') == 'false') {
|
// https://www.bilibili.com/judgement/index
|
||||||
|
if (self::getLock() > time() || self::$retry_time > time() || !getEnable('judgement')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
# https://www.bilibili.com/judgement/index
|
$case_id = self::$wait_case_id ?: self::caseObtain();
|
||||||
$case_id = self::$wait_case_id ? self::$wait_case_id : self::caseObtain();
|
|
||||||
if (!self::judgeCase($case_id)) {
|
if (!self::judgeCase($case_id)) {
|
||||||
self::setLock(1 * 60 + 5);
|
self::setLock(1 * 60 + 5);
|
||||||
return;
|
return;
|
||||||
@ -44,7 +44,7 @@ class Judge
|
|||||||
* @param $case_id
|
* @param $case_id
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private static function judgeCase($case_id)
|
private static function judgeCase($case_id): bool
|
||||||
{
|
{
|
||||||
if (is_null($case_id) || $case_id == 0) {
|
if (is_null($case_id) || $case_id == 0) {
|
||||||
return true;
|
return true;
|
||||||
@ -95,7 +95,7 @@ class Judge
|
|||||||
* @param $pct
|
* @param $pct
|
||||||
* @return int|null
|
* @return int|null
|
||||||
*/
|
*/
|
||||||
private static function judgeAdvice($num_judged, $pct)
|
private static function judgeAdvice($num_judged, $pct): ?int
|
||||||
{
|
{
|
||||||
if ($num_judged >= 300) {
|
if ($num_judged >= 300) {
|
||||||
# 认为这里可能出现了较多分歧,抬一手
|
# 认为这里可能出现了较多分歧,抬一手
|
||||||
@ -137,8 +137,7 @@ class Judge
|
|||||||
*/
|
*/
|
||||||
private static function juryVote($case_id, $decision)
|
private static function juryVote($case_id, $decision)
|
||||||
{
|
{
|
||||||
$user_info = User::parseCookies();
|
$url = 'https://api.bilibili.com/x/credit/jury/vote';
|
||||||
$url = 'http://api.bilibili.com/x/credit/jury/vote';
|
|
||||||
$payload = [
|
$payload = [
|
||||||
"jsonp" => "jsonp",
|
"jsonp" => "jsonp",
|
||||||
"cid" => $case_id,
|
"cid" => $case_id,
|
||||||
@ -147,7 +146,7 @@ class Judge
|
|||||||
"likes" => "",
|
"likes" => "",
|
||||||
"hates" => "",
|
"hates" => "",
|
||||||
"attr" => "1",
|
"attr" => "1",
|
||||||
"csrf" => $user_info['token'],
|
"csrf" => getCsrf(),
|
||||||
];
|
];
|
||||||
$raw = Curl::post('pc', $url, $payload);
|
$raw = Curl::post('pc', $url, $payload);
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
@ -158,18 +157,16 @@ class Judge
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 案件获取
|
* @use 案件获取
|
||||||
* @return |null
|
* @return mixed|null
|
||||||
*/
|
*/
|
||||||
private static function caseObtain()
|
private static function caseObtain()
|
||||||
{
|
{
|
||||||
$user_info = User::parseCookies();
|
$url = 'https://api.bilibili.com/x/credit/jury/caseObtain';
|
||||||
$url = 'http://api.bilibili.com/x/credit/jury/caseObtain';
|
|
||||||
$payload = [
|
$payload = [
|
||||||
"jsonp" => "jsonp",
|
"jsonp" => "jsonp",
|
||||||
"csrf" => $user_info['token']
|
"csrf" => getCsrf()
|
||||||
];
|
];
|
||||||
$raw = Curl::post('pc', $url, $payload);
|
$raw = Curl::post('pc', $url, $payload);
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
@ -196,7 +193,7 @@ class Judge
|
|||||||
* @param $case_id
|
* @param $case_id
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private static function judgementVote($case_id)
|
private static function judgementVote($case_id): array
|
||||||
{
|
{
|
||||||
$url = 'https://api.bilibili.com/x/credit/jury/juryCase';
|
$url = 'https://api.bilibili.com/x/credit/jury/juryCase';
|
||||||
$headers = [
|
$headers = [
|
||||||
@ -227,6 +224,31 @@ class Judge
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 随机整数
|
||||||
|
* @param int $max
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private static function randInt(int $max = 17): string
|
||||||
|
{
|
||||||
|
$temp = [];
|
||||||
|
foreach (range(1, $max) as $_) {
|
||||||
|
array_push($temp, mt_rand(0, 9));
|
||||||
|
}
|
||||||
|
return implode("", $temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 初始化参数
|
||||||
|
*/
|
||||||
|
private static function initParams()
|
||||||
|
{
|
||||||
|
self::$retry_time = 0;
|
||||||
|
self::$wait_case_id = 0;
|
||||||
|
self::$wait_time = 0;
|
||||||
|
self::$min_ok_pct = 1;
|
||||||
|
self::$max_ok_pct = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取案例数据|风纪检测
|
* @use 获取案例数据|风纪检测
|
||||||
@ -273,31 +295,4 @@ class Judge
|
|||||||
Log::info("今日投票{$sum_cases}({$valid_cases}票有效(非弃权),{$judging_cases}票还在进行中)");
|
Log::info("今日投票{$sum_cases}({$valid_cases}票有效(非弃权),{$judging_cases}票还在进行中)");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @use 随机整数
|
|
||||||
* @param int $max
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private static function randInt(int $max = 17): string
|
|
||||||
{
|
|
||||||
$temp = [];
|
|
||||||
foreach (range(1, $max) as $index) {
|
|
||||||
array_push($temp, mt_rand(0, 9));
|
|
||||||
}
|
|
||||||
return implode("", $temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @use 初始化参数
|
|
||||||
*/
|
|
||||||
private static function initParams()
|
|
||||||
{
|
|
||||||
self::$retry_time = 0;
|
|
||||||
self::$wait_case_id = 0;
|
|
||||||
self::$wait_time = 0;
|
|
||||||
self::$min_ok_pct = 1;
|
|
||||||
self::$max_ok_pct = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -41,7 +41,6 @@ class Live
|
|||||||
return $areas;
|
return $areas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use AREA_ID转ROOM_ID
|
* @use AREA_ID转ROOM_ID
|
||||||
* @param $area_id
|
* @param $area_id
|
||||||
@ -77,7 +76,6 @@ class Live
|
|||||||
return $area_info;
|
return $area_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取随机直播房间号
|
* @use 获取随机直播房间号
|
||||||
* @return int
|
* @return int
|
||||||
@ -93,19 +91,19 @@ class Live
|
|||||||
];
|
];
|
||||||
$raw = Curl::get('other', $url, $payload);
|
$raw = Curl::get('other', $url, $payload);
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
|
print_r($de_raw);
|
||||||
if ($de_raw['code'] != '0') {
|
if ($de_raw['code'] != '0') {
|
||||||
return 23058;
|
return 23058;
|
||||||
}
|
}
|
||||||
return $de_raw['data'][mt_rand(1, 29)]['roomid'];
|
return $de_raw['data'][mt_rand(1, 29)]['roomid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取直播房间号
|
* @use 获取直播房间号
|
||||||
* @param $room_id
|
* @param $room_id
|
||||||
* @return bool
|
* @return false|mixed
|
||||||
*/
|
*/
|
||||||
public static function getRealRoomID($room_id): bool
|
public static function getRealRoomID($room_id)
|
||||||
{
|
{
|
||||||
$data = self::getRoomInfoV1($room_id);
|
$data = self::getRoomInfoV1($room_id);
|
||||||
if (!isset($data['code']) || !isset($data['data'])) {
|
if (!isset($data['code']) || !isset($data['data'])) {
|
||||||
@ -174,7 +172,6 @@ class Live
|
|||||||
return json_decode($raw, true);
|
return json_decode($raw, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取配置信息
|
* @use 获取配置信息
|
||||||
* @param $room_id
|
* @param $room_id
|
||||||
@ -187,11 +184,11 @@ class Live
|
|||||||
$server = $data['data']['host_server_list'][0];
|
$server = $data['data']['host_server_list'][0];
|
||||||
$addr = "tcp://{$server['host']}:{$server['port']}/sub";
|
$addr = "tcp://{$server['host']}:{$server['port']}/sub";
|
||||||
} else {
|
} else {
|
||||||
$addr = getenv('ZONE_SERVER_ADDR');
|
$addr = getConf('server_addr', 'zone_monitor');
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
'addr' => $addr,
|
'addr' => $addr,
|
||||||
'token' => isset($data['data']['token']) ? $data['data']['token'] : '',
|
'token' => $data['data']['token'] ?? '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +220,6 @@ class Live
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 访问直播间
|
* @use 访问直播间
|
||||||
* @param $room_id
|
* @param $room_id
|
||||||
@ -240,27 +236,18 @@ class Live
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取毫秒
|
* @use 发送弹幕pc
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public static function getMillisecond(): float
|
|
||||||
{
|
|
||||||
list($t1, $t2) = explode(' ', microtime());
|
|
||||||
return (float)sprintf('%.0f', (floatval($t1) + floatval($t2)) * 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @use 发送弹幕
|
|
||||||
* @param int $room_id
|
* @param int $room_id
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function sendBarrage(int $room_id, string $content): array
|
public static function sendBarragePC(int $room_id, string $content): array
|
||||||
{
|
{
|
||||||
$user_info = User::parseCookies();
|
$room_id = self::getRealRoomID($room_id);
|
||||||
|
if (!$room_id) {
|
||||||
|
return ['code' => 404, 'msg' => '直播间数据异常'];
|
||||||
|
}
|
||||||
$url = 'https://api.live.bilibili.com/msg/send';
|
$url = 'https://api.live.bilibili.com/msg/send';
|
||||||
$payload = [
|
$payload = [
|
||||||
'color' => '16777215',
|
'color' => '16777215',
|
||||||
@ -270,17 +257,44 @@ class Live
|
|||||||
'rnd' => 0,
|
'rnd' => 0,
|
||||||
'bubble' => 0,
|
'bubble' => 0,
|
||||||
'roomid' => $room_id,
|
'roomid' => $room_id,
|
||||||
'csrf' => $user_info['token'],
|
'csrf' => getCsrf(),
|
||||||
'csrf_token' => $user_info['token'],
|
'csrf_token' => getCsrf(),
|
||||||
];
|
];
|
||||||
$headers = [
|
$headers = [
|
||||||
'origin' => 'https://live.bilibili.com',
|
'origin' => 'https://live.bilibili.com',
|
||||||
'referer' => "https://live.bilibili.com/{$room_id}"
|
'referer' => "https://live.bilibili.com/{$room_id}"
|
||||||
];
|
];
|
||||||
$raw = Curl::post('pc', $url, $payload, $headers);
|
$raw = Curl::post('pc', $url, $payload, $headers);
|
||||||
|
// {"code":0,"data":[],"message":"","msg":""}
|
||||||
return json_decode($raw, true) ?? ['code' => 404, 'msg' => '上层数据为空!'];
|
return json_decode($raw, true) ?? ['code' => 404, 'msg' => '上层数据为空!'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 发送弹幕app
|
||||||
|
* @param int $room_id
|
||||||
|
* @param string $content
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function sendBarrageAPP(int $room_id, string $content): array
|
||||||
|
{
|
||||||
|
$room_id = self::getRealRoomID($room_id);
|
||||||
|
if (!$room_id) {
|
||||||
|
return ['code' => 404, 'msg' => '直播间数据异常'];
|
||||||
|
}
|
||||||
|
$url = 'https://api.live.bilibili.com/msg/send';
|
||||||
|
$payload = [
|
||||||
|
'color' => '16777215',
|
||||||
|
'fontsize' => 25,
|
||||||
|
'mode' => 1,
|
||||||
|
'msg' => $content,
|
||||||
|
'rnd' => 0,
|
||||||
|
'roomid' => $room_id,
|
||||||
|
'csrf' => getCsrf(),
|
||||||
|
'csrf_token' => getCsrf(),
|
||||||
|
];
|
||||||
|
$raw = Curl::post('app', $url, Sign::common($payload));
|
||||||
|
return json_decode($raw, true) ?? ['code' => 404, 'msg' => '上层数据为空!'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取勋章列表
|
* @use 获取勋章列表
|
||||||
@ -291,6 +305,7 @@ class Live
|
|||||||
{
|
{
|
||||||
$metal_list = [];
|
$metal_list = [];
|
||||||
for ($i = 1; $i <= 10; $i++) {
|
for ($i = 1; $i <= 10; $i++) {
|
||||||
|
// $url = 'https://api.live.bilibili.com/fans_medal/v5/live_fans_medal/iApiMedal';
|
||||||
$url = 'https://api.live.bilibili.com/i/api/medal';
|
$url = 'https://api.live.bilibili.com/i/api/medal';
|
||||||
$payload = [
|
$payload = [
|
||||||
'page' => $i,
|
'page' => $i,
|
||||||
@ -362,9 +377,8 @@ class Live
|
|||||||
public static function sendGift(array $guest, array $gift, int $num)
|
public static function sendGift(array $guest, array $gift, int $num)
|
||||||
{
|
{
|
||||||
$url = 'https://api.live.bilibili.com/gift/v2/live/bag_send';
|
$url = 'https://api.live.bilibili.com/gift/v2/live/bag_send';
|
||||||
$user_info = User::parseCookies();
|
|
||||||
$payload = [
|
$payload = [
|
||||||
'uid' => $user_info['uid'], // 自己的UID
|
'uid' => getUid(), // 自己的UID
|
||||||
'gift_id' => $gift['gift_id'],
|
'gift_id' => $gift['gift_id'],
|
||||||
'ruid' => $guest['uid'], // UP的UID
|
'ruid' => $guest['uid'], // UP的UID
|
||||||
'send_ruid' => 0,
|
'send_ruid' => 0,
|
||||||
@ -377,8 +391,8 @@ class Live
|
|||||||
'storm_beat_id' => 0,
|
'storm_beat_id' => 0,
|
||||||
'metadata' => '',
|
'metadata' => '',
|
||||||
'price' => 0,
|
'price' => 0,
|
||||||
'csrf' => $user_info['token'],
|
'csrf' => getCsrf(),
|
||||||
'csrf_token' => $user_info['token']
|
'csrf_token' => getCsrf()
|
||||||
];
|
];
|
||||||
// {"code":0,"msg":"success","message":"success","data":{"tid":"1595419985112400002","uid":4133274,"uname":"沙奈之朵","face":"https://i2.hdslb.com/bfs/face/eb101ef90ebc4e9bf79f65312a22ebac84946700.jpg","guard_level":0,"ruid":893213,"rcost":30834251,"gift_id":30607,"gift_type":5,"gift_name":"小心心","gift_num":1,"gift_action":"投喂","gift_price":5000,"coin_type":"silver","total_coin":5000,"pay_coin":5000,"metadata":"","fulltext":"","rnd":"1595419967","tag_image":"","effect_block":1,"extra":{"wallet":null,"gift_bag":{"bag_id":210196588,"gift_num":20},"top_list":[],"follow":null,"medal":null,"title":null,"pk":{"pk_gift_tips":"","crit_prob":0},"fulltext":"","event":{"event_score":0,"event_redbag_num":0},"capsule":null},"blow_switch":0,"send_tips":"赠送成功","gift_effect":{"super":0,"combo_timeout":0,"super_gift_num":0,"super_batch_gift_num":0,"batch_combo_id":"","broadcast_msg_list":[],"small_tv_list":[],"beat_storm":null,"smallTVCountFlag":true},"send_master":null,"crit_prob":0,"combo_stay_time":3,"combo_total_coin":0,"demarcation":2,"magnification":1,"combo_resources_id":1,"is_special_batch":0,"send_gift_countdown":6}}
|
// {"code":0,"msg":"success","message":"success","data":{"tid":"1595419985112400002","uid":4133274,"uname":"沙奈之朵","face":"https://i2.hdslb.com/bfs/face/eb101ef90ebc4e9bf79f65312a22ebac84946700.jpg","guard_level":0,"ruid":893213,"rcost":30834251,"gift_id":30607,"gift_type":5,"gift_name":"小心心","gift_num":1,"gift_action":"投喂","gift_price":5000,"coin_type":"silver","total_coin":5000,"pay_coin":5000,"metadata":"","fulltext":"","rnd":"1595419967","tag_image":"","effect_block":1,"extra":{"wallet":null,"gift_bag":{"bag_id":210196588,"gift_num":20},"top_list":[],"follow":null,"medal":null,"title":null,"pk":{"pk_gift_tips":"","crit_prob":0},"fulltext":"","event":{"event_score":0,"event_redbag_num":0},"capsule":null},"blow_switch":0,"send_tips":"赠送成功","gift_effect":{"super":0,"combo_timeout":0,"super_gift_num":0,"super_batch_gift_num":0,"batch_combo_id":"","broadcast_msg_list":[],"small_tv_list":[],"beat_storm":null,"smallTVCountFlag":true},"send_master":null,"crit_prob":0,"combo_stay_time":3,"combo_total_coin":0,"demarcation":2,"magnification":1,"combo_resources_id":1,"is_special_batch":0,"send_gift_countdown":6}}
|
||||||
$data = Curl::post('app', $url, Sign::common($payload));
|
$data = Curl::post('app', $url, Sign::common($payload));
|
||||||
@ -390,7 +404,6 @@ class Live
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取分区直播间
|
* @use 获取分区直播间
|
||||||
* @param int $parent_area_id
|
* @param int $parent_area_id
|
||||||
|
|||||||
@ -11,11 +11,9 @@ namespace BiliHelper\Plugin;
|
|||||||
|
|
||||||
use BiliHelper\Core\Log;
|
use BiliHelper\Core\Log;
|
||||||
use BiliHelper\Core\Curl;
|
use BiliHelper\Core\Curl;
|
||||||
use BiliHelper\Core\Config;
|
|
||||||
use BiliHelper\Util\TimeLock;
|
use BiliHelper\Util\TimeLock;
|
||||||
use BiliHelper\Tool\Common;
|
use BiliHelper\Tool\Common;
|
||||||
|
|
||||||
|
|
||||||
class Login
|
class Login
|
||||||
{
|
{
|
||||||
use TimeLock;
|
use TimeLock;
|
||||||
@ -31,14 +29,13 @@ class Login
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log::info('启动登录程序');
|
Log::info('启动登录程序');
|
||||||
if (getenv('ACCESS_TOKEN') == "") {
|
if (getConf('access_token', 'login.auth') == '') {
|
||||||
Log::info('准备载入登录令牌');
|
Log::info('准备载入登录令牌');
|
||||||
self::login();
|
self::login();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::info('检查登录令牌有效性');
|
Log::info('检查登录令牌有效性');
|
||||||
if (!self::checkToken()) {
|
if (!self::checkToken()) {
|
||||||
Log::warning('登录令牌即将过期');
|
Log::warning('登录令牌失效或即将过期');
|
||||||
Log::info('申请更换登录令牌中');
|
Log::info('申请更换登录令牌中');
|
||||||
if (!self::refreshToken()) {
|
if (!self::refreshToken()) {
|
||||||
Log::warning('无效的登录令牌,尝试重新申请');
|
Log::warning('无效的登录令牌,尝试重新申请');
|
||||||
@ -54,7 +51,7 @@ class Login
|
|||||||
private static function login()
|
private static function login()
|
||||||
{
|
{
|
||||||
self::checkLogin();
|
self::checkLogin();
|
||||||
switch (intval(getenv('LOGIN_MODE'))) {
|
switch (getConf('mode', 'login.mode')) {
|
||||||
case 1:
|
case 1:
|
||||||
// 账密模式
|
// 账密模式
|
||||||
self::accountLogin();
|
self::accountLogin();
|
||||||
@ -68,7 +65,6 @@ class Login
|
|||||||
// self::captchaLogin();
|
// self::captchaLogin();
|
||||||
Log::error('此登录模式暂未开放');
|
Log::error('此登录模式暂未开放');
|
||||||
die();
|
die();
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
Log::error('登录模式配置错误');
|
Log::error('登录模式配置错误');
|
||||||
die();
|
die();
|
||||||
@ -80,15 +76,15 @@ class Login
|
|||||||
*/
|
*/
|
||||||
private static function checkLogin()
|
private static function checkLogin()
|
||||||
{
|
{
|
||||||
$user = getenv('APP_USER');
|
$username = getConf('username', 'login.account');
|
||||||
$pass = getenv('APP_PASS');
|
$password = getConf('password', 'login.account');
|
||||||
if (empty($user) || empty($pass)) {
|
if (empty($username) || empty($password)) {
|
||||||
Log::error('空白的帐号和口令');
|
Log::error('空白的帐号和口令');
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
self::clearAccount();
|
self::clearAccount();
|
||||||
self::$username = $user;
|
self::$username = $username;
|
||||||
self::$password = self::publicKeyEnc($pass);
|
self::$password = self::publicKeyEnc($password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,15 +117,16 @@ class Login
|
|||||||
{
|
{
|
||||||
$url = 'https://passport.bilibili.com/api/v2/oauth2/info';
|
$url = 'https://passport.bilibili.com/api/v2/oauth2/info';
|
||||||
$payload = [
|
$payload = [
|
||||||
'access_token' => getenv('ACCESS_TOKEN'),
|
'access_token' => getConf('access_token', 'login.auth'),
|
||||||
];
|
];
|
||||||
$data = Curl::get('app', $url, Sign::common($payload));
|
$data = Curl::get('app', $url, Sign::common($payload));
|
||||||
|
// {"ts":1234,"code":0,"data":{"mid":1234,"access_token":"1234","expires_in":7759292}}
|
||||||
$data = json_decode($data, true);
|
$data = json_decode($data, true);
|
||||||
if (isset($data['code']) && $data['code']) {
|
if (isset($data['code']) && $data['code']) {
|
||||||
Log::error('检查令牌失败', ['msg' => $data['message']]);
|
Log::error('检查令牌失败', ['msg' => $data['message']]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Log::info('令牌有效期: ' . date('Y-m-d H:i:s', $data['ts'] + $data['data']['expires_in']));
|
Log::notice('令牌有效期: ' . date('Y-m-d H:i:s', $data['ts'] + $data['data']['expires_in']));
|
||||||
return $data['data']['expires_in'] > 14400;
|
return $data['data']['expires_in'] > 14400;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,8 +137,8 @@ class Login
|
|||||||
{
|
{
|
||||||
$url = 'https://passport.bilibili.com/api/v2/oauth2/refresh_token';
|
$url = 'https://passport.bilibili.com/api/v2/oauth2/refresh_token';
|
||||||
$payload = [
|
$payload = [
|
||||||
'access_token' => getenv('ACCESS_TOKEN'),
|
'access_token' => getConf('access_token', 'login.auth'),
|
||||||
'refresh_token' => getenv('REFRESH_TOKEN'),
|
'refresh_token' => getConf('refresh_token', 'login.auth'),
|
||||||
];
|
];
|
||||||
$raw = Curl::post('app', $url, Sign::common($payload));
|
$raw = Curl::post('app', $url, Sign::common($payload));
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
@ -150,13 +147,7 @@ class Login
|
|||||||
Log::error('重新生成令牌失败', ['msg' => $de_raw['message']]);
|
Log::error('重新生成令牌失败', ['msg' => $de_raw['message']]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Log::info('重新令牌生成完毕');
|
self::refreshSuccess($de_raw);
|
||||||
$access_token = $de_raw['data']['token_info']['access_token'];
|
|
||||||
$refresh_token = $de_raw['data']['token_info']['refresh_token'];
|
|
||||||
self::saveConfig('ACCESS_TOKEN', $access_token);
|
|
||||||
self::saveConfig('REFRESH_TOKEN', $refresh_token);
|
|
||||||
self::saveCookie($de_raw);
|
|
||||||
Log::info('重置信息配置完毕');
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +212,7 @@ class Login
|
|||||||
*/
|
*/
|
||||||
private static function ocrCaptcha(array $captcha): array
|
private static function ocrCaptcha(array $captcha): array
|
||||||
{
|
{
|
||||||
$url = 'http://captcha-v1.mudew.com:19951/';
|
$url = 'https://captcha-v1.mudew.com:19951/';
|
||||||
$payload = [
|
$payload = [
|
||||||
'type' => 'gt3',
|
'type' => 'gt3',
|
||||||
'gt' => $captcha['gt'],
|
'gt' => $captcha['gt'],
|
||||||
@ -240,17 +231,6 @@ class Login
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @use 验证码登录
|
|
||||||
* @param string $mode
|
|
||||||
*/
|
|
||||||
private static function captchaLogin(string $mode = '验证码模式')
|
|
||||||
{
|
|
||||||
$captcha_ori = self::getCaptcha();
|
|
||||||
$captcha = self::ocrCaptcha($captcha_ori);
|
|
||||||
self::accountLogin($captcha['validate'], $captcha['challenge'], $mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 账密登录
|
* @use 账密登录
|
||||||
* @param string $validate
|
* @param string $validate
|
||||||
@ -373,9 +353,10 @@ class Login
|
|||||||
self::loginFail($mode, '未知错误: ' . $data['data']['message']);
|
self::loginFail($mode, '未知错误: ' . $data['data']['message']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// 正常登录
|
||||||
|
self::loginSuccess($mode, $data);
|
||||||
}
|
}
|
||||||
// 正常登录
|
|
||||||
self::loginSuccess($mode, $data);
|
|
||||||
break;
|
break;
|
||||||
case -105:
|
case -105:
|
||||||
// 需要验证码
|
// 需要验证码
|
||||||
@ -398,30 +379,52 @@ class Login
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 登陆成功
|
* @use 登录成功
|
||||||
* @param $mode
|
* @param $mode
|
||||||
* @param $data
|
* @param $data
|
||||||
*/
|
*/
|
||||||
private static function loginSuccess($mode, $data)
|
private static function loginSuccess($mode, $data)
|
||||||
{
|
{
|
||||||
Log::info("{$mode} 登录成功");
|
Log::info("{$mode} 登录成功");
|
||||||
$access_token = $data['data']['token_info']['access_token'];
|
self::successHandle($data);
|
||||||
$refresh_token = $data['data']['token_info']['refresh_token'];
|
Log::info('生成信息配置完毕');
|
||||||
self::saveConfig('ACCESS_TOKEN', $access_token);
|
|
||||||
self::saveConfig('REFRESH_TOKEN', $refresh_token);
|
|
||||||
self::saveCookie($data);
|
|
||||||
Log::info('信息配置完毕');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 登陆失败
|
* @use 刷新成功
|
||||||
|
* @param $data
|
||||||
|
*/
|
||||||
|
private static function refreshSuccess($data)
|
||||||
|
{
|
||||||
|
Log::info('重新令牌生成完毕');
|
||||||
|
self::successHandle($data);
|
||||||
|
Log::info('重置信息配置完毕');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 成功处理
|
||||||
|
* @param $data
|
||||||
|
*/
|
||||||
|
private static function successHandle($data)
|
||||||
|
{
|
||||||
|
$access_token = $data['data']['token_info']['access_token'];
|
||||||
|
$refresh_token = $data['data']['token_info']['refresh_token'];
|
||||||
|
self::saveConfig('access_token', $access_token, 'login.auth');
|
||||||
|
self::saveConfig('refresh_token', $refresh_token, 'login.auth');
|
||||||
|
self::saveConfig('cookie', self::formatCookie($data), 'login.auth');
|
||||||
|
$user = User::parseCookies();
|
||||||
|
self::saveConfig('uid', $user['uid'], 'login.auth', false);
|
||||||
|
self::saveConfig('csrf', $user['csrf'], 'login.auth', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 登录失败
|
||||||
* @param $mode
|
* @param $mode
|
||||||
* @param $data
|
* @param $data
|
||||||
*/
|
*/
|
||||||
private static function loginFail($mode, $data)
|
private static function loginFail($mode, $data)
|
||||||
{
|
{
|
||||||
Log::error("{$mode} 登录失败");
|
Log::error("{$mode} 登录失败", ['msg' => $data]);
|
||||||
Log::error('登录失败', ['msg' => $data]);
|
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,26 +444,31 @@ class Login
|
|||||||
* @use 保存配置
|
* @use 保存配置
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param string $value
|
* @param string $value
|
||||||
|
* @param string $section
|
||||||
|
* @param bool $print
|
||||||
* @param bool $hide
|
* @param bool $hide
|
||||||
*/
|
*/
|
||||||
private static function saveConfig(string $key, string $value, $hide = true)
|
private static function saveConfig(string $key, string $value, string $section, $print = true, $hide = true)
|
||||||
{
|
{
|
||||||
Config::put($key, $value);
|
setConf($key, $value, $section);
|
||||||
Log::info(" > {$key}: " . ($hide ? Common::replaceStar($value, 4, 4) : $value));
|
if ($print) {
|
||||||
|
Log::info(" > {$key}: " . ($hide ? Common::replaceStar($value, 6, 6) : $value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 保存配置
|
* @use @use 格式化COOKIE
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function saveCookie(array $data)
|
private static function formatCookie(array $data): string
|
||||||
{
|
{
|
||||||
$c = '';
|
$c = '';
|
||||||
$cookies = $data['data']['cookie_info']['cookies'];
|
$cookies = $data['data']['cookie_info']['cookies'];
|
||||||
foreach ($cookies as $cookie) {
|
foreach ($cookies as $cookie) {
|
||||||
$c .= $cookie['name'] . '=' . $cookie['value'] . ';';
|
$c .= $cookie['name'] . '=' . $cookie['value'] . ';';
|
||||||
}
|
}
|
||||||
self::saveConfig('COOKIE', $c);
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -468,14 +476,15 @@ class Login
|
|||||||
*/
|
*/
|
||||||
private static function clearAccount()
|
private static function clearAccount()
|
||||||
{
|
{
|
||||||
$variables = ['ACCESS_TOKEN', 'REFRESH_TOKEN', 'COOKIE'];
|
$variables = ['cookie', 'access_token', 'refresh_token'];
|
||||||
foreach ($variables as $variable) {
|
foreach ($variables as $variable) {
|
||||||
Config::put($variable, '');
|
setConf($variable, '', 'login.auth');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 刷新Cookie
|
* @use 刷新COOKIE
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function refreshCookie(): string
|
private static function refreshCookie(): string
|
||||||
{
|
{
|
||||||
@ -493,4 +502,16 @@ class Login
|
|||||||
return implode("", array_reverse($cookies));
|
return implode("", array_reverse($cookies));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 验证码登录
|
||||||
|
* @param string $mode
|
||||||
|
*/
|
||||||
|
private static function captchaLogin(string $mode = '验证码模式')
|
||||||
|
{
|
||||||
|
$captcha_ori = self::getCaptcha();
|
||||||
|
$captcha = self::ocrCaptcha($captcha_ori);
|
||||||
|
self::accountLogin($captcha['validate'], $captcha['challenge'], $mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -20,7 +20,7 @@ class MainSite
|
|||||||
|
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (self::getLock() > time() || getenv('USE_MAIN_SITE') == 'false') {
|
if (self::getLock() > time() || !getEnable('main_site')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (self::watchAid() && self::shareAid() && self::coinAdd()) {
|
if (self::watchAid() && self::shareAid() && self::coinAdd()) {
|
||||||
@ -30,7 +30,6 @@ class MainSite
|
|||||||
self::setLock(3600);
|
self::setLock(3600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 投币
|
* @use 投币
|
||||||
* @param $aid
|
* @param $aid
|
||||||
@ -38,13 +37,12 @@ class MainSite
|
|||||||
*/
|
*/
|
||||||
private static function reward($aid): bool
|
private static function reward($aid): bool
|
||||||
{
|
{
|
||||||
$user_info = User::parseCookies();
|
|
||||||
$url = "https://api.bilibili.com/x/web-interface/coin/add";
|
$url = "https://api.bilibili.com/x/web-interface/coin/add";
|
||||||
$payload = [
|
$payload = [
|
||||||
"aid" => $aid,
|
"aid" => $aid,
|
||||||
"multiply" => "1",
|
"multiply" => "1",
|
||||||
"cross_domain" => "true",
|
"cross_domain" => "true",
|
||||||
"csrf" => $user_info['token']
|
"csrf" => getCsrf()
|
||||||
];
|
];
|
||||||
$headers = [
|
$headers = [
|
||||||
'Host' => "api.bilibili.com",
|
'Host' => "api.bilibili.com",
|
||||||
@ -55,15 +53,14 @@ class MainSite
|
|||||||
$raw = Curl::post('app', $url, Sign::common($payload), $headers);
|
$raw = Curl::post('app', $url, Sign::common($payload), $headers);
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
if ($de_raw['code'] == 0) {
|
if ($de_raw['code'] == 0) {
|
||||||
Log::notice("主站任务: av{$aid}投币成功!");
|
Log::notice("主站任务: av{$aid} 投币成功");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Log::warning("主站任务: av{$aid}投币失败!");
|
Log::warning("主站任务: av{$aid} 投币失败");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 投币日志
|
* @use 投币日志
|
||||||
* @return int
|
* @return int
|
||||||
@ -75,7 +72,7 @@ class MainSite
|
|||||||
$raw = Curl::get('pc', $url, $payload);
|
$raw = Curl::get('pc', $url, $payload);
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
|
|
||||||
$logs = isset($de_raw['data']['list']) ? $de_raw['data']['list'] : [];
|
$logs = $de_raw['data']['list'] ?? [];
|
||||||
$coins = 0;
|
$coins = 0;
|
||||||
foreach ($logs as $log) {
|
foreach ($logs as $log) {
|
||||||
$log_ux = strtotime($log['time']);
|
$log_ux = strtotime($log['time']);
|
||||||
@ -106,45 +103,36 @@ class MainSite
|
|||||||
*/
|
*/
|
||||||
protected static function coinAdd(): bool
|
protected static function coinAdd(): bool
|
||||||
{
|
{
|
||||||
switch (getenv('USE_ADD_COIN')) {
|
if (!getConf('add_coin', 'main_site')) return true;
|
||||||
case 'false':
|
|
||||||
break;
|
// 预计数量 失败默认0 避免损失
|
||||||
case 'true':
|
$estimate_num = getConf('add_coin_num', 'main_site') ?? 0;
|
||||||
// 预计数量 失败默认0 避免损失
|
// 库存数量
|
||||||
$estimate_num = intval(getenv('ADD_COIN_NUM') ?? 0);
|
$stock_num = self::getCoin();
|
||||||
// 库存数量
|
// 实际数量 处理硬币库存少于预计数量
|
||||||
$stock_num = self::getCoin();
|
$actual_num = intval($estimate_num > $stock_num ? $stock_num : $estimate_num) - self::coinLog();
|
||||||
// 实际数量 处理硬币库存少于预计数量
|
Log::info("当前硬币库存 {$stock_num} 预计投币 {$estimate_num} 实际投币 {$actual_num}");
|
||||||
$actual_num = intval($estimate_num > $stock_num ? $stock_num : $estimate_num) - self::coinLog();
|
// 上限
|
||||||
Log::info("当前硬币库存 {$stock_num} 预计投币 {$estimate_num} 实际投币 {$actual_num}");
|
if ($actual_num <= 0) {
|
||||||
// 上限
|
Log::notice('今日投币上限已满');
|
||||||
if ($actual_num <= 0) {
|
return true;
|
||||||
Log::info('今日投币上限已满!');
|
}
|
||||||
break;
|
// 稿件列表
|
||||||
}
|
if (getConf('add_coin_mode', 'main_site') == 'random') {
|
||||||
// 稿件列表
|
// 随机热门稿件榜单
|
||||||
if (gettype('ADD_COIN_MODE') =='random'){
|
$aids = self::getDayRankingAids($actual_num);
|
||||||
// 随机热门稿件榜单
|
} else {
|
||||||
$aids = self::getDayRankingAids($actual_num);
|
// 固定获取关注UP稿件榜单, 不足会随机补全
|
||||||
}else{
|
$aids = self::getFollowUpAids($actual_num);
|
||||||
// 固定获取关注UP稿件榜单, 不足会随机补全
|
}
|
||||||
$aids = self::getFollowUpAids($actual_num);
|
Log::info("获取稿件列表: " . implode(" ", $aids));
|
||||||
}
|
// 投币
|
||||||
Log::info("获取稿件列表: ". implode(" ",$aids));
|
foreach ($aids as $aid) {
|
||||||
// 投币
|
self::reward($aid);
|
||||||
foreach ($aids as $aid) {
|
|
||||||
self::reward($aid);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Log::warning('当前视频投币设置不正确, 请检查配置文件!');
|
|
||||||
die();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取随机AID
|
* @use 获取随机AID
|
||||||
* @return string
|
* @return string
|
||||||
@ -166,7 +154,6 @@ class MainSite
|
|||||||
return (string)$aid;
|
return (string)$aid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取关注UP稿件列表
|
* @use 获取关注UP稿件列表
|
||||||
* @param int $num
|
* @param int $num
|
||||||
@ -175,11 +162,9 @@ class MainSite
|
|||||||
private static function getFollowUpAids(int $num): array
|
private static function getFollowUpAids(int $num): array
|
||||||
{
|
{
|
||||||
$aids = [];
|
$aids = [];
|
||||||
$rand_nums = [];
|
|
||||||
$url = 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new';
|
$url = 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new';
|
||||||
$user_info = User::parseCookies();
|
|
||||||
$payload = [
|
$payload = [
|
||||||
'uid' => $user_info['uid'],
|
'uid' => getUid(),
|
||||||
'type_list' => '8,512,4097,4098,4099,4100,4101'
|
'type_list' => '8,512,4097,4098,4099,4100,4101'
|
||||||
];
|
];
|
||||||
$headers = [
|
$headers = [
|
||||||
@ -201,7 +186,6 @@ class MainSite
|
|||||||
return $aids;
|
return $aids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取榜单稿件列表
|
* @use 获取榜单稿件列表
|
||||||
* @param int $num
|
* @param int $num
|
||||||
@ -238,21 +222,21 @@ class MainSite
|
|||||||
return $aids;
|
return $aids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 分享视频
|
* @use 分享视频
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private static function shareAid(): bool
|
private static function shareAid(): bool
|
||||||
{
|
{
|
||||||
|
if (!getConf('share', 'main_site')) return true;
|
||||||
|
|
||||||
# aid = 稿件av号
|
# aid = 稿件av号
|
||||||
$url = "https://api.bilibili.com/x/web-interface/share/add";
|
$url = "https://api.bilibili.com/x/web-interface/share/add";
|
||||||
$av_info = self::parseAid();
|
$av_info = self::parseAid();
|
||||||
$user_info = User::parseCookies();
|
|
||||||
$payload = [
|
$payload = [
|
||||||
'aid' => $av_info['aid'],
|
'aid' => $av_info['aid'],
|
||||||
'jsonp' => "jsonp",
|
'jsonp' => "jsonp",
|
||||||
'csrf' => $user_info['token'],
|
'csrf' => getCsrf(),
|
||||||
];
|
];
|
||||||
$headers = [
|
$headers = [
|
||||||
'Host' => "api.bilibili.com",
|
'Host' => "api.bilibili.com",
|
||||||
@ -263,21 +247,22 @@ class MainSite
|
|||||||
$raw = Curl::post('pc', $url, $payload, $headers);
|
$raw = Curl::post('pc', $url, $payload, $headers);
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
if ($de_raw['code'] == 0) {
|
if ($de_raw['code'] == 0) {
|
||||||
Log::notice("主站任务: av{$av_info['aid']}分享成功!");
|
Log::notice("主站任务: av{$av_info['aid']} 分享成功");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Log::warning("主站任务: av{$av_info['aid']}分享失败!");
|
Log::warning("主站任务: av{$av_info['aid']} 分享失败");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 观看视频
|
* @use 观看视频
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private static function watchAid(): bool
|
private static function watchAid(): bool
|
||||||
{
|
{
|
||||||
|
if (!getConf('watch', 'main_site')) return true;
|
||||||
|
|
||||||
$url = "https://api.bilibili.com/x/report/click/h5";
|
$url = "https://api.bilibili.com/x/report/click/h5";
|
||||||
$av_info = self::parseAid();
|
$av_info = self::parseAid();
|
||||||
$user_info = User::parseCookies();
|
$user_info = User::parseCookies();
|
||||||
@ -289,8 +274,8 @@ class MainSite
|
|||||||
'ftime' => time(),
|
'ftime' => time(),
|
||||||
'jsonp' => "jsonp",
|
'jsonp' => "jsonp",
|
||||||
'lv' => "",
|
'lv' => "",
|
||||||
'mid' => $user_info['uid'],
|
'mid' => getUid(),
|
||||||
'csrf' => $user_info['token'],
|
'csrf' => getCsrf(),
|
||||||
'stime' => time()
|
'stime' => time()
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -309,7 +294,7 @@ class MainSite
|
|||||||
"aid" => $av_info['aid'],
|
"aid" => $av_info['aid'],
|
||||||
"cid" => $av_info['cid'],
|
"cid" => $av_info['cid'],
|
||||||
"mid" => $user_info['uid'],
|
"mid" => $user_info['uid'],
|
||||||
"csrf" => $user_info['token'],
|
"csrf" => getCsrf(),
|
||||||
"jsonp" => "jsonp",
|
"jsonp" => "jsonp",
|
||||||
"played_time" => "0",
|
"played_time" => "0",
|
||||||
"realtime" => $av_info['duration'],
|
"realtime" => $av_info['duration'],
|
||||||
@ -329,16 +314,15 @@ class MainSite
|
|||||||
$raw = Curl::post('pc', $url, $payload, $headers);
|
$raw = Curl::post('pc', $url, $payload, $headers);
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
if ($de_raw['code'] == 0) {
|
if ($de_raw['code'] == 0) {
|
||||||
Log::notice("主站任务: av{$av_info['aid']}观看成功!");
|
Log::notice("主站任务: av{$av_info['aid']} 观看成功");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log::warning("主站任务: av{$av_info['aid']}观看失败!");
|
Log::warning("主站任务: av{$av_info['aid']} 观看失败");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 解析AID到CID
|
* @use 解析AID到CID
|
||||||
* @return array
|
* @return array
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class ManGa
|
|||||||
|
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (self::getLock() > time() || getenv('USE_MANGA') == 'false') {
|
if (self::getLock() > time() || !getEnable('manga')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (self::sign() && self::share()) {
|
if (self::sign() && self::share()) {
|
||||||
@ -31,12 +31,16 @@ class ManGa
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 漫画签到
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
private static function sign(): bool
|
private static function sign(): bool
|
||||||
{
|
{
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$url = 'https://manga.bilibili.com/twirp/activity.v1.Activity/ClockIn';
|
$url = 'https://manga.bilibili.com/twirp/activity.v1.Activity/ClockIn';
|
||||||
$payload = [
|
$payload = [
|
||||||
'access_key' => getenv('ACCESS_TOKEN'),
|
'access_key' => getConf('access_token', 'login.auth'),
|
||||||
'ts' => time()
|
'ts' => time()
|
||||||
];
|
];
|
||||||
$raw = Curl::post('app', $url, Sign::common($payload));
|
$raw = Curl::post('app', $url, Sign::common($payload));
|
||||||
@ -44,14 +48,18 @@ class ManGa
|
|||||||
# {"code":0,"msg":"","data":{}}
|
# {"code":0,"msg":"","data":{}}
|
||||||
# {"code":"invalid_argument","msg":"clockin clockin is duplicate","meta":{"argument":"clockin"}}
|
# {"code":"invalid_argument","msg":"clockin clockin is duplicate","meta":{"argument":"clockin"}}
|
||||||
if (!$de_raw['code']) {
|
if (!$de_raw['code']) {
|
||||||
Log::notice('漫画签到: 成功~');
|
Log::notice('漫画签到: 成功');
|
||||||
} else {
|
} else {
|
||||||
Log::warning('漫画签到: 失败或者重复操作~');
|
Log::warning('漫画签到: 失败或者重复操作');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 漫画分享
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
private static function share(): bool
|
private static function share(): bool
|
||||||
{
|
{
|
||||||
sleep(1);
|
sleep(1);
|
||||||
@ -62,9 +70,9 @@ class ManGa
|
|||||||
# {"code":0,"msg":"","data":{"point":5}}
|
# {"code":0,"msg":"","data":{"point":5}}
|
||||||
# {"code":1,"msg":"","data":{"point":0}}
|
# {"code":1,"msg":"","data":{"point":0}}
|
||||||
if (!$de_raw['code']) {
|
if (!$de_raw['code']) {
|
||||||
Log::notice('漫画分享: 成功~');
|
Log::notice('漫画分享: 成功');
|
||||||
} else {
|
} else {
|
||||||
Log::warning('漫画分享: 失败或者重复操作~');
|
Log::warning('漫画分享: 失败或者重复操作');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,6 @@ use BiliHelper\Core\Curl;
|
|||||||
use BiliHelper\Util\TimeLock;
|
use BiliHelper\Util\TimeLock;
|
||||||
use BiliHelper\Util\FilterWords;
|
use BiliHelper\Util\FilterWords;
|
||||||
|
|
||||||
|
|
||||||
class MaterialObject
|
class MaterialObject
|
||||||
{
|
{
|
||||||
use TimeLock;
|
use TimeLock;
|
||||||
@ -27,13 +26,10 @@ class MaterialObject
|
|||||||
|
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (getenv('USE_LIVE_BOX') == 'false') {
|
if (self::getLock() > time() || !getEnable('live_box')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self::setPauseStatus();
|
self::setPauseStatus();
|
||||||
if (self::getLock() > time()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self::calcAid(700, 900);
|
self::calcAid(700, 900);
|
||||||
$lottery_list = self::fetchLottery();
|
$lottery_list = self::fetchLottery();
|
||||||
self::drawLottery($lottery_list);
|
self::drawLottery($lottery_list);
|
||||||
@ -57,7 +53,6 @@ class MaterialObject
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 抽奖盒子状态
|
* @use 抽奖盒子状态
|
||||||
* @param int $aid
|
* @param int $aid
|
||||||
@ -92,7 +87,6 @@ class MaterialObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取抽奖
|
* @use 获取抽奖
|
||||||
* @return array
|
* @return array
|
||||||
@ -141,7 +135,6 @@ class MaterialObject
|
|||||||
return $lottery_list;
|
return $lottery_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 过滤轮次
|
* @use 过滤轮次
|
||||||
* @param array $rounds
|
* @param array $rounds
|
||||||
@ -165,7 +158,6 @@ class MaterialObject
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 抽奖
|
* @use 抽奖
|
||||||
* @param array $lottery_list
|
* @param array $lottery_list
|
||||||
@ -194,7 +186,6 @@ class MaterialObject
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 计算Aid
|
* @use 计算Aid
|
||||||
* @param $min
|
* @param $min
|
||||||
|
|||||||
@ -25,13 +25,13 @@ class Notice
|
|||||||
*/
|
*/
|
||||||
public static function push(string $type, string $result = '')
|
public static function push(string $type, string $result = '')
|
||||||
{
|
{
|
||||||
if (getenv('USE_NOTIFY') == 'false') {
|
if (!getEnable('notify')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (self::filterResultWords($result)) {
|
if (self::filterResultWords($result)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$uname = User::userInfo() ? getenv('APP_UNAME') : getenv('APP_USER');
|
$uname = getConf('uname', 'print') ?? getConf('username', 'login.account');
|
||||||
self::sendInfoHandle($type, $uname, $result);
|
self::sendInfoHandle($type, $uname, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ class Notice
|
|||||||
{
|
{
|
||||||
self::loadJsonData();
|
self::loadJsonData();
|
||||||
$default_words = self::$store->get("Notice.default");;
|
$default_words = self::$store->get("Notice.default");;
|
||||||
$custom_words = empty(getenv('NOTIFY_FILTER_WORDS')) ? [] : explode(',', getenv('NOTIFY_FILTER_WORDS'));
|
$custom_words = explode(',', getConf('filter_words', 'notify'));
|
||||||
$total_words = array_merge($default_words, $custom_words);
|
$total_words = array_merge($default_words, $custom_words);
|
||||||
foreach ($total_words as $word) {
|
foreach ($total_words as $word) {
|
||||||
if (strpos($result, $word) !== false) {
|
if (strpos($result, $word) !== false) {
|
||||||
@ -54,7 +54,6 @@ class Notice
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 处理信息
|
* @use 处理信息
|
||||||
* @param string $type
|
* @param string $type
|
||||||
@ -156,27 +155,29 @@ class Notice
|
|||||||
*/
|
*/
|
||||||
private static function sendLog(array $info)
|
private static function sendLog(array $info)
|
||||||
{
|
{
|
||||||
if (getenv('NOTIFY_SCTKEY')) {
|
if (getConf('sctkey', 'notify.sct')) {
|
||||||
self::sctSend($info);
|
self::sctSend($info);
|
||||||
}
|
}
|
||||||
if (getenv('NOTIFY_SCKEY')) {
|
if (getConf('sckey', 'notify.sc')) {
|
||||||
self::scSend($info);
|
self::scSend($info);
|
||||||
}
|
}
|
||||||
if (getenv('NOTIFY_TELE_BOTTOKEN') && getenv('NOTIFY_TELE_CHATID')) {
|
if (getConf('bottoken', 'notify.telegram') && getConf('chatid', 'notify.telegram')) {
|
||||||
self::teleSend($info);
|
self::teleSend($info);
|
||||||
}
|
}
|
||||||
if (getenv('NOTIFY_DINGTALK_TOKEN')) {
|
if (getConf('token', 'notify.dingtalk')) {
|
||||||
self::dingTalkSend($info);
|
self::dingTalkSend($info);
|
||||||
}
|
}
|
||||||
if (getenv('NOTIFY_PUSHPLUS_TOKEN')) {
|
if (getConf('token', 'notify.pushplus')) {
|
||||||
self::pushPlusSend($info);
|
self::pushPlusSend($info);
|
||||||
}
|
}
|
||||||
if (getenv('NOTIFY_CQ_URL') && getenv('NOTIFY_CQ_TOKEN') && getenv('NOTIFY_CQ_QQ')) {
|
if (getConf('target_qq', 'notify.gocqhttp') && getConf('token', 'notify.gocqhttp') && getConf('url', 'notify.gocqhttp')) {
|
||||||
self::goCqhttp($info);
|
self::goCqhttp($info);
|
||||||
}
|
}
|
||||||
|
if (getConf('token', 'notify.debug') && getConf('url', 'notify.debug')) {
|
||||||
|
self::debug($info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use DingTalkbot推送
|
* @use DingTalkbot推送
|
||||||
* @doc https://developers.dingtalk.com/document/app/document-upgrade-notice#/serverapi2/qf2nxq
|
* @doc https://developers.dingtalk.com/document/app/document-upgrade-notice#/serverapi2/qf2nxq
|
||||||
@ -185,7 +186,7 @@ class Notice
|
|||||||
private static function dingTalkSend(array $info)
|
private static function dingTalkSend(array $info)
|
||||||
{
|
{
|
||||||
Log::info('使用DingTalk机器人推送消息');
|
Log::info('使用DingTalk机器人推送消息');
|
||||||
$url = 'https://oapi.dingtalk.com/robot/send?access_token=' . getenv('NOTIFY_DINGTALK_TOKEN');
|
$url = 'https://oapi.dingtalk.com/robot/send?access_token=' . getConf('token', 'notify.dingtalk');
|
||||||
$payload = [
|
$payload = [
|
||||||
'msgtype' => 'markdown',
|
'msgtype' => 'markdown',
|
||||||
'markdown' => [
|
'markdown' => [
|
||||||
@ -205,7 +206,6 @@ class Notice
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use TeleBot推送
|
* @use TeleBot推送
|
||||||
* @doc https://core.telegram.org/bots/api#sendmessage
|
* @doc https://core.telegram.org/bots/api#sendmessage
|
||||||
@ -214,10 +214,10 @@ class Notice
|
|||||||
private static function teleSend(array $info)
|
private static function teleSend(array $info)
|
||||||
{
|
{
|
||||||
Log::info('使用Tele机器人推送消息');
|
Log::info('使用Tele机器人推送消息');
|
||||||
$url = 'https://api.telegram.org/bot' . getenv('NOTIFY_TELE_BOTTOKEN');
|
$url = 'https://api.telegram.org/bot' . getConf('bottoken', 'notify.telegram');
|
||||||
$payload = [
|
$payload = [
|
||||||
'method' => 'sendMessage',
|
'method' => 'sendMessage',
|
||||||
'chat_id' => getenv('NOTIFY_TELE_CHATID'),
|
'chat_id' => getConf('chatid', 'notify.telegram'),
|
||||||
'text' => $info['content']
|
'text' => $info['content']
|
||||||
];
|
];
|
||||||
$raw = Curl::post('other', $url, $payload);
|
$raw = Curl::post('other', $url, $payload);
|
||||||
@ -229,7 +229,6 @@ class Notice
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use ServerChan推送
|
* @use ServerChan推送
|
||||||
* @use https://sc.ftqq.com/
|
* @use https://sc.ftqq.com/
|
||||||
@ -238,7 +237,7 @@ class Notice
|
|||||||
private static function scSend(array $info)
|
private static function scSend(array $info)
|
||||||
{
|
{
|
||||||
Log::info('使用ServerChan推送消息');
|
Log::info('使用ServerChan推送消息');
|
||||||
$url = 'https://sc.ftqq.com/' . getenv('NOTIFY_SCKEY') . '.send';
|
$url = 'https://sc.ftqq.com/' . getConf('sckey', 'notify.sc') . '.send';
|
||||||
$payload = [
|
$payload = [
|
||||||
'text' => $info['title'],
|
'text' => $info['title'],
|
||||||
'desp' => $info['content'],
|
'desp' => $info['content'],
|
||||||
@ -253,7 +252,6 @@ class Notice
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use ServerChan(Turbo)推送
|
* @use ServerChan(Turbo)推送
|
||||||
* @doc https://sct.ftqq.com/
|
* @doc https://sct.ftqq.com/
|
||||||
@ -262,7 +260,7 @@ class Notice
|
|||||||
private static function sctSend(array $info)
|
private static function sctSend(array $info)
|
||||||
{
|
{
|
||||||
Log::info('使用ServerChan(Turbo)推送消息');
|
Log::info('使用ServerChan(Turbo)推送消息');
|
||||||
$url = 'https://sctapi.ftqq.com/' . getenv('NOTIFY_SCTKEY') . '.send';
|
$url = 'https://sctapi.ftqq.com/' . getConf('sctkey', 'notify.sct') . '.send';
|
||||||
$payload = [
|
$payload = [
|
||||||
'text' => $info['title'],
|
'text' => $info['title'],
|
||||||
'desp' => $info['content'],
|
'desp' => $info['content'],
|
||||||
@ -288,7 +286,7 @@ class Notice
|
|||||||
Log::info('使用PushPlus酱推送消息');
|
Log::info('使用PushPlus酱推送消息');
|
||||||
$url = 'http://www.pushplus.plus/send';
|
$url = 'http://www.pushplus.plus/send';
|
||||||
$payload = [
|
$payload = [
|
||||||
'token' => getenv('NOTIFY_PUSHPLUS_TOKEN'),
|
'token' => getConf('token', 'notify.pushplus'),
|
||||||
'title' => $info['title'],
|
'title' => $info['title'],
|
||||||
'content' => $info['content']
|
'content' => $info['content']
|
||||||
];
|
];
|
||||||
@ -305,7 +303,6 @@ class Notice
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use GO-CQHTTP推送
|
* @use GO-CQHTTP推送
|
||||||
* @doc https://docs.go-cqhttp.org/api/
|
* @doc https://docs.go-cqhttp.org/api/
|
||||||
@ -314,10 +311,10 @@ class Notice
|
|||||||
private static function goCqhttp(array $info)
|
private static function goCqhttp(array $info)
|
||||||
{
|
{
|
||||||
Log::info('使用GoCqhttp推送消息');
|
Log::info('使用GoCqhttp推送消息');
|
||||||
$url = getenv('NOTIFY_CQ_URL');
|
$url = getConf('url', 'notify.gocqhttp');
|
||||||
$payload = [
|
$payload = [
|
||||||
'access_token' => getenv('NOTIFY_CQ_TOKEN'),
|
'access_token' => getConf('token', 'notify.gocqhttp'),
|
||||||
'user_id' => getenv('NOTIFY_CQ_QQ'),
|
'user_id' => getConf('target_qq', 'notify.gocqhttp'),
|
||||||
'message' => $info['content']
|
'message' => $info['content']
|
||||||
];
|
];
|
||||||
$raw = Curl::get('other', $url, $payload);
|
$raw = Curl::get('other', $url, $payload);
|
||||||
@ -330,4 +327,30 @@ class Notice
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 个人调试使用
|
||||||
|
* @doc
|
||||||
|
* @param array $info
|
||||||
|
*/
|
||||||
|
private static function debug(array $info)
|
||||||
|
{
|
||||||
|
Log::info('使用Debug推送消息');
|
||||||
|
$url = getConf('url', 'notify.debug');
|
||||||
|
$payload = [
|
||||||
|
'receiver' => getConf('token', 'notify.debug'),
|
||||||
|
'title' => $info['title'],
|
||||||
|
'body' => $info['content'],
|
||||||
|
'url' => '',
|
||||||
|
];
|
||||||
|
$raw = Curl::post('other', $url, $payload);
|
||||||
|
$de_raw = json_decode($raw, true);
|
||||||
|
// {"success": true, "msg": null, "data": {"errcode": 0, "errmsg": "ok", "msgid": 1231, "token": "456"}}
|
||||||
|
if ($de_raw['success'] == true) {
|
||||||
|
Log::info("推送消息成功: {$de_raw['data']['msgid']}");
|
||||||
|
} else {
|
||||||
|
Log::warning("推送消息失败: {$raw}");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -15,17 +15,15 @@ use BiliHelper\Core\Curl;
|
|||||||
use BiliHelper\Util\TimeLock;
|
use BiliHelper\Util\TimeLock;
|
||||||
use BiliHelper\Util\BaseRaffle;
|
use BiliHelper\Util\BaseRaffle;
|
||||||
|
|
||||||
|
|
||||||
class PkRaffle extends BaseRaffle
|
class PkRaffle extends BaseRaffle
|
||||||
{
|
{
|
||||||
const ACTIVE_TITLE = '大乱斗';
|
const ACTIVE_TITLE = '主播乱斗';
|
||||||
const ACTIVE_SWITCH = 'USE_PK';
|
const ACTIVE_SWITCH = 'live_pk';
|
||||||
|
|
||||||
protected static $wait_list = [];
|
protected static $wait_list = [];
|
||||||
protected static $finish_list = [];
|
protected static $finish_list = [];
|
||||||
protected static $all_list = [];
|
protected static $all_list = [];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 解析数据
|
* @use 解析数据
|
||||||
* @param int $room_id
|
* @param int $room_id
|
||||||
@ -65,7 +63,6 @@ class PkRaffle extends BaseRaffle
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 创建抽奖任务
|
* @use 创建抽奖任务
|
||||||
* @param array $raffles
|
* @param array $raffles
|
||||||
@ -75,14 +72,12 @@ class PkRaffle extends BaseRaffle
|
|||||||
{
|
{
|
||||||
$url = 'https://api.live.bilibili.com/xlive/lottery-interface/v1/pk/join';
|
$url = 'https://api.live.bilibili.com/xlive/lottery-interface/v1/pk/join';
|
||||||
$tasks = [];
|
$tasks = [];
|
||||||
$results = [];
|
|
||||||
$user_info = User::parseCookies();
|
|
||||||
foreach ($raffles as $raffle) {
|
foreach ($raffles as $raffle) {
|
||||||
$payload = [
|
$payload = [
|
||||||
'id' => $raffle['raffle_id'],
|
'id' => $raffle['raffle_id'],
|
||||||
'roomid' => $raffle['room_id'],
|
'roomid' => $raffle['room_id'],
|
||||||
'csrf_token' => $user_info['token'],
|
'csrf_token' => getCsrf(),
|
||||||
"csrf" => $user_info['token'],
|
"csrf" => getCsrf(),
|
||||||
];
|
];
|
||||||
array_push($tasks, [
|
array_push($tasks, [
|
||||||
'payload' => Sign::common($payload),
|
'payload' => Sign::common($payload),
|
||||||
@ -93,15 +88,14 @@ class PkRaffle extends BaseRaffle
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$results = Curl::async('app', $url, $tasks);
|
|
||||||
// print_r($results);
|
// print_r($results);
|
||||||
return $results;
|
return Curl::async('app', $url, $tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 解析抽奖信息
|
* @use 解析抽奖信息
|
||||||
* @param array $results
|
* @param array $results
|
||||||
* @return mixed|void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected static function parseLottery(array $results)
|
protected static function parseLottery(array $results)
|
||||||
{
|
{
|
||||||
|
|||||||
95
src/plugin/PolishTheMedal.php
Normal file
95
src/plugin/PolishTheMedal.php
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Website: https://mudew.com/
|
||||||
|
* Author: Lkeme
|
||||||
|
* License: The MIT License
|
||||||
|
* Email: Useri@live.cn
|
||||||
|
* Updated: 2021 ~ 2022
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace BiliHelper\Plugin;
|
||||||
|
|
||||||
|
use BiliHelper\Core\Log;
|
||||||
|
use BiliHelper\Tool\Generator;
|
||||||
|
use BiliHelper\Util\TimeLock;
|
||||||
|
|
||||||
|
class PolishTheMedal
|
||||||
|
{
|
||||||
|
use TimeLock;
|
||||||
|
|
||||||
|
private static $metal_lock = 0; // 勋章时间锁
|
||||||
|
private static $fans_medals = []; // 全部勋章
|
||||||
|
private static $grey_fans_medals = []; // 灰色勋章
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public static function run()
|
||||||
|
{
|
||||||
|
if (!getEnable('polish_the_medal')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 获取灰色勋章
|
||||||
|
if (self::$metal_lock < time()) {
|
||||||
|
// 如果勋章过多导致未处理完,就1小时一次,否则8小时一次。
|
||||||
|
if (empty(self::$grey_fans_medals)) {
|
||||||
|
self::fetchGreyMedalList();
|
||||||
|
self::$metal_lock = time() + 8 * 60 * 60;
|
||||||
|
} else {
|
||||||
|
self::$metal_lock = time() + 1 * 60 * 60;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 点亮灰色勋章
|
||||||
|
if (self::getLock() < time()) {
|
||||||
|
// 随机4-10分钟处理一次点亮操作
|
||||||
|
self::polishTheMedal();
|
||||||
|
self::setLock(mt_rand(4, 10) * 60);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 点亮勋章
|
||||||
|
*/
|
||||||
|
private static function polishTheMedal()
|
||||||
|
{
|
||||||
|
$medal = array_pop(self::$grey_fans_medals);
|
||||||
|
// 为空
|
||||||
|
if (is_null($medal)) return;
|
||||||
|
Log::info("开始点亮直播间@{$medal['roomid']}的勋章");
|
||||||
|
// 擦亮
|
||||||
|
$response = Live::sendBarrageAPP($medal['roomid'], Generator::emoji());
|
||||||
|
if (isset($response['code']) && $response['code'] == 0) {
|
||||||
|
Log::notice("在直播间@{$medal['roomid']}发送点亮弹幕成功");
|
||||||
|
} else {
|
||||||
|
Log::warning("在直播间@{$medal['roomid']}发送点亮弹幕失败, CODE -> {$response['code']} MSG -> {$response['message']} ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 获取灰色勋章列表(过滤无勋章或已满)
|
||||||
|
*/
|
||||||
|
private static function fetchGreyMedalList()
|
||||||
|
{
|
||||||
|
$data = Live::fetchMedalList();
|
||||||
|
foreach ($data as $vo) {
|
||||||
|
// 过滤主站勋章
|
||||||
|
if (!isset($vo['roomid'])) continue;
|
||||||
|
// 过滤自己勋章
|
||||||
|
if ($vo['target_id'] == getUid()) continue;
|
||||||
|
// 所有
|
||||||
|
self::$fans_medals[] = [
|
||||||
|
'uid' => $vo['target_id'],
|
||||||
|
'roomid' => $vo['roomid'],
|
||||||
|
];
|
||||||
|
// 灰色
|
||||||
|
if ($vo['medal_color_start'] == 12632256 && $vo['medal_color_end'] == 12632256 && $vo['medal_color_border'] == 12632256) {
|
||||||
|
self::$grey_fans_medals[] = [
|
||||||
|
'uid' => $vo['target_id'],
|
||||||
|
'roomid' => $vo['roomid'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 乱序
|
||||||
|
shuffle(self::$grey_fans_medals);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1 +0,0 @@
|
|||||||
<?php
|
|
||||||
@ -13,7 +13,6 @@ namespace BiliHelper\Plugin;
|
|||||||
use BiliHelper\Core\Log;
|
use BiliHelper\Core\Log;
|
||||||
use BiliHelper\Util\TimeLock;
|
use BiliHelper\Util\TimeLock;
|
||||||
|
|
||||||
|
|
||||||
class Schedule
|
class Schedule
|
||||||
{
|
{
|
||||||
use TimeLock;
|
use TimeLock;
|
||||||
@ -23,7 +22,7 @@ class Schedule
|
|||||||
private static $unlock_timers = [];
|
private static $unlock_timers = [];
|
||||||
private static $sleep_section = [];
|
private static $sleep_section = [];
|
||||||
// 日常类
|
// 日常类
|
||||||
private static $fillable = ['Login', 'Schedule', 'Daily', 'Judge', 'MainSite', 'GiftSend', 'DailyTask', 'Silver2Coin', 'ManGa', 'GameMatch', 'GroupSignIn', 'AwardRecord', 'Statistics'];
|
private static $fillable = ['Login', 'Schedule', 'DailyBag', 'Judge', 'MainSite', 'GiftSend', 'DailyTask', 'Silver2Coin', 'ManGa', 'GroupSignIn', 'AwardRecord', 'Statistics'];
|
||||||
// 任务类
|
// 任务类
|
||||||
private static $guarded_first = ['Barrage', 'GiftHeart', 'Silver', 'MaterialObject'];
|
private static $guarded_first = ['Barrage', 'GiftHeart', 'Silver', 'MaterialObject'];
|
||||||
// 监控类
|
// 监控类
|
||||||
@ -31,9 +30,12 @@ class Schedule
|
|||||||
// 抽奖类
|
// 抽奖类
|
||||||
private static $guarded_third = ['StormRaffle', 'GuardRaffle', 'PkRaffle', 'GiftRaffle', 'AnchorRaffle'];
|
private static $guarded_third = ['StormRaffle', 'GuardRaffle', 'PkRaffle', 'GiftRaffle', 'AnchorRaffle'];
|
||||||
// 特殊 老爷处理
|
// 特殊 老爷处理
|
||||||
private static $guarded_fourth = ['Heart'];
|
private static $guarded_fourth = ['DoubleHeart'];
|
||||||
// 暂定不做处理,后期看情况再定
|
// 暂定不做处理,后期看情况再定
|
||||||
private static $release = ['ActivityLottery', 'SmallHeart', 'Competition', 'SmallHeart', 'Forward', 'CapsuleLottery'];
|
private static $release = ['ActivityLottery', 'SmallHeart', 'Competition', 'SmallHeart', 'Forward', 'CapsuleLottery', 'PolishTheMedal'];
|
||||||
|
// 暂定不做处理 大会员类
|
||||||
|
private static $guarded_fifth = ['VipPrivilege', 'BpConsumption'];
|
||||||
|
|
||||||
|
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
@ -48,10 +50,10 @@ class Schedule
|
|||||||
/**
|
/**
|
||||||
* @use 检查休眠
|
* @use 检查休眠
|
||||||
*/
|
*/
|
||||||
private static function isSleep()
|
private static function isSleep(): bool
|
||||||
{
|
{
|
||||||
if (getenv('USE_SLEEP') != 'false' && self::$unlock_hour != date('H')) {
|
if (getEnable('sleep') && self::$unlock_hour != date('H')) {
|
||||||
self::$sleep_section = empty(self::$sleep_section) ? explode(',', getenv('SLEEP_SECTION')) : self::$sleep_section;
|
self::$sleep_section = empty(self::$sleep_section) ? explode(',', getConf('section', 'sleep')) : self::$sleep_section;
|
||||||
if (!in_array(date('H'), self::$sleep_section)) {
|
if (!in_array(date('H'), self::$sleep_section)) {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@ -64,7 +66,7 @@ class Schedule
|
|||||||
/**
|
/**
|
||||||
* @use 特殊暂停
|
* @use 特殊暂停
|
||||||
*/
|
*/
|
||||||
private static function isSpecialPause()
|
private static function isSpecialPause(): bool
|
||||||
{
|
{
|
||||||
foreach (self::$guarded_second as $classname) {
|
foreach (self::$guarded_second as $classname) {
|
||||||
$status = call_user_func(array(__NAMESPACE__ . '\\' . $classname, 'getPauseStatus'));
|
$status = call_user_func(array(__NAMESPACE__ . '\\' . $classname, 'getPauseStatus'));
|
||||||
|
|||||||
@ -27,7 +27,7 @@ class Sign
|
|||||||
// $appsecret = '59b43e04ad6965f34319062b478f83dd';
|
// $appsecret = '59b43e04ad6965f34319062b478f83dd';
|
||||||
//
|
//
|
||||||
// $default = [
|
// $default = [
|
||||||
// 'access_key' => getenv('ACCESS_TOKEN'),
|
// 'access_key' => getConf('access_token', 'login.auth')
|
||||||
// 'actionKey' => 'appkey',
|
// 'actionKey' => 'appkey',
|
||||||
// 'appkey' => $appkey,
|
// 'appkey' => $appkey,
|
||||||
// 'build' => 101800,
|
// 'build' => 101800,
|
||||||
@ -45,17 +45,17 @@ class Sign
|
|||||||
* @param $payload
|
* @param $payload
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function login($payload)
|
public static function login($payload): array
|
||||||
{
|
{
|
||||||
# Android 新
|
# Android 新
|
||||||
$appkey = 'bca7e84c2d947ac6';
|
$appkey = 'bca7e84c2d947ac6';
|
||||||
$appsecret = '60698ba2f68e01ce44738920a0ffe768';
|
$appsecret = '60698ba2f68e01ce44738920a0ffe768';
|
||||||
|
|
||||||
$default = [
|
$default = [
|
||||||
'access_key' => getenv('ACCESS_TOKEN'),
|
'access_key' => getConf('access_token', 'login.auth'),
|
||||||
'actionKey' => 'appkey',
|
'actionKey' => 'appkey',
|
||||||
'appkey' => $appkey,
|
'appkey' => $appkey,
|
||||||
'build' => 6205500,
|
'build' => 6240300,
|
||||||
'channel' => 'bili',
|
'channel' => 'bili',
|
||||||
'device' => 'phone',
|
'device' => 'phone',
|
||||||
'mobi_app' => 'android',
|
'mobi_app' => 'android',
|
||||||
@ -71,7 +71,7 @@ class Sign
|
|||||||
* @param $payload
|
* @param $payload
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function common($payload)
|
public static function common($payload): array
|
||||||
{
|
{
|
||||||
# iOS 6680
|
# iOS 6680
|
||||||
// $appkey = '27eb53fc9058f8c3';
|
// $appkey = '27eb53fc9058f8c3';
|
||||||
@ -81,11 +81,11 @@ class Sign
|
|||||||
$appsecret = '560c52ccd288fed045859ed18bffd973';
|
$appsecret = '560c52ccd288fed045859ed18bffd973';
|
||||||
|
|
||||||
$default = [
|
$default = [
|
||||||
'access_key' => getenv('ACCESS_TOKEN'),
|
'access_key' => getConf('access_token', 'login.auth'),
|
||||||
'actionKey' => 'appkey',
|
'actionKey' => 'appkey',
|
||||||
'appkey' => $appkey,
|
'appkey' => $appkey,
|
||||||
'build' => 6205500,
|
'build' => 6240300,
|
||||||
'device' => 'android',
|
'device' => 'phone',
|
||||||
'mobi_app' => 'android',
|
'mobi_app' => 'android',
|
||||||
'platform' => 'android',
|
'platform' => 'android',
|
||||||
'ts' => time(),
|
'ts' => time(),
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class Silver2Coin
|
|||||||
|
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (self::getLock() > time() || getenv('USE_SILVER2COIN') == 'false') {
|
if (self::getLock() > time() || !getEnable('silver2coin')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (self::appSilver2coin() && self::pcSilver2coin()) {
|
if (self::appSilver2coin() && self::pcSilver2coin()) {
|
||||||
@ -30,7 +30,6 @@ class Silver2Coin
|
|||||||
self::setLock(3600);
|
self::setLock(3600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use app兑换
|
* @use app兑换
|
||||||
* @return bool
|
* @return bool
|
||||||
@ -41,20 +40,20 @@ class Silver2Coin
|
|||||||
$url = 'https://api.live.bilibili.com/AppExchange/silver2coin';
|
$url = 'https://api.live.bilibili.com/AppExchange/silver2coin';
|
||||||
$payload = [];
|
$payload = [];
|
||||||
$raw = Curl::get('app', $url, Sign::common($payload));
|
$raw = Curl::get('app', $url, Sign::common($payload));
|
||||||
|
// {"code":403,"msg":"仅主站正式会员以上的用户可以兑换","message":"仅主站正式会员以上的用户可以兑换","data":[]}
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
|
|
||||||
if (!$de_raw['code'] && $de_raw['msg'] == '兑换成功') {
|
if (!$de_raw['code'] && $de_raw['msg'] == '兑换成功') {
|
||||||
Log::info('[APP]银瓜子兑换硬币: ' . $de_raw['msg']);
|
Log::notice('[APP] 银瓜子兑换硬币: ' . $de_raw['msg']);
|
||||||
} elseif ($de_raw['code'] == 403) {
|
} elseif ($de_raw['code'] == 403) {
|
||||||
Log::warning('[APP]银瓜子兑换硬币: ' . $de_raw['msg']);
|
Log::warning('[APP] 银瓜子兑换硬币: ' . $de_raw['msg']);
|
||||||
} else {
|
} else {
|
||||||
Log::warning('[APP]银瓜子兑换硬币: ' . $de_raw['msg']);
|
Log::warning('[APP] 银瓜子兑换硬币: ' . $de_raw['msg']);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use pc兑换
|
* @use pc兑换
|
||||||
* @return bool
|
* @return bool
|
||||||
@ -67,11 +66,13 @@ class Silver2Coin
|
|||||||
$url = "https://api.live.bilibili.com/pay/v1/Exchange/silver2coin";
|
$url = "https://api.live.bilibili.com/pay/v1/Exchange/silver2coin";
|
||||||
|
|
||||||
$raw = Curl::get('pc', $url, $payload);
|
$raw = Curl::get('pc', $url, $payload);
|
||||||
|
// {"code":403,"msg":"仅主站正式会员以上的用户可以兑换","message":"仅主站正式会员以上的用户可以兑换","data":[]}
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
if ($de_raw['code'] == -403) {
|
if (isset($de_raw['code']) && $de_raw['code'] == 0) {
|
||||||
return false;
|
Log::notice('[PC] 银瓜子兑换硬币: ' . $de_raw['msg']);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
Log::info('[PC]银瓜子兑换硬币: ' . $de_raw['msg']);
|
Log::warning('[PC] 银瓜子兑换硬币: ' . $de_raw['msg']);
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
namespace BiliHelper\Plugin;
|
namespace BiliHelper\Plugin;
|
||||||
|
|
||||||
|
|
||||||
use BiliHelper\Util\TimeLock;
|
use BiliHelper\Util\TimeLock;
|
||||||
use BiliHelper\Util\XliveHeartBeat;
|
use BiliHelper\Util\XliveHeartBeat;
|
||||||
|
|
||||||
@ -19,9 +18,7 @@ class SmallHeart
|
|||||||
use TimeLock;
|
use TimeLock;
|
||||||
use XliveHeartBeat;
|
use XliveHeartBeat;
|
||||||
|
|
||||||
|
|
||||||
private static $fans_medals = []; // 全部勋章
|
private static $fans_medals = []; // 全部勋章
|
||||||
private static $grey_fans_medals = []; // 灰色勋章
|
|
||||||
private static $metal_lock = 0; // 勋章时间锁
|
private static $metal_lock = 0; // 勋章时间锁
|
||||||
private static $interval = 60; // 每次跳动时间
|
private static $interval = 60; // 每次跳动时间
|
||||||
private static $total_time = 0;
|
private static $total_time = 0;
|
||||||
@ -29,13 +26,12 @@ class SmallHeart
|
|||||||
|
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (getenv('USE_HEARTBEAT') == 'false') {
|
if (!getEnable('small_heart')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::$metal_lock < time()) {
|
if (self::$metal_lock < time()) {
|
||||||
self::polishMetal();
|
self::fetchMedalList();
|
||||||
self::$metal_lock = time() + 8 * 60 * 60;
|
self::$metal_lock = time() + 12 * 60 * 60;
|
||||||
}
|
}
|
||||||
if (self::getLock() < time()) {
|
if (self::getLock() < time()) {
|
||||||
self::heartBeat();
|
self::heartBeat();
|
||||||
@ -49,35 +45,6 @@ class SmallHeart
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @use 勋章处理
|
|
||||||
*/
|
|
||||||
private static function polishMetal()
|
|
||||||
{
|
|
||||||
// 灰色勋章
|
|
||||||
self::fetchGreyMedalList();
|
|
||||||
if (empty(self::$grey_fans_medals)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 小心心
|
|
||||||
$bag_list = Live::fetchBagListByGift('小心心', 30607);
|
|
||||||
if (empty($bag_list)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 擦亮勋章
|
|
||||||
foreach ($bag_list as $gift) {
|
|
||||||
for ($num = 1; $num <= $gift['gift_num']; $num++) {
|
|
||||||
$grey_fans_medal = array_shift(self::$grey_fans_medals);
|
|
||||||
// 为空
|
|
||||||
if (is_null($grey_fans_medal)) break;
|
|
||||||
// 擦亮
|
|
||||||
Live::sendGift($grey_fans_medal, $gift, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 心跳处理
|
* @use 心跳处理
|
||||||
*/
|
*/
|
||||||
@ -86,7 +53,7 @@ class SmallHeart
|
|||||||
if (empty(self::$fans_medals)) {
|
if (empty(self::$fans_medals)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (is_null(self::$metal)){
|
if (is_null(self::$metal)) {
|
||||||
self::$metal = self::$fans_medals[array_rand(self::$fans_medals)];
|
self::$metal = self::$fans_medals[array_rand(self::$fans_medals)];
|
||||||
}
|
}
|
||||||
$interval = self::xliveHeartBeatTask(self::$metal['roomid'], 999, 999);
|
$interval = self::xliveHeartBeatTask(self::$metal['roomid'], 999, 999);
|
||||||
@ -96,31 +63,22 @@ class SmallHeart
|
|||||||
self::$interval = $interval == 0 ? 60 : $interval;
|
self::$interval = $interval == 0 ? 60 : $interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取灰色勋章列表(过滤无勋章或已满)
|
* @use 获取灰色勋章列表(过滤无勋章或已满)
|
||||||
*/
|
*/
|
||||||
private static function fetchGreyMedalList()
|
private static function fetchMedalList()
|
||||||
{
|
{
|
||||||
$data = Live::fetchMedalList();
|
$data = Live::fetchMedalList();
|
||||||
$user_info = User::parseCookies();
|
|
||||||
foreach ($data as $vo) {
|
foreach ($data as $vo) {
|
||||||
// 过滤主站勋章
|
// 过滤主站勋章
|
||||||
if (!isset($vo['roomid'])) continue;
|
if (!isset($vo['roomid'])) continue;
|
||||||
// 过滤自己勋章
|
// 过滤自己勋章
|
||||||
if ($vo['target_id'] == $user_info['uid']) continue;
|
if ($vo['target_id'] == getUid()) continue;
|
||||||
// 所有
|
// 所有
|
||||||
self::$fans_medals[] = [
|
self::$fans_medals[] = [
|
||||||
'uid' => $vo['target_id'],
|
'uid' => $vo['target_id'],
|
||||||
'roomid' => $vo['roomid'],
|
'roomid' => $vo['roomid'],
|
||||||
];
|
];
|
||||||
// 灰色
|
|
||||||
if ($vo['medal_color_start'] == 12632256 && $vo['medal_color_end'] == 12632256 && $vo['medal_color_border'] == 12632256) {
|
|
||||||
self::$grey_fans_medals[] = [
|
|
||||||
'uid' => $vo['target_id'],
|
|
||||||
'roomid' => $vo['roomid'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,6 @@ use BiliHelper\Core\Log;
|
|||||||
use BiliHelper\Util\TimeLock;
|
use BiliHelper\Util\TimeLock;
|
||||||
use MathieuViossat\Util\ArrayToTextTable;
|
use MathieuViossat\Util\ArrayToTextTable;
|
||||||
|
|
||||||
|
|
||||||
class Statistics
|
class Statistics
|
||||||
{
|
{
|
||||||
use TimeLock;
|
use TimeLock;
|
||||||
@ -31,11 +30,9 @@ class Statistics
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self::outputResult();
|
self::outputResult();
|
||||||
|
|
||||||
self::setLock(20 * 60);
|
self::setLock(20 * 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 添加推送
|
* @use 添加推送
|
||||||
* @param string $key
|
* @param string $key
|
||||||
@ -49,7 +46,6 @@ class Statistics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 添加参与
|
* @use 添加参与
|
||||||
* @param string $key
|
* @param string $key
|
||||||
@ -63,7 +59,6 @@ class Statistics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 添加成功
|
* @use 添加成功
|
||||||
* @param string $key
|
* @param string $key
|
||||||
@ -77,7 +72,6 @@ class Statistics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 添加收益
|
* @use 添加收益
|
||||||
* @param string $title
|
* @param string $title
|
||||||
@ -94,7 +88,6 @@ class Statistics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 转换时间
|
* @use 转换时间
|
||||||
* @param int $the_time
|
* @param int $the_time
|
||||||
@ -142,7 +135,6 @@ class Statistics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取结果
|
* @use 获取结果
|
||||||
* @param array $target
|
* @param array $target
|
||||||
@ -156,7 +148,6 @@ class Statistics
|
|||||||
return is_null($second_key) ? $target[self::getTodayKey()][$key] : $target[self::getTodayKey()][$key][$second_key];
|
return is_null($second_key) ? $target[self::getTodayKey()][$key] : $target[self::getTodayKey()][$key][$second_key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取所有结果
|
* @use 获取所有结果
|
||||||
* @param array $target
|
* @param array $target
|
||||||
@ -164,7 +155,7 @@ class Statistics
|
|||||||
* @param string $second_key
|
* @param string $second_key
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private static function getResults(array &$target, string $key, $second_key = null)
|
private static function getResults(array &$target, string $key, $second_key = null): int
|
||||||
{
|
{
|
||||||
$results = 0;
|
$results = 0;
|
||||||
is_null($second_key) ? self::initKeyValue($target, $key) : self::initKeyValue($target, $key, 0, $second_key);
|
is_null($second_key) ? self::initKeyValue($target, $key) : self::initKeyValue($target, $key, 0, $second_key);
|
||||||
@ -177,7 +168,6 @@ class Statistics
|
|||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 变量增加
|
* @use 变量增加
|
||||||
* @param array $target
|
* @param array $target
|
||||||
@ -186,13 +176,12 @@ class Statistics
|
|||||||
* @param null $second_key
|
* @param null $second_key
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private static function valIncrease(array &$target, string $key, $num = 1, $second_key = null)
|
private static function valIncrease(array &$target, string $key, $num = 1, $second_key = null): bool
|
||||||
{
|
{
|
||||||
is_null($second_key) ? $target[self::getTodayKey()][$key] += $num : $target[self::getTodayKey()][$key][$second_key] += $num;
|
is_null($second_key) ? $target[self::getTodayKey()][$key] += $num : $target[self::getTodayKey()][$key][$second_key] += $num;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 变量替换
|
* @use 变量替换
|
||||||
* @param array $target
|
* @param array $target
|
||||||
@ -201,7 +190,7 @@ class Statistics
|
|||||||
* @param string $second_key
|
* @param string $second_key
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private static function valReplace(array &$target, string $key, $data = null, $second_key = '')
|
private static function valReplace(array &$target, string $key, $data = null, $second_key = ''): bool
|
||||||
{
|
{
|
||||||
is_null($second_key) ? $target[self::getTodayKey()][$key] = $data : $target[self::getTodayKey()][$key][$second_key] = $data;
|
is_null($second_key) ? $target[self::getTodayKey()][$key] = $data : $target[self::getTodayKey()][$key][$second_key] = $data;
|
||||||
return true;
|
return true;
|
||||||
@ -242,10 +231,9 @@ class Statistics
|
|||||||
return [self::unique_arr($tr_list_count), self::unique_arr($tr_list_profit)];
|
return [self::unique_arr($tr_list_count), self::unique_arr($tr_list_profit)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 二维数组去重
|
* @use 二维数组去重
|
||||||
* @param $result
|
* @param array $result
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private static function unique_arr(array $result): array
|
private static function unique_arr(array $result): array
|
||||||
|
|||||||
@ -12,13 +12,12 @@ namespace BiliHelper\Plugin;
|
|||||||
|
|
||||||
use BiliHelper\Core\Log;
|
use BiliHelper\Core\Log;
|
||||||
use BiliHelper\Core\Curl;
|
use BiliHelper\Core\Curl;
|
||||||
use BiliHelper\Util\TimeLock;
|
|
||||||
use BiliHelper\Util\BaseRaffle;
|
use BiliHelper\Util\BaseRaffle;
|
||||||
|
|
||||||
class StormRaffle extends BaseRaffle
|
class StormRaffle extends BaseRaffle
|
||||||
{
|
{
|
||||||
const ACTIVE_TITLE = '节奏风暴';
|
const ACTIVE_TITLE = '节奏风暴';
|
||||||
const ACTIVE_SWITCH = 'USE_STORM';
|
const ACTIVE_SWITCH = 'live_storm';
|
||||||
|
|
||||||
protected static $wait_list = [];
|
protected static $wait_list = [];
|
||||||
protected static $finish_list = [];
|
protected static $finish_list = [];
|
||||||
@ -27,7 +26,6 @@ class StormRaffle extends BaseRaffle
|
|||||||
private static $drop_rate = null;
|
private static $drop_rate = null;
|
||||||
private static $attempt = null;
|
private static $attempt = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 解析数据
|
* @use 解析数据
|
||||||
* @param int $room_id
|
* @param int $room_id
|
||||||
@ -49,7 +47,7 @@ class StormRaffle extends BaseRaffle
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 过滤抽奖范围
|
// 过滤抽奖范围
|
||||||
self::$drop_rate = getenv('STORM_DROPRATE') !== "" ? (int)getenv('STORM_DROPRATE') : 0;
|
self::$drop_rate = (int)getConf('drop_rate', 'live_storm');
|
||||||
if (mt_rand(1, 100) <= (int)self::$drop_rate) {
|
if (mt_rand(1, 100) <= (int)self::$drop_rate) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -69,7 +67,6 @@ class StormRaffle extends BaseRaffle
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 格式化日志输出
|
* 格式化日志输出
|
||||||
* @param $id
|
* @param $id
|
||||||
@ -82,7 +79,6 @@ class StormRaffle extends BaseRaffle
|
|||||||
return "风暴 {$id} 请求 {$num} 状态 {$info}";
|
return "风暴 {$id} 请求 {$num} 状态 {$info}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 创建抽奖任务
|
* @use 创建抽奖任务
|
||||||
* @param array $raffles
|
* @param array $raffles
|
||||||
@ -91,9 +87,8 @@ class StormRaffle extends BaseRaffle
|
|||||||
protected static function createLottery(array $raffles): array
|
protected static function createLottery(array $raffles): array
|
||||||
{
|
{
|
||||||
$url = 'https://api.live.bilibili.com/lottery/v1/Storm/join';
|
$url = 'https://api.live.bilibili.com/lottery/v1/Storm/join';
|
||||||
$user_info = User::parseCookies();
|
|
||||||
foreach ($raffles as $raffle) {
|
foreach ($raffles as $raffle) {
|
||||||
self::$attempt = getenv('STORM_ATTEMPT') !== "" ? explode(',', getenv('STORM_ATTEMPT')) : [30, 50];
|
self::$attempt = empty($attempt = getConf('attempt', 'live_storm')) ? [10, 20] : explode(',', $attempt);
|
||||||
$num = mt_rand((int)self::$attempt[0], (int)self::$attempt[1]);
|
$num = mt_rand((int)self::$attempt[0], (int)self::$attempt[1]);
|
||||||
$payload = [
|
$payload = [
|
||||||
'id' => $raffle['raffle_id'],
|
'id' => $raffle['raffle_id'],
|
||||||
@ -101,8 +96,8 @@ class StormRaffle extends BaseRaffle
|
|||||||
"color" => "16772431",
|
"color" => "16772431",
|
||||||
"captcha_token" => "",
|
"captcha_token" => "",
|
||||||
"captcha_phrase" => "",
|
"captcha_phrase" => "",
|
||||||
"token" => $user_info['token'],
|
"token" => getCsrf(),
|
||||||
"csrf_token" => $user_info['token'],
|
"csrf_token" => getCsrf(),
|
||||||
"visit_id" => ""
|
"visit_id" => ""
|
||||||
];
|
];
|
||||||
for ($i = 1; $i < $num; $i++) {
|
for ($i = 1; $i < $num; $i++) {
|
||||||
@ -158,7 +153,7 @@ class StormRaffle extends BaseRaffle
|
|||||||
/**
|
/**
|
||||||
* @use 解析抽奖信息
|
* @use 解析抽奖信息
|
||||||
* @param array $results
|
* @param array $results
|
||||||
* @return mixed|void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected static function parseLottery(array $results)
|
protected static function parseLottery(array $results)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -11,7 +11,8 @@
|
|||||||
namespace BiliHelper\Plugin;
|
namespace BiliHelper\Plugin;
|
||||||
|
|
||||||
use BiliHelper\Core\Curl;
|
use BiliHelper\Core\Curl;
|
||||||
use BiliHelper\Core\Config;
|
use BiliHelper\Core\Log;
|
||||||
|
use BiliHelper\Tool\Common;
|
||||||
|
|
||||||
class User
|
class User
|
||||||
{
|
{
|
||||||
@ -32,7 +33,6 @@ class User
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 老爷检测
|
* @use 老爷检测
|
||||||
* @return bool
|
* @return bool
|
||||||
@ -48,25 +48,6 @@ class User
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @use 写入用户名
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function userInfo(): bool
|
|
||||||
{
|
|
||||||
$data = self::getUserInfo();
|
|
||||||
if (getenv('APP_UNAME') != "") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if ($data['msg'] == 'ok') {
|
|
||||||
Config::put('APP_UNAME', $data['data']['uname']);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use UserInfo
|
* @use UserInfo
|
||||||
* @return array
|
* @return array
|
||||||
@ -75,7 +56,7 @@ class User
|
|||||||
{
|
{
|
||||||
$url = 'https://api.live.bilibili.com/User/getUserInfo';
|
$url = 'https://api.live.bilibili.com/User/getUserInfo';
|
||||||
$payload = [
|
$payload = [
|
||||||
'ts' => Live::getMillisecond(),
|
'ts' => Common::getMillisecond(),
|
||||||
];
|
];
|
||||||
$raw = Curl::get('app', $url, Sign::common($payload));
|
$raw = Curl::get('app', $url, Sign::common($payload));
|
||||||
return json_decode($raw, true);
|
return json_decode($raw, true);
|
||||||
@ -91,7 +72,7 @@ class User
|
|||||||
{
|
{
|
||||||
$url = 'https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByUser';
|
$url = 'https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByUser';
|
||||||
$payload = [
|
$payload = [
|
||||||
'room_id' => $room_id ?? getenv('ROOM_ID')
|
'room_id' => $room_id ?? getConf('room_id', 'global_room')
|
||||||
];
|
];
|
||||||
$raw = Curl::get('pc', $url, $payload);
|
$raw = Curl::get('pc', $url, $payload);
|
||||||
return json_decode($raw, true);
|
return json_decode($raw, true);
|
||||||
@ -107,10 +88,10 @@ class User
|
|||||||
{
|
{
|
||||||
$url = 'https://api.live.bilibili.com/xlive/app-room/v1/index/getInfoByUser';
|
$url = 'https://api.live.bilibili.com/xlive/app-room/v1/index/getInfoByUser';
|
||||||
$payload = [
|
$payload = [
|
||||||
'room_id' => $room_id ?? getenv('ROOM_ID')
|
'room_id' => $room_id ?? getConf('room_id', 'global_room')
|
||||||
];
|
];
|
||||||
$raw = Curl::get('app', $url, Sign::common($payload));
|
$raw = Curl::get('app', $url, Sign::common($payload));
|
||||||
return json_decode($raw, true);;
|
return json_decode($raw, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,17 +100,14 @@ class User
|
|||||||
*/
|
*/
|
||||||
public static function parseCookies(): array
|
public static function parseCookies(): array
|
||||||
{
|
{
|
||||||
$cookies = getenv('COOKIE');
|
$cookies = getCookie();
|
||||||
preg_match('/bili_jct=(.{32})/', $cookies, $token);
|
preg_match('/bili_jct=(.{32})/', $cookies, $token);
|
||||||
$token = isset($token[1]) ? $token[1] : '';
|
|
||||||
preg_match('/DedeUserID=(\d+)/', $cookies, $uid);
|
preg_match('/DedeUserID=(\d+)/', $cookies, $uid);
|
||||||
$uid = isset($uid[1]) ? $uid[1] : '';
|
|
||||||
preg_match('/DedeUserID__ckMd5=(.{16})/', $cookies, $sid);
|
preg_match('/DedeUserID__ckMd5=(.{16})/', $cookies, $sid);
|
||||||
$sid = isset($sid[1]) ? $sid[1] : '';
|
|
||||||
return [
|
return [
|
||||||
'token' => $token,
|
'csrf' => $token[1] ?? '',
|
||||||
'uid' => $uid,
|
'uid' => $uid[1] ?? '',
|
||||||
'sid' => $sid,
|
'sid' => $sid[1] ?? '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,8 +117,7 @@ class User
|
|||||||
*/
|
*/
|
||||||
public static function fetchAllFollowings(): array
|
public static function fetchAllFollowings(): array
|
||||||
{
|
{
|
||||||
$user_info = User::parseCookies();
|
$uid = getUid();
|
||||||
$uid = $user_info['uid'];
|
|
||||||
$followings = [];
|
$followings = [];
|
||||||
for ($i = 1; $i < 100; $i++) {
|
for ($i = 1; $i < 100; $i++) {
|
||||||
$url = "https://api.bilibili.com/x/relation/followings";
|
$url = "https://api.bilibili.com/x/relation/followings";
|
||||||
@ -168,7 +145,6 @@ class User
|
|||||||
return $followings;
|
return $followings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取分组关注列表
|
* @use 获取分组关注列表
|
||||||
* @param int $tag_id
|
* @param int $tag_id
|
||||||
@ -178,8 +154,7 @@ class User
|
|||||||
*/
|
*/
|
||||||
public static function fetchTagFollowings(int $tag_id = 0, int $page_num = 100, int $page_size = 50): array
|
public static function fetchTagFollowings(int $tag_id = 0, int $page_num = 100, int $page_size = 50): array
|
||||||
{
|
{
|
||||||
$user_info = User::parseCookies();
|
$uid = getUid();
|
||||||
$uid = $user_info['uid'];
|
|
||||||
$followings = [];
|
$followings = [];
|
||||||
for ($i = 1; $i < $page_num; $i++) {
|
for ($i = 1; $i < $page_num; $i++) {
|
||||||
$url = "https://api.bilibili.com/x/relation/tag";
|
$url = "https://api.bilibili.com/x/relation/tag";
|
||||||
@ -208,7 +183,6 @@ class User
|
|||||||
return $followings;
|
return $followings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 设置用户关注
|
* @use 设置用户关注
|
||||||
* @param int $follow_uid
|
* @param int $follow_uid
|
||||||
@ -217,15 +191,14 @@ class User
|
|||||||
*/
|
*/
|
||||||
public static function setUserFollow(int $follow_uid, $un_follow = false): bool
|
public static function setUserFollow(int $follow_uid, $un_follow = false): bool
|
||||||
{
|
{
|
||||||
$user_info = User::parseCookies();
|
|
||||||
$url = 'https://api.live.bilibili.com/relation/v1/Feed/SetUserFollow';
|
$url = 'https://api.live.bilibili.com/relation/v1/Feed/SetUserFollow';
|
||||||
$payload = [
|
$payload = [
|
||||||
'uid' => $user_info['uid'],
|
'uid' => getUid(),
|
||||||
'type' => $un_follow ? 0 : 1,
|
'type' => $un_follow ? 0 : 1,
|
||||||
'follow' => $follow_uid,
|
'follow' => $follow_uid,
|
||||||
're_src' => 18,
|
're_src' => 18,
|
||||||
'csrf_token' => $user_info['token'],
|
'csrf_token' => getCsrf(),
|
||||||
'csrf' => $user_info['token'],
|
'csrf' => getCsrf(),
|
||||||
'visit_id' => ''
|
'visit_id' => ''
|
||||||
];
|
];
|
||||||
$headers = [
|
$headers = [
|
||||||
@ -248,11 +221,10 @@ class User
|
|||||||
*/
|
*/
|
||||||
public static function createRelationTag(string $tag_name): int
|
public static function createRelationTag(string $tag_name): int
|
||||||
{
|
{
|
||||||
$user_info = User::parseCookies();
|
|
||||||
$url = 'https://api.bilibili.com/x/relation/tag/create?cross_domain=true';
|
$url = 'https://api.bilibili.com/x/relation/tag/create?cross_domain=true';
|
||||||
$payload = [
|
$payload = [
|
||||||
'tag' => $tag_name,
|
'tag' => $tag_name,
|
||||||
'csrf' => $user_info['token'],
|
'csrf' => getCsrf(),
|
||||||
];
|
];
|
||||||
$headers = [
|
$headers = [
|
||||||
'content-type' => 'application/x-www-form-urlencoded; charset=UTF-8',
|
'content-type' => 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||||
@ -276,12 +248,11 @@ class User
|
|||||||
*/
|
*/
|
||||||
public static function tagAddUsers(int $fid, int $tid): bool
|
public static function tagAddUsers(int $fid, int $tid): bool
|
||||||
{
|
{
|
||||||
$user_info = User::parseCookies();
|
|
||||||
$url = 'https://api.bilibili.com/x/relation/tags/addUsers?cross_domain=true';
|
$url = 'https://api.bilibili.com/x/relation/tags/addUsers?cross_domain=true';
|
||||||
$payload = [
|
$payload = [
|
||||||
'fids' => $fid,
|
'fids' => $fid,
|
||||||
'tagids' => $tid,
|
'tagids' => $tid,
|
||||||
'csrf' => $user_info['token'],
|
'csrf' => getCsrf(),
|
||||||
];
|
];
|
||||||
$headers = [
|
$headers = [
|
||||||
'content-type' => 'application/x-www-form-urlencoded; charset=UTF-8',
|
'content-type' => 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||||
@ -303,12 +274,11 @@ class User
|
|||||||
*/
|
*/
|
||||||
public static function fetchTags(): array
|
public static function fetchTags(): array
|
||||||
{
|
{
|
||||||
$user_info = User::parseCookies();
|
|
||||||
$tags = [];
|
$tags = [];
|
||||||
$url = 'https://api.bilibili.com/x/relation/tags';
|
$url = 'https://api.bilibili.com/x/relation/tags';
|
||||||
$payload = [];
|
$payload = [];
|
||||||
$headers = [
|
$headers = [
|
||||||
'referer' => "https://space.bilibili.com/{$user_info['uid']}/fans/follow",
|
'referer' => 'https://space.bilibili.com/' . getUid() . '/fans/follow',
|
||||||
];
|
];
|
||||||
$raw = Curl::get('pc', $url, $payload, $headers);
|
$raw = Curl::get('pc', $url, $payload, $headers);
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
@ -320,4 +290,31 @@ class User
|
|||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 是否为有效年度大会员
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function isYearVip(): bool
|
||||||
|
{
|
||||||
|
$url = 'https://api.bilibili.com/x/vip/web/user/info';
|
||||||
|
$headers = [
|
||||||
|
'origin' => 'https://account.bilibili.com',
|
||||||
|
'referer' => 'https://account.bilibili.com/account/home'
|
||||||
|
];
|
||||||
|
$payload = [];
|
||||||
|
$raw = Curl::get('pc', $url, $payload, $headers);
|
||||||
|
// {"code":0,"message":"0","ttl":1,"data":{"mid":1234,"vip_type":2,"vip_status":1,"vip_due_date":1667750400000,"vip_pay_type":0,"theme_type":0,"label":{"text":"年度大会员","label_theme":"annual_vip","text_color":"#FFFFFF","bg_style":1,"bg_color":"#FB7299","border_color":""},"avatar_subscript":1,"avatar_subscript_url":"http://i0.hdslb.com/bfs/vip/icon_Certification_big_member_22_3x.png","nickname_color":"#FB7299","is_new_user":false}}
|
||||||
|
$de_raw = json_decode($raw, true);
|
||||||
|
if ($de_raw['code'] == 0) {
|
||||||
|
if ($de_raw['data']['vip_type'] == 2 && $de_raw['data']['vip_due_date'] > Common::getMillisecond()) {
|
||||||
|
Log::debug("获取会员成功 有效年度大会员");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Log::debug("获取会员成功 不是年度大会员或已过期");
|
||||||
|
} else {
|
||||||
|
Log::debug("获取会员信息失败 {$raw}");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
96
src/plugin/VipPrivilege.php
Normal file
96
src/plugin/VipPrivilege.php
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Website: https://mudew.com/
|
||||||
|
* Author: Lkeme
|
||||||
|
* License: The MIT License
|
||||||
|
* Email: Useri@live.cn
|
||||||
|
* Updated: 2021 ~ 2022
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace BiliHelper\Plugin;
|
||||||
|
|
||||||
|
use BiliHelper\Core\Curl;
|
||||||
|
use BiliHelper\Core\Log;
|
||||||
|
use BiliHelper\Util\TimeLock;
|
||||||
|
|
||||||
|
class VipPrivilege
|
||||||
|
{
|
||||||
|
use TimeLock;
|
||||||
|
|
||||||
|
private static $privilege = [
|
||||||
|
0 => '未知奖励',
|
||||||
|
1 => 'B币劵',
|
||||||
|
2 => '会员购优惠券'
|
||||||
|
];
|
||||||
|
|
||||||
|
public static function run()
|
||||||
|
{
|
||||||
|
if (self::getLock() > time() || !getEnable('vip_privilege')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 如果为年度大会员
|
||||||
|
if (User::isYearVip()) {
|
||||||
|
$privilege_list = self::myVipPrivilege();
|
||||||
|
foreach ($privilege_list as $privilege) {
|
||||||
|
// 是否领取状态
|
||||||
|
if ($privilege['state'] != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 领取奖励
|
||||||
|
self::myVipPrivilegeReceive($privilege['type']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 定时11点 + 随机120分钟
|
||||||
|
self::setLock(self::timing(11) + mt_rand(1, 120) * 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 领取我的大会员权益
|
||||||
|
* @param int $type
|
||||||
|
*/
|
||||||
|
private static function myVipPrivilegeReceive(int $type)
|
||||||
|
{
|
||||||
|
$url = 'https://api.bilibili.com/x/vip/privilege/receive';
|
||||||
|
$headers = [
|
||||||
|
'origin' => 'https://account.bilibili.com',
|
||||||
|
'referer' => 'https://account.bilibili.com/account/big/myPackage',
|
||||||
|
];
|
||||||
|
$payload = [
|
||||||
|
'type' => $type,
|
||||||
|
'csrf' => getCsrf(),
|
||||||
|
];
|
||||||
|
$raw = Curl::post('pc', $url, $payload, $headers);
|
||||||
|
// {"code":0,"message":"0","ttl":1}
|
||||||
|
$de_raw = json_decode($raw, true);
|
||||||
|
if ($de_raw['code'] == 0) {
|
||||||
|
Log::notice('大会员权益 ' . self::$privilege[$type] . ' 领取成功');
|
||||||
|
} else {
|
||||||
|
Log::warning('大会员权益 ' . self::$privilege[$type] . " 领取失败, {$raw}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 获取我的大会员权益列表
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private static function myVipPrivilege(): array
|
||||||
|
{
|
||||||
|
$url = 'https://api.bilibili.com/x/vip/privilege/my';
|
||||||
|
$headers = [
|
||||||
|
'origin' => 'https://account.bilibili.com',
|
||||||
|
'referer' => 'https://account.bilibili.com/account/big/myPackage',
|
||||||
|
];
|
||||||
|
$payload = [];
|
||||||
|
$raw = Curl::get('pc', $url, $payload, $headers);
|
||||||
|
// {"code":0,"message":"0","ttl":1,"data":{"list":[{"type":1,"state":0,"expire_time":1622476799},{"type":2,"state":0,"expire_time":1622476799}]}}
|
||||||
|
$de_raw = json_decode($raw, true);
|
||||||
|
if ($de_raw['code'] == 0 && isset($de_raw['data']['list'])) {
|
||||||
|
Log::info('获取大会员权益列表成功');
|
||||||
|
return $de_raw['data']['list'];
|
||||||
|
} else {
|
||||||
|
Log::warning("获取大会员权益列表失败 {$raw}");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -39,7 +39,7 @@ class ZoneTcpClient
|
|||||||
*/
|
*/
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (self::getLock() > time() || getenv('USE_ZONE_SERVER') == 'false') {
|
if (self::getLock() > time() || !getEnable('zone_monitor')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self::setPauseStatus();
|
self::setPauseStatus();
|
||||||
@ -50,13 +50,12 @@ class ZoneTcpClient
|
|||||||
self::pushHandle();
|
self::pushHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 初始化
|
* @use 初始化
|
||||||
*/
|
*/
|
||||||
private static function init()
|
private static function init()
|
||||||
{
|
{
|
||||||
if (empty(getenv('ZONE_SERVER_ADDR'))) {
|
if (empty(getConf('server_addr', 'zone_monitor'))) {
|
||||||
exit('推送服务器信息不完整, 请检查配置文件!');
|
exit('推送服务器信息不完整, 请检查配置文件!');
|
||||||
}
|
}
|
||||||
if (!self::$client) {
|
if (!self::$client) {
|
||||||
@ -79,7 +78,6 @@ class ZoneTcpClient
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 触发重连
|
* @use 触发重连
|
||||||
* @param array $area_data
|
* @param array $area_data
|
||||||
@ -166,14 +164,13 @@ class ZoneTcpClient
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 响应数据
|
* @use 响应数据
|
||||||
* @param $msg
|
* @param $msg
|
||||||
* @param $type
|
* @param $type
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private static function onMessage($msg, $type)
|
private static function onMessage($msg, $type): bool
|
||||||
{
|
{
|
||||||
// 心跳后回复人气
|
// 心跳后回复人气
|
||||||
if ($type == 3) {
|
if ($type == 3) {
|
||||||
@ -359,9 +356,9 @@ class ZoneTcpClient
|
|||||||
Log::info("监测到 @分区 {$data['area_id']} @房间 {$data['room_id']} @抽奖 {$data['raffle_title']}");
|
Log::info("监测到 @分区 {$data['area_id']} @房间 {$data['room_id']} @抽奖 {$data['raffle_title']}");
|
||||||
// print_r($data);
|
// print_r($data);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @推送到上游处理
|
* @推送到上游处理
|
||||||
*/
|
*/
|
||||||
@ -387,12 +384,11 @@ class ZoneTcpClient
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 发送握手包
|
* @use 发送握手包
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private static function sendHandShake()
|
private static function sendHandShake(): bool
|
||||||
{
|
{
|
||||||
return self::writer(self::genHandshakePkg(self::$room_id));
|
return self::writer(self::genHandshakePkg(self::$room_id));
|
||||||
}
|
}
|
||||||
@ -406,7 +402,6 @@ class ZoneTcpClient
|
|||||||
return self::packMsg('', 0x0002);
|
return self::packMsg('', 0x0002);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 握手包
|
* @use 握手包
|
||||||
* @param $room_id
|
* @param $room_id
|
||||||
@ -431,17 +426,16 @@ class ZoneTcpClient
|
|||||||
* @param $option
|
* @param $option
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function packMsg($value, $option)
|
private static function packMsg($value, $option): string
|
||||||
{
|
{
|
||||||
$head = pack('NnnNN', 0x10 + strlen($value), 0x10, 0x01, $option, 0x0001);
|
$head = pack('NnnNN', 0x10 + strlen($value), 0x10, 0x01, $option, 0x0001);
|
||||||
return $head . $value;
|
return $head . $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 解包数据
|
* @use 解包数据
|
||||||
* @param $value
|
* @param $value
|
||||||
* @return int|mixed
|
* @return array|false
|
||||||
*/
|
*/
|
||||||
private static function unPackMsg($value)
|
private static function unPackMsg($value)
|
||||||
{
|
{
|
||||||
@ -449,12 +443,10 @@ class ZoneTcpClient
|
|||||||
Log::warning("unPackMsg: 包头异常 " . strlen($value));
|
Log::warning("unPackMsg: 包头异常 " . strlen($value));
|
||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
$head = unpack('Npacklen/nheadlen/nver/Nop/Nseq', $value);
|
|
||||||
// Log::info(json_encode($head, true));
|
// Log::info(json_encode($head, true));
|
||||||
return $head;
|
return unpack('Npacklen/nheadlen/nver/Nop/Nseq', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 心跳
|
* @use 心跳
|
||||||
*/
|
*/
|
||||||
@ -534,7 +526,7 @@ class ZoneTcpClient
|
|||||||
* @param $data
|
* @param $data
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private static function writer($data)
|
private static function writer($data): bool
|
||||||
{
|
{
|
||||||
$status = false;
|
$status = false;
|
||||||
try {
|
try {
|
||||||
@ -551,7 +543,6 @@ class ZoneTcpClient
|
|||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 读取数据
|
* @use 读取数据
|
||||||
*/
|
*/
|
||||||
@ -570,8 +561,8 @@ class ZoneTcpClient
|
|||||||
// 长度为0 ,空信息
|
// 长度为0 ,空信息
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$length = isset($head['packlen']) ? $head['packlen'] : 16;
|
$length = $head['packlen'] ?? 16;
|
||||||
$type = isset($head['op']) ? $head['op'] : 0x0000;
|
$type = $head['op'] ?? 0x0000;
|
||||||
$len_body = $length - 16;
|
$len_body = $length - 16;
|
||||||
Log::debug("(AreaId={$client_info['area_id']} -> RoomId={$client_info['room_id']} -> Len={$len_body})");
|
Log::debug("(AreaId={$client_info['area_id']} -> RoomId={$client_info['room_id']} -> Len={$len_body})");
|
||||||
if (!$len_body)
|
if (!$len_body)
|
||||||
@ -590,7 +581,13 @@ class ZoneTcpClient
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function v2_split($bin, $total)
|
/**
|
||||||
|
* @use V2切割
|
||||||
|
* @param $bin
|
||||||
|
* @param $total
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private static function v2_split($bin, $total): array
|
||||||
{
|
{
|
||||||
$list = [];
|
$list = [];
|
||||||
$step = 0;
|
$step = 0;
|
||||||
@ -604,7 +601,7 @@ class ZoneTcpClient
|
|||||||
if ($step == $total) break;
|
if ($step == $total) break;
|
||||||
$bin = substr($data, $step, 16);
|
$bin = substr($data, $step, 16);
|
||||||
$head = self::unPackMsg($bin);
|
$head = self::unPackMsg($bin);
|
||||||
$length = isset($head['packlen']) ? $head['packlen'] : 16;
|
$length = $head['packlen'] ?? 16;
|
||||||
$body = substr($data, $step + 16, $length - 16);
|
$body = substr($data, $step + 16, $length - 16);
|
||||||
$step += $length;
|
$step += $length;
|
||||||
array_push($list, $body);
|
array_push($list, $body);
|
||||||
@ -612,12 +609,20 @@ class ZoneTcpClient
|
|||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $object
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
private static function getClass($object): string
|
private static function getClass($object): string
|
||||||
{
|
{
|
||||||
$class = \get_class($object);
|
$class = \get_class($object);
|
||||||
return 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class) . '@anonymous' : $class;
|
return 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class) . '@anonymous' : $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $e
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
private static function formatErr($e): string
|
private static function formatErr($e): string
|
||||||
{
|
{
|
||||||
return sprintf('Uncaught Exception %s: "%s" at %s line %s', self::getClass($e), $e->getMessage(), $e->getFile(), $e->getLine());
|
return sprintf('Uncaught Exception %s: "%s" at %s line %s', self::getClass($e), $e->getMessage(), $e->getFile(), $e->getLine());
|
||||||
@ -626,7 +631,7 @@ class ZoneTcpClient
|
|||||||
/*
|
/*
|
||||||
* @use replace delay by select
|
* @use replace delay by select
|
||||||
*/
|
*/
|
||||||
public static function Delayed()
|
public static function Delayed(): Delayed
|
||||||
{
|
{
|
||||||
$r = [];
|
$r = [];
|
||||||
$w = NULL;
|
$w = NULL;
|
||||||
|
|||||||
@ -20,11 +20,11 @@ class BvToAv
|
|||||||
protected $add = 8728348608;
|
protected $add = 8728348608;
|
||||||
protected $s = [11, 10, 3, 8, 4, 6];
|
protected $s = [11, 10, 3, 8, 4, 6];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BV 转 AV
|
* @use BV 转 AV
|
||||||
*
|
|
||||||
* @param $bv
|
* @param $bv
|
||||||
* @return int
|
* @return int|string
|
||||||
*/
|
*/
|
||||||
public function dec($bv)
|
public function dec($bv)
|
||||||
{
|
{
|
||||||
@ -36,14 +36,13 @@ class BvToAv
|
|||||||
return ($r - $this->add) ^ $this->xor;
|
return ($r - $this->add) ^ $this->xor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @use AV 转 BV
|
||||||
* AV 转 BV
|
|
||||||
*
|
|
||||||
* @param $av
|
* @param $av
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function enc($av)
|
public function enc($av): string
|
||||||
{
|
{
|
||||||
$tr = str_split($this->tr);
|
$tr = str_split($this->tr);
|
||||||
$bv = 'BV1 4 1 7 ';
|
$bv = 'BV1 4 1 7 ';
|
||||||
|
|||||||
@ -24,6 +24,21 @@ class Common
|
|||||||
return intval(sprintf('%u', (floatval($t1) + floatval($t2)) * 1000));
|
return intval(sprintf('%u', (floatval($t1) + floatval($t2)) * 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 获取当月第一天及最后一天
|
||||||
|
* $day[0] 第一天
|
||||||
|
* $day[1] 最后一天
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getTheMonth(): array
|
||||||
|
{
|
||||||
|
$today = date("Y-m-d");
|
||||||
|
$first_day = date('Y-m-01', strtotime($today));
|
||||||
|
$last_day = date('Y-m-d', strtotime("$first_day +1 month -1 day"));
|
||||||
|
return array($first_day, $last_day);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 替换字符串
|
* @use 替换字符串
|
||||||
* @param $str
|
* @param $str
|
||||||
@ -51,9 +66,7 @@ class Common
|
|||||||
$len = $len - mb_strlen($top, $charset);
|
$len = $len - mb_strlen($top, $charset);
|
||||||
$len = $len - mb_strlen($bottom, $charset);
|
$len = $len - mb_strlen($bottom, $charset);
|
||||||
$newStr = $top;
|
$newStr = $top;
|
||||||
for ($i = 0; $i < $len; $i++) {
|
$newStr .= str_repeat($dot, $len);
|
||||||
$newStr .= $dot;
|
|
||||||
}
|
|
||||||
$newStr .= $bottom;
|
$newStr .= $bottom;
|
||||||
return $newStr;
|
return $newStr;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,6 @@
|
|||||||
namespace BiliHelper\Tool;
|
namespace BiliHelper\Tool;
|
||||||
|
|
||||||
use BiliHelper\Core\Log;
|
use BiliHelper\Core\Log;
|
||||||
use BiliHelper\Core\Curl;
|
|
||||||
|
|
||||||
class DumpMemory
|
class DumpMemory
|
||||||
{
|
{
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class Faker
|
|||||||
* @example 79907610
|
* @example 79907610
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function numberBetween($int1 = 0, $int2 = 2147483647)
|
public static function numberBetween($int1 = 0, $int2 = 2147483647): int
|
||||||
{
|
{
|
||||||
$min = $int1 < $int2 ? $int1 : $int2;
|
$min = $int1 < $int2 ? $int1 : $int2;
|
||||||
$max = $int1 < $int2 ? $int2 : $int1;
|
$max = $int1 < $int2 ? $int2 : $int1;
|
||||||
@ -36,7 +36,7 @@ class Faker
|
|||||||
* @param int $except
|
* @param int $except
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function randomDigitNot($except)
|
public static function randomDigitNot($except): int
|
||||||
{
|
{
|
||||||
$result = self::numberBetween(0, 8);
|
$result = self::numberBetween(0, 8);
|
||||||
if ($result >= $except) {
|
if ($result >= $except) {
|
||||||
@ -53,7 +53,7 @@ class Faker
|
|||||||
* @param string $string String that needs to bet parsed
|
* @param string $string String that needs to bet parsed
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function asciify($string = '****')
|
public static function asciify($string = '****'): string
|
||||||
{
|
{
|
||||||
return preg_replace_callback('/\*/u', 'static::randomAscii', $string);
|
return preg_replace_callback('/\*/u', 'static::randomAscii', $string);
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ class Faker
|
|||||||
/**
|
/**
|
||||||
* @example 'fY4èHdZv68'
|
* @example 'fY4èHdZv68'
|
||||||
*/
|
*/
|
||||||
public function password($minLength = 6, $maxLength = 20)
|
public function password($minLength = 6, $maxLength = 20): string
|
||||||
{
|
{
|
||||||
$pattern = str_repeat('*', $this->numberBetween($minLength, $maxLength));
|
$pattern = str_repeat('*', $this->numberBetween($minLength, $maxLength));
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ class Faker
|
|||||||
/**
|
/**
|
||||||
* @example '35cd:186d:3e23:2986:ef9f:5b41:42a4:e6f1'
|
* @example '35cd:186d:3e23:2986:ef9f:5b41:42a4:e6f1'
|
||||||
*/
|
*/
|
||||||
public function ipv6()
|
public function ipv6(): string
|
||||||
{
|
{
|
||||||
$res = array();
|
$res = array();
|
||||||
for ($i = 0; $i < 8; $i++) {
|
for ($i = 0; $i < 8; $i++) {
|
||||||
@ -108,7 +108,7 @@ class Faker
|
|||||||
/**
|
/**
|
||||||
* @example '32:F1:39:2F:D6:18'
|
* @example '32:F1:39:2F:D6:18'
|
||||||
*/
|
*/
|
||||||
public static function macAddress()
|
public static function macAddress(): string
|
||||||
{
|
{
|
||||||
for ($i = 0; $i < 6; $i++) {
|
for ($i = 0; $i < 6; $i++) {
|
||||||
$mac[] = sprintf('%02X', static::numberBetween(0, 0xff));
|
$mac[] = sprintf('%02X', static::numberBetween(0, 0xff));
|
||||||
@ -118,6 +118,11 @@ class Faker
|
|||||||
return $mac;
|
return $mac;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 转Ascii
|
||||||
|
* @param $string
|
||||||
|
* @return array|string|string[]
|
||||||
|
*/
|
||||||
protected static function toAscii($string)
|
protected static function toAscii($string)
|
||||||
{
|
{
|
||||||
static $arrayFrom, $arrayTo;
|
static $arrayFrom, $arrayTo;
|
||||||
|
|||||||
@ -11,11 +11,9 @@
|
|||||||
|
|
||||||
namespace BiliHelper\Tool;
|
namespace BiliHelper\Tool;
|
||||||
|
|
||||||
|
|
||||||
class File
|
class File
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 创建文件
|
* @use 创建文件
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
|
|||||||
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace BiliHelper\Tool;
|
namespace BiliHelper\Tool;
|
||||||
|
|
||||||
|
|
||||||
class Generator
|
class Generator
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -53,7 +52,8 @@ class Generator
|
|||||||
* @use 生成BUVID
|
* @use 生成BUVID
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function buvid():string{
|
public static function buvid(): string
|
||||||
|
{
|
||||||
// XYD5B85DA7212341F51C612344A6B8C6C21234
|
// XYD5B85DA7212341F51C612344A6B8C6C21234
|
||||||
$mac = Faker::macAddress();
|
$mac = Faker::macAddress();
|
||||||
$md5 = md5($mac);
|
$md5 = md5($mac);
|
||||||
@ -61,4 +61,23 @@ class Generator
|
|||||||
return strtoupper("XY{$md5_arr[2]}{$md5_arr[12]}{$md5_arr[22]}{$md5}");
|
return strtoupper("XY{$md5_arr[2]}{$md5_arr[12]}{$md5_arr[22]}{$md5}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 获取颜文字信息
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function emoji(): string
|
||||||
|
{
|
||||||
|
$emoji_list = [
|
||||||
|
"(⌒▽⌒)", "( ̄▽ ̄)", "(=・ω・=)", "(`・ω・´)", "(〜 ̄△ ̄)〜", "(・∀・)",
|
||||||
|
"(°∀°)ノ", "( ̄3 ̄)", "╮( ̄▽ ̄)╭", "_(:3」∠)_", "( ´_ゝ`)", "←_←", "→_→",
|
||||||
|
"(<_<)", "(>_>)", "(;¬_¬)", '("▔□▔)/', "(゚Д゚≡゚д゚)!?", "Σ(゚д゚;)", "Σ(  ̄□ ̄||)",
|
||||||
|
"(´;ω;`)", "(/TДT)/", "(^・ω・^ )", "(。・ω・。)", "(● ̄(エ) ̄●)", "ε=ε=(ノ≧∇≦)ノ",
|
||||||
|
"(´・_・`)", "(-_-#)", "( ̄へ ̄)", "( ̄ε(# ̄) Σ", "ヽ(`Д´)ノ", "(#-_-)┯━┯",
|
||||||
|
"(╯°口°)╯(┴—┴", "←◡←", "( ♥д♥)", "Σ>―(〃°ω°〃)♡→", "⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄",
|
||||||
|
"(╬゚д゚)▄︻┻┳═一", "・*・:≡( ε:)", "(打卡)", "(签到)"
|
||||||
|
];
|
||||||
|
shuffle($emoji_list);
|
||||||
|
return $emoji_list[array_rand($emoji_list)];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ trait AllotTasks
|
|||||||
* @use 加载json数据
|
* @use 加载json数据
|
||||||
* @return Parser
|
* @return Parser
|
||||||
*/
|
*/
|
||||||
protected static function loadJsonData()
|
protected static function loadJsonData(): Parser
|
||||||
{
|
{
|
||||||
return Parser::fromFile(static::$repository);
|
return Parser::fromFile(static::$repository);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ abstract class BaseRaffle
|
|||||||
{
|
{
|
||||||
use TimeLock;
|
use TimeLock;
|
||||||
use FilterWords;
|
use FilterWords;
|
||||||
|
|
||||||
const ACTIVE_TITLE = '';
|
const ACTIVE_TITLE = '';
|
||||||
const ACTIVE_SWITCH = '';
|
const ACTIVE_SWITCH = '';
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ abstract class BaseRaffle
|
|||||||
|
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
if (getenv(static::ACTIVE_SWITCH) == 'false') {
|
if (!getEnable(static::ACTIVE_SWITCH)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (static::getLock() > time()) {
|
if (static::getLock() > time()) {
|
||||||
@ -103,7 +104,6 @@ abstract class BaseRaffle
|
|||||||
return $de_raw;
|
return $de_raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 解析抽奖信息
|
* @use 解析抽奖信息
|
||||||
* @param int $room_id
|
* @param int $room_id
|
||||||
@ -112,7 +112,6 @@ abstract class BaseRaffle
|
|||||||
*/
|
*/
|
||||||
abstract protected static function parseLotteryInfo(int $room_id, array $data): bool;
|
abstract protected static function parseLotteryInfo(int $room_id, array $data): bool;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 创建抽奖
|
* @use 创建抽奖
|
||||||
* @param array $raffles
|
* @param array $raffles
|
||||||
@ -120,7 +119,6 @@ abstract class BaseRaffle
|
|||||||
*/
|
*/
|
||||||
abstract protected static function createLottery(array $raffles): array;
|
abstract protected static function createLottery(array $raffles): array;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 解析抽奖返回
|
* @use 解析抽奖返回
|
||||||
* @param array $results
|
* @param array $results
|
||||||
@ -135,7 +133,7 @@ abstract class BaseRaffle
|
|||||||
* @param string $type
|
* @param string $type
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected static function arrKeySort($arr, $key, $type = 'asc')
|
protected static function arrKeySort($arr, $key, $type = 'asc'): array
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'desc':
|
case 'desc':
|
||||||
@ -149,7 +147,6 @@ abstract class BaseRaffle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 去重检测
|
* @use 去重检测
|
||||||
* @param $lid
|
* @param $lid
|
||||||
@ -179,7 +176,7 @@ abstract class BaseRaffle
|
|||||||
public static function pushToQueue(array $data): bool
|
public static function pushToQueue(array $data): bool
|
||||||
{
|
{
|
||||||
// 开关
|
// 开关
|
||||||
if (getenv(static::ACTIVE_SWITCH) == 'false') {
|
if (!getEnable(static::ACTIVE_SWITCH)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 黑屋
|
// 黑屋
|
||||||
|
|||||||
@ -42,7 +42,7 @@ trait TimeLock
|
|||||||
* @use used in Amp loop Delayed
|
* @use used in Amp loop Delayed
|
||||||
* @return delayed
|
* @return delayed
|
||||||
*/
|
*/
|
||||||
public static function Delayed()
|
public static function Delayed(): Delayed
|
||||||
{
|
{
|
||||||
return new Delayed(1000);
|
return new Delayed(1000);
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ trait TimeLock
|
|||||||
* @use 暂停状态
|
* @use 暂停状态
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function getPauseStatus()
|
public static function getPauseStatus(): bool
|
||||||
{
|
{
|
||||||
return static::$pause_status;
|
return static::$pause_status;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -104,7 +104,7 @@ trait XliveHeartBeat
|
|||||||
//成功在id为{room_id}的直播间发送第{ii}次心跳
|
//成功在id为{room_id}的直播间发送第{ii}次心跳
|
||||||
}
|
}
|
||||||
$minute = round(static::$_count_time / 60) - 1;
|
$minute = round(static::$_count_time / 60) - 1;
|
||||||
Log::info("已在直播间 $room_id 连续观看了 $minute 分钟");
|
Log::notice("已在直播间 $room_id 连续观看了 $minute 分钟");
|
||||||
return $r_data['heartbeat_interval'];
|
return $r_data['heartbeat_interval'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,7 +157,6 @@ trait XliveHeartBeat
|
|||||||
protected static function eHeartBeat(array $id): array
|
protected static function eHeartBeat(array $id): array
|
||||||
{
|
{
|
||||||
$url = 'https://live-trace.bilibili.com/xlive/data-interface/v1/x25Kn/E';
|
$url = 'https://live-trace.bilibili.com/xlive/data-interface/v1/x25Kn/E';
|
||||||
$user_info = User::parseCookies();
|
|
||||||
$payload = [
|
$payload = [
|
||||||
'id' => json_encode([$id[0], $id[1], $id[2], $id[3]], true),
|
'id' => json_encode([$id[0], $id[1], $id[2], $id[3]], true),
|
||||||
'device' => json_encode([Generator::hash(), Generator::uuid4()], true),
|
'device' => json_encode([Generator::hash(), Generator::uuid4()], true),
|
||||||
@ -165,8 +164,8 @@ trait XliveHeartBeat
|
|||||||
'is_patch' => 0,
|
'is_patch' => 0,
|
||||||
'heart_beat' => [],
|
'heart_beat' => [],
|
||||||
'ua' => static::$_user_agent,
|
'ua' => static::$_user_agent,
|
||||||
'csrf_token' => $user_info['token'],
|
'csrf_token' => getCsrf(),
|
||||||
'csrf' => $user_info['token'],
|
'csrf' => getCsrf(),
|
||||||
'visit_id' => ''
|
'visit_id' => ''
|
||||||
];
|
];
|
||||||
// print_r($payload);
|
// print_r($payload);
|
||||||
@ -299,12 +298,12 @@ trait XliveHeartBeat
|
|||||||
*/
|
*/
|
||||||
protected static function depend(): bool
|
protected static function depend(): bool
|
||||||
{
|
{
|
||||||
if (getenv('ENC_SERVER') == '') {
|
if (getConf('server', 'heartbeat_enc') == '') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 加载加密服务器
|
// 加载加密服务器
|
||||||
if (is_null(static::$_enc_server)) {
|
if (is_null(static::$_enc_server)) {
|
||||||
static::$_enc_server = getenv('ENC_SERVER');
|
static::$_enc_server = getConf('server', 'heartbeat_enc');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user