* 完善issue模板

完善issue模板

* imp:更新README,删除冗余内容。

* imp:更新README,删除冗余内容。

* imp:增加了鸣谢 区域

* v1.6.0.2

修正 多个API接口
优化 特别专题页任务判断
请注意,本脚本的签到功能对小米服务器暂已不可信,强烈建议在常用IP地使用

* 修正配置文件

修正 默认的onepush配置

* 修改api

* auto reformat by PyCharm

---------

Co-authored-by: 0-8-4 <ljd69154@liangjundi.cn>
This commit is contained in:
TardisX 2023-11-10 09:28:29 +08:00 committed by GitHub
parent 8c2540d8d1
commit 9ae162c26f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 105 additions and 118 deletions

BIN
.github/md_pic/jetbrains-variant-3.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

107
README.md
View File

@ -22,11 +22,11 @@
### **使用说明** ### **使用说明**
关于项目的详细使用方法请阅览 **[WiKi](https://github.com/0-8-4/miui-auto-tasks/wiki)** 项目支持本地、Docker、青龙面板等部署方式详细使用说明请参见 **[WiKi](https://github.com/0-8-4/miui-auto-tasks/wiki)**
### **项目依赖** ### **项目依赖**
1. 需要前往 Python 官网自行下载自己系统对应的 Python 版本,或使用自己系统对应的包管理安装,推荐至少 Python 3.6 以上 1. 需要前往 Python 官网自行下载自己系统对应的 Python 版本,或使用自己系统对应的包管理安装,推荐至少 Python 3.7 以上
``` ```
https://www.python.org/downloads/ https://www.python.org/downloads/
@ -39,92 +39,25 @@
注意:你可能需要使用管理员权限运行命令行 注意:你可能需要使用管理员权限运行命令行
### **快速上手**
1. 配置好 `config.yaml` 文件,并与 `miuitask.py` 文件放在同一个目录下
2. 使用终端 在 `miuitask.py` 所在目录下运行如下命令:
```bash
python3 miuitask.py
```
### **项目介绍** ### **项目介绍**
- [x] 支持 多账号 配置 - [x] 支持 多账号 配置
- [x] 支持 Docker 部署 - [x] 支持 Docker 部署
- [x] 支持 腾讯云函数 部署 - [x] 支持 青龙面板 部署
- [x] 支持 自动登录账号刷新社区 Cookie 以便于实现自动化 - [x] 支持 自动登录账号刷新社区 Cookie 以便于实现自动化
- [x] 绝大多数功能均可在配置文件中自行开关启用 - [x] 绝大多数功能均可在配置文件中自行开关启用
&#x26A0; 请注意,配置文件默认禁用了 MIUI Task 绝大多数模拟网络请求的功能能力,请注意修改配置文件按需启用。根据社区相关规则,模拟这些功能的网络请求可能存在一定风险。您需要自行承担使用本脚本的后果 &#x26A0; 请注意,配置文件默认禁用了 MIUI Task 绝大多数模拟网络请求的功能能力,请注意修改配置文件按需启用。根据社区相关规则,模拟这些功能的网络请求可能存在一定风险。您需要自行承担使用本脚本的后果
### **配置推送**
推送基于[onepush](https://github.com/y1ndan/onepush)
- 推送名称 / notifier: bark
参数大全 / params:
{'required': ['key'], 'optional': ['title', 'sound', 'isarchive', 'icon', 'group', 'url', 'copy', 'autocopy']}
- 推送名称 / notifier: custom
参数大全 / params:
{'required': ['url'], 'optional': ['method', 'datatype', 'data']}
- 推送名称 / notifier: dingtalk
参数大全 / params:
{'required': ['token'], 'optional': ['title', 'secret', 'markdown']}
- 推送名称 / notifier: discord
参数大全 / params:
{'required': ['webhook'], 'optional': ['title', 'username', 'avatar_url', 'color']}
- 推送名称 / notifier: pushplus
参数大全 / params:
{'required': ['token'], 'optional': ['title', 'topic', 'markdown']}
- 推送名称 / notifier: qmsg
参数大全 / params:
{'required': ['key'], 'optional': ['title', 'mode', 'qq']}
- 推送名称 / notifier: serverchan
参数大全 / params:
{'required': ['sckey', 'title'], 'optional': []}
- 推送名称 / notifier: serverchanturbo
参数大全 / params:
{'required': ['sctkey', 'title'], 'optional': ['channel', 'openid']}
- 推送名称 / notifier: telegram
参数大全 / params:
{'required': ['token', 'userid'], 'optional': ['title', 'api_url']}
- 推送名称 / notifier: wechatworkapp
参数大全 / params:
{'required': ['corpid', 'corpsecret', 'agentid'], 'optional': ['title', 'touser', 'markdown']}
- 推送名称 / notifier: wechatworkbot
参数大全 / params:
{'required': ['key'], 'optional': ['title', 'markdown']}
* **required为必填参数optional为选填参数**
配置参考:
```yaml
ONEPUSH:
notifier: telegram
params:
title:
markdown: false
token: 123456789:XXXXXXXXXXXXXXXXXXXXXXXX
userid: 114514
```
```yaml
ONEPUSH:
notifier: pushplus
params:
title:
token: XXXXXXXXXXXXXXXXXXXXXXXX
markdown: false
```
#### **其他** #### **其他**
* 在使用本脚本时请临时关闭网络代理工具及广告拦截程序 * 在使用本脚本时请临时关闭网络代理工具及广告拦截程序
* 在服务器上使用前建议先使用服务器IP登录 `https://account.xiaomi.com` * 在服务器上使用前建议先使用服务器IP登录 `https://account.xiaomi.com`
@ -134,7 +67,7 @@ ONEPUSH:
#### **贡献** #### **贡献**
如果你在使用过程中发现任何问题,可以 [提交 issue](https://github.com/0-8-4/miui-auto-tasks/issues/new) 或自行 Fork 修改后提交 Pull request 如果你在使用过程中发现任何问题,可以使用模板 [提交 issue](https://github.com/0-8-4/miui-auto-tasks/issues/new) 或自行 Fork 修改后提交 Pull request
如果你要提交 Pull request请确保你的代码风格和项目已有的代码保持一致遵循 [PEP 8](https://www.python.org/dev/peps/pep-0008) ,变量命名清晰,有适当的注释 如果你要提交 Pull request请确保你的代码风格和项目已有的代码保持一致遵循 [PEP 8](https://www.python.org/dev/peps/pep-0008) ,变量命名清晰,有适当的注释
@ -163,3 +96,15 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
``` ```
# **鸣谢**
## 社区
本项目所有贡献者感谢所有Star了本项目的人
[![Star History Chart](https://api.star-history.com/svg?repos=0-8-4/miui-auto-tasks&type=Date)](https://star-history.com/#0-8-4/miui-auto-tasks&Date)
## JetBrains
特别感谢 [JetBrains](https://www.jetbrains.com/) 为开源项目提供免费的 [PyCharm](https://www.jetbrains.com/pycharm/) 等 IDE 的授权
[<img src=".github/md_pic/jetbrains-variant-3.png" width="200"/>](https://www.jetbrains.com/)

View File

@ -35,7 +35,7 @@ accounts:
# board-follow: false # board-follow: false
# carrot-pull: false # carrot-pull: false
ONEPUSH: ONEPUSH:
notifier: telegram notifier: false
params: params:
title: title:
markdown: false markdown: false

View File

@ -54,7 +54,8 @@ class MIUITask:
'timestamp': sign[1] 'timestamp': sign[1]
} }
try: try:
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/content/announceThumbUp', headers=headers,params=data) response = requests.get('https://api.vip.miui.com/mtop/planet/vip/content/announceThumbUp', headers=headers,
params=data)
r_json = response.json() r_json = response.json()
if r_json['code'] == 401: if r_json['code'] == 401:
return w_log("点赞失败Cookie无效") return w_log("点赞失败Cookie无效")
@ -74,7 +75,8 @@ class MIUITask:
'postId': '36625780' 'postId': '36625780'
} }
try: try:
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/content/announceCancelThumbUp', headers=headers,params=data) response = requests.get('https://api.vip.miui.com/mtop/planet/vip/content/announceCancelThumbUp',
headers=headers, params=data)
r_json = response.json() r_json = response.json()
if r_json['code'] == 401: if r_json['code'] == 401:
return w_log("取消点赞失败Cookie无效") return w_log("取消点赞失败Cookie无效")
@ -112,13 +114,19 @@ class MIUITask:
'cookie': str(self.cookie) 'cookie': str(self.cookie)
} }
params = { params = {
'userId': str(self.uid), 'ref': 'vipAccountShortcut',
'pathname': '/mio/detail',
'version': 'dev.231026',
'miui_vip_ph': str(self.miui_vip_ph)
}
data = {
'action': 'BROWSE_POST_10S', 'action': 'BROWSE_POST_10S',
'miui_vip_ph': str(self.miui_vip_ph) 'miui_vip_ph': str(self.miui_vip_ph)
} }
try: try:
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByAction', response = requests.post(
params=params, headers=headers) 'https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByActionV2',
params=params, headers=headers, data=data)
r_json = response.json() r_json = response.json()
if r_json['status'] == 401: if r_json['status'] == 401:
return w_log("浏览帖子失败Cookie无效") return w_log("浏览帖子失败Cookie无效")
@ -136,12 +144,18 @@ class MIUITask:
'cookie': str(self.cookie) 'cookie': str(self.cookie)
} }
params = { params = {
'userId': str(self.uid), 'ref': 'vipAccountShortcut',
'pathname': '/mio/detail',
'version': 'dev.231026',
'miui_vip_ph': str(self.miui_vip_ph)
}
data = {
'action': 'BROWSE_SPECIAL_PAGES_USER_HOME', 'action': 'BROWSE_SPECIAL_PAGES_USER_HOME',
'miui_vip_ph': str(self.miui_vip_ph) 'miui_vip_ph': str(self.miui_vip_ph)
} }
try: try:
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByAction', response = requests.post(
'https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByActionV2',
params=params, headers=headers) params=params, headers=headers)
r_json = response.json() r_json = response.json()
if r_json['status'] == 401: if r_json['status'] == 401:
@ -160,13 +174,19 @@ class MIUITask:
'cookie': str(self.cookie) 'cookie': str(self.cookie)
} }
params = { params = {
'userId': str(self.uid), 'ref': 'vipAccountShortcut',
'pathname': '/mio/detail',
'version': 'dev.231026',
'miui_vip_ph': str(self.miui_vip_ph)
}
data = {
'action': 'BROWSE_SPECIAL_PAGES_SPECIAL_PAGE', 'action': 'BROWSE_SPECIAL_PAGES_SPECIAL_PAGE',
'miui_vip_ph': str(self.miui_vip_ph) 'miui_vip_ph': str(self.miui_vip_ph)
} }
try: try:
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByAction', response = requests.post(
params=params, headers=headers) 'https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByActionV2',
params=params, headers=headers, data=data)
r_json = response.json() r_json = response.json()
if r_json['status'] == 401: if r_json['status'] == 401:
return w_log("浏览专题页失败Cookie无效") return w_log("浏览专题页失败Cookie无效")
@ -191,7 +211,7 @@ class MIUITask:
response = requests.post( response = requests.post(
'https://api.vip.miui.com/api/community/board/follow?' 'https://api.vip.miui.com/api/community/board/follow?'
'&pathname=/mio/allboard&version=dev.20051', '&pathname=/mio/allboard&version=dev.20051',
headers=headers,params=params) headers=headers, params=params)
r_json = response.json() r_json = response.json()
if r_json['status'] == 401: if r_json['status'] == 401:
return w_log("加入小米圈子失败Cookie无效") return w_log("加入小米圈子失败Cookie无效")
@ -213,7 +233,7 @@ class MIUITask:
} }
try: try:
response = requests.post('https://api.vip.miui.com/api/community/board/unfollow?' response = requests.post('https://api.vip.miui.com/api/community/board/unfollow?'
'&pathname=/mio/allboard&version=dev.20051', headers=headers,params=params) '&pathname=/mio/allboard&version=dev.20051', headers=headers, params=params)
r_json = response.json() r_json = response.json()
if r_json['status'] == 401: if r_json['status'] == 401:
return w_log("退出小米圈子失败Cookie无效") return w_log("退出小米圈子失败Cookie无效")
@ -255,12 +275,15 @@ class MIUITask:
'cookie': str(self.cookie) 'cookie': str(self.cookie)
} }
params = { params = {
'ref': 'vipAccountShortcut',
'pathname': '/mio/checkIn',
'version': 'dev.231026',
'miui_vip_ph': str(self.miui_vip_ph) 'miui_vip_ph': str(self.miui_vip_ph)
} }
try: try:
response = requests.post( response = requests.post(
'https://api.vip.miui.com/mtop/planet/vip/user/checkinV2?ref=vipAccountShortcut&pathname=/mio/checkIn&version=dev.231107', 'https://api.vip.miui.com/mtop/planet/vip/user/checkinV2',
headers=headers,params=params) headers=headers, params=params)
r_json = response.json() r_json = response.json()
if r_json['status'] == 401: if r_json['status'] == 401:
return w_log("每日签到失败Cookie无效") return w_log("每日签到失败Cookie无效")
@ -281,7 +304,8 @@ class MIUITask:
'miui_vip_ph': str(self.miui_vip_ph) 'miui_vip_ph': str(self.miui_vip_ph)
} }
try: try:
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/app/init/start/infos', headers=headers,params=params) response = requests.get('https://api.vip.miui.com/mtop/planet/vip/app/init/start/infos', headers=headers,
params=params)
r_code = response.status_code r_code = response.status_code
if r_code == 401: if r_code == 401:
return w_log("登录社区失败Cookie无效") return w_log("登录社区失败Cookie无效")
@ -364,7 +388,8 @@ class MIUITask:
'cookie': str(self.cookie) 'cookie': str(self.cookie)
} }
try: try:
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/member/getCheckinPageCakeList', headers=headers) response = requests.get('https://api.vip.miui.com/mtop/planet/vip/member/getCheckinPageCakeList',
headers=headers)
r_json = response.json() r_json = response.json()
if r_json['status'] != 200: if r_json['status'] != 200:
w_log("获取每日任务状态失败:" + str(r_json['message'])) w_log("获取每日任务状态失败:" + str(r_json['message']))
@ -377,13 +402,16 @@ class MIUITask:
for daily_task in task['data']: for daily_task in task['data']:
task_status[daily_task['title']] = daily_task['showType'] task_status[daily_task['title']] = daily_task['showType']
task_name = daily_task['title'] task_name = daily_task['title']
task_desc = daily_task.get('desc', '')
task_completion_status = "完成" if daily_task['showType'] == 0 else "未完成" task_completion_status = "完成" if daily_task['showType'] == 0 else "未完成"
w_log("获取到信息: " + str(task_name) + ", " + str(task_completion_status)) task_status[task_name] = {'showType': daily_task['showType'], 'desc': task_desc}
w_log("获取到信息: " + str(task_name) + ", " + str(task_completion_status) + ", 描述: " + str(
task_desc))
return task_status return task_status
except Exception as e: except Exception as e:
w_log("获取信息出错") w_log("获取每日任务信息出错")
w_log(e) w_log(e)
return None return None
@ -401,7 +429,8 @@ class MIUITask:
'miui_vip_ph': str(self.miui_vip_ph) 'miui_vip_ph': str(self.miui_vip_ph)
} }
try: try:
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/member/getGrowUpPageData', headers=headers, params=params) response = requests.get('https://api.vip.miui.com/mtop/planet/vip/member/getGrowUpPageData',
headers=headers, params=params)
r_json = response.json() r_json = response.json()
your_point = re.findall(r"'title': '成长值'.*'title': '(\d+)'.*'title': '/'", str(r_json['entity']))[0] your_point = re.findall(r"'title': '成长值'.*'title': '(\d+)'.*'title': '/'", str(r_json['entity']))[0]
@ -426,7 +455,8 @@ def process_exception(e: Exception):
w_log('系统设置了代理,出现异常') w_log('系统设置了代理,出现异常')
def start(miui_task: MIUITask, check_in: bool, browse_post: bool, browse_user_page: bool, thumb_up: bool, browse_specialpage: bool, board_follow: bool, carrot_pull: bool): def start(miui_task: MIUITask, check_in: bool, browse_post: bool, browse_user_page: bool, thumb_up: bool,
browse_specialpage: bool, board_follow: bool, carrot_pull: bool):
if miui_task.mi_login(): if miui_task.mi_login():
w_log("本脚本用于模拟网络请求测试,仅供测试学习使用,禁止用于其他用途") w_log("本脚本用于模拟网络请求测试,仅供测试学习使用,禁止用于其他用途")
w_log("本脚本默认不做任何操作,如您愿意承担一切可能的后果,可编辑配置文件手动打开需要的功能") w_log("本脚本默认不做任何操作,如您愿意承担一切可能的后果,可编辑配置文件手动打开需要的功能")
@ -436,28 +466,30 @@ def start(miui_task: MIUITask, check_in: bool, browse_post: bool, browse_user_pa
if task_status is None: if task_status is None:
w_log("无法获取状态,将跳过多数模拟请求功能") w_log("无法获取状态,将跳过多数模拟请求功能")
else: else:
if "每日签到" in task_status and task_status.get("每日签到", 1) == 1 and check_in: if "每日签到" in task_status and task_status["每日签到"].get("showType", 0) == 1 and check_in:
w_log("模拟请求「每日签到」") w_log("模拟请求「每日签到」")
random_sleep() random_sleep()
miui_task.check_in() miui_task.check_in()
else: else:
w_log("自动跳过模拟请求「每日签到」") w_log("自动跳过模拟请求「每日签到」")
if "浏览帖子超过10秒" in task_status and task_status.get("浏览帖子超过10秒", 1) == 1 and browse_post: if "浏览帖子超过10秒" in task_status and task_status["浏览帖子超过10秒"].get("showType",
0) == 1 and browse_post:
w_log("模拟请求「浏览帖子超过10秒」") w_log("模拟请求「浏览帖子超过10秒」")
sleep_ten_sec_more() sleep_ten_sec_more()
miui_task.browse_post() miui_task.browse_post()
else: else:
w_log("自动跳过模拟请求「浏览帖子超过10秒」") w_log("自动跳过模拟请求「浏览帖子超过10秒」")
if "浏览个人/他人主页超过10秒" in task_status and task_status.get("浏览个人/他人主页超过10秒", 1) == 1 and browse_user_page: if "浏览个人/他人主页超过10秒" in task_status and task_status["浏览个人/他人主页超过10秒"].get("showType",
0) == 1 and browse_user_page:
w_log("模拟请求「浏览个人/他人主页超过10秒」") w_log("模拟请求「浏览个人/他人主页超过10秒」")
sleep_ten_sec_more() sleep_ten_sec_more()
miui_task.browse_user_page() miui_task.browse_user_page()
else: else:
w_log("自动跳过模拟请求「浏览个人/他人主页超过10秒」") w_log("自动跳过模拟请求「浏览个人/他人主页超过10秒」")
if "点赞他人帖子" in task_status and task_status.get("点赞他人帖子", 1) == 1 and thumb_up: if "点赞他人帖子" in task_status and task_status["点赞他人帖子"].get("showType", 0) == 1 and thumb_up:
w_log("模拟请求「点赞他人帖子」") w_log("模拟请求「点赞他人帖子」")
random_sleep() random_sleep()
miui_task.thumb_up() miui_task.thumb_up()
@ -466,14 +498,23 @@ def start(miui_task: MIUITask, check_in: bool, browse_post: bool, browse_user_pa
else: else:
w_log("自动跳过模拟请求「点赞他人帖子」") w_log("自动跳过模拟请求「点赞他人帖子」")
if "浏览指定专题页" in task_status and task_status.get("浏览指定专题页", 1) == 1 and browse_specialpage: special_page_desc = "浏览超过10秒成长值+1每日上限1分"
w_log("模拟请求「浏览指定专题页」") special_page_task = None
for task, details in task_status.items():
if special_page_desc in details.get('desc', '') and details.get('showType', 1) == 1:
special_page_task = task
break
if special_page_task and browse_specialpage:
w_log("模拟请求「" + str(special_page_task) + "")
sleep_ten_sec_more() sleep_ten_sec_more()
miui_task.browse_specialpage() miui_task.browse_specialpage()
else: else:
w_log("自动跳过模拟请求「浏览指定专题页」") w_log("自动跳过模拟请求「" + str(special_page_task) + "")
if "加入小米社区圈子" in task_status and task_status.get("加入小米社区圈子", 1) == 1 and board_follow: if "加入小米社区圈子" in task_status and task_status["加入小米社区圈子"].get("showType",
0) == 1 and board_follow:
w_log("模拟请求「加入小米社区圈子」") w_log("模拟请求「加入小米社区圈子」")
random_sleep() random_sleep()
miui_task.board_follow() miui_task.board_follow()
@ -491,7 +532,7 @@ def start(miui_task: MIUITask, check_in: bool, browse_post: bool, browse_user_pa
def main(): def main():
w_log("MIUI-AUTO-TASK v1.6.0.1") w_log("MIUI-AUTO-TASK v1.6.0.2")
w_log('---------- 系统信息 -------------') w_log('---------- 系统信息 -------------')
system_info() system_info()
w_log('---------- 项目信息 -------------') w_log('---------- 项目信息 -------------')
@ -512,7 +553,8 @@ def main():
w_log('---------- EXECUTING -------------') w_log('---------- EXECUTING -------------')
start( start(
MIUITask(i.get('uid'), i.get('password'), i.get('user-agent'), device_id=i.get('device-id')), MIUITask(i.get('uid'), i.get('password'), i.get('user-agent'), device_id=i.get('device-id')),
i.get('check-in'), i.get('browse-post'), i.get('browse-user-page'), i.get('thumb-up'), i.get('browse-specialpage'), i.get('board-follow'), i.get('carrot-pull') i.get('check-in'), i.get('browse-post'), i.get('browse-user-page'), i.get('thumb-up'),
i.get('browse-specialpage'), i.get('board-follow'), i.get('carrot-pull')
) )
time.sleep(5) time.sleep(5)
s_log(config.get('logging')) s_log(config.get('logging'))