├── utils ├── __init__.py └── utils.py ├── .gitignore ├── requirements.txt ├── .github ├── md_pic │ └── jetbrains-variant-3.png ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── feature_request.yml │ └── bug_report.yml └── workflows │ └── docker-image.yml ├── .idea └── .gitignore ├── Dockerfile ├── main.py ├── LICENSE ├── config.template.yaml ├── README.md └── miuitask.py /utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests>=2.25.1 2 | python-dotenv>=0.19.2 3 | PyYAML>=6.0 4 | onepush 5 | -------------------------------------------------------------------------------- /.github/md_pic/jetbrains-variant-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elysias123/miui-auto-tasks/HEAD/.github/md_pic/jetbrains-variant-3.png -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | 3 | contact_links: 4 | - name: 在 GitHub Discussions 讨论获得帮助 5 | url: https://github.com/0-8-4/miui-auto-tasks/discussions 6 | about: Have a question? Not sure if your issue affects everyone reproducibly? The quickest way to get help is on GitHub Discussions! 7 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Datasource local storage ignored files 5 | /dataSources/ 6 | /dataSources.local.xml 7 | # Editor-based HTTP Client requests 8 | /httpRequests/ 9 | /inspectionProfiles/profiles_settings.xml 10 | /inspectionProfiles/Project_Default.xml 11 | /misc.xml 12 | /miui-auto-tasks.iml 13 | /modules.xml 14 | /other.xml 15 | /vcs.xml 16 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.11.6-alpine 2 | 3 | COPY ./utils /srv/utils/ 4 | 5 | COPY ./requirements.txt /tmp 6 | 7 | COPY ./config.template.yaml ./miuitask.py ./main.py /srv/ 8 | 9 | COPY /srv/config.template.yaml /srv/config.yaml 10 | RUN pip install --no-cache-dir -i https://mirrors.bfsu.edu.cn/pypi/web/simple -r /tmp/requirements.txt && \ 11 | rm -rf /tmp/* 12 | 13 | WORKDIR /srv 14 | 15 | CMD ["python", "main.py"] 16 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from apscheduler.schedulers.blocking import BlockingScheduler 2 | from miuitask import main 3 | from utils.utils import get_config, w_log 4 | 5 | config = get_config() 6 | 7 | def timing(): 8 | try: 9 | hour = config.get('hour') 10 | minute = config.get('minute') 11 | sched = BlockingScheduler() 12 | sched.add_job(main, 'cron', hour=hour, minute=minute, id='auto_sign') 13 | w_log("已开启cron定时模式 每天{}时{}分内执行一次签到任务".format(hour, minute)) 14 | sched.start() 15 | except KeyboardInterrupt: 16 | pass 17 | except Exception as err: 18 | w_log("程序出现异常!\n:".err) 19 | timing() 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 東雲研究所 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/docker-image.yml: -------------------------------------------------------------------------------- 1 | # author: 0-8-4 2 | # date: 24-11-2022 18:34 AEDT 3 | # 4 | # This script is used to automatically build docker image and 5 | # push to DockerHub when every new release is published 6 | 7 | name: DockerHub CI 8 | 9 | on: 10 | release: 11 | types: [published] 12 | workflow_dispatch: 13 | 14 | env: 15 | DOCKERHUB_REPO: o1si/miui-auto-tasks 16 | 17 | jobs: 18 | build: 19 | runs-on: ubuntu-latest 20 | steps: 21 | - 22 | name: Set up QEMU 23 | uses: docker/setup-qemu-action@v2 24 | 25 | - 26 | name: Set up Docker Buildx 27 | uses: docker/setup-buildx-action@v2 28 | 29 | - 30 | name: Login to Docker Hub 31 | uses: docker/login-action@v2 32 | with: 33 | username: ${{ secrets.DOCKERHUB_USERNAME }} 34 | password: ${{ secrets.DOCKERHUB_TOKEN }} 35 | 36 | - 37 | name: Build and push 38 | uses: docker/build-push-action@v3 39 | with: 40 | push: true 41 | platforms: | 42 | linux/amd64 43 | linux/arm64 44 | tags: | 45 | ${{ env.DOCKERHUB_REPO }}:latest 46 | ${{ env.DOCKERHUB_REPO }}:${{ github.event.release.tag_name }} 47 | 48 | -------------------------------------------------------------------------------- /config.template.yaml: -------------------------------------------------------------------------------- 1 | accounts: 2 | - uid: 100000 3 | # 账户ID 非账户用户名或手机号 4 | password: Abcd.1234 5 | # 账户密码或其MD5哈希 6 | user-agent: 'Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Safari/537.36' 7 | # 登录社区时所用浏览器的 User-Agent 8 | # 可在此工具查看:https://tool.chinaz.com/useragent 9 | postid: 41559680 10 | # 例如:https://web.vip.miui.com/page/info/mio/mio/detail?postId=41559680 11 | # postid就是41559680 12 | # 功能开关 13 | check-in: false 14 | # 社区成长值签到,启用功能意味着你愿意自行承担相关风险 15 | browse-user-page: false 16 | # 社区浏览个人主页10秒,启用功能意味着你愿意自行承担相关风险 17 | browse-post: false 18 | # 社区浏览帖子10秒,启用功能意味着你愿意自行承担相关风险 19 | thumb-up: false 20 | # 点赞帖子,启用功能意味着你愿意自行承担相关风险 21 | browse-specialpage: false 22 | # 社区在活动期间可能会出现限时的“浏览指定专题页”任务,启用功能意味着你愿意自行承担相关风险 23 | board-follow: false 24 | # 社区可能会出现限时的“加入圈子”任务,启用功能意味着你愿意自行承担相关风险 25 | carrot-pull: false 26 | # 社区拔萝卜,启用功能意味着你愿意自行承担相关风险 27 | 28 | # 若有多个账户,按照以下模板进行修改,使用时删除前端 #注释 29 | # - uid: 100001 30 | # password: abc123 31 | # user-agent: 'Mozilla/5.0 (Android 11; Mobile; rv:95.0) Gecko/95.0 Firefox/95.0' 32 | # check-in: false 33 | # browse-user-page: false 34 | # browse-post: false 35 | # thumb-up: false 36 | # browse-specialpage: false 37 | # board-follow: false 38 | # carrot-pull: false 39 | ONEPUSH: 40 | notifier: false 41 | params: 42 | title: 43 | markdown: false 44 | token: 45 | userid: 46 | 47 | hour: 12-22 48 | minute: 0-59 49 | logging: false 50 | # 归档日志到本地文件 51 | version: v1.6.1 52 | # config 文件版本号,debug用 53 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: 功能请求 2 | description: Suggest an idea for this project 3 | title: "[Feature] " 4 | labels: [enhancement] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | 如果你可以自己 编程实现 的话, 建议您直接提交 PR 或 描述解决方法, 非常感谢! 10 | - type: checkboxes 11 | id: verify_step 12 | attributes: 13 | label: Verify Steps 14 | description: "在提交之前,请确认 / Please verify that you've followed these steps" 15 | options: 16 | - label: Tracker 我已经在 [Issue Tracker](……/) 中找过我要提出的问题 17 | required: true 18 | - label: Need 当前 MIUITask 并不包含该功能特性或者还不完善 19 | required: true 20 | - label: Framework 这是 MIUITask 应包含的特性, 并非实现社区外功能 21 | required: true 22 | - label: Meaningful 我提交的不是无意义的 催促更新或修复 请求 23 | required: true 24 | - type: textarea 25 | attributes: 26 | label: Describe the Feature 27 | description: | 28 | 对问题本身清晰而简洁的描述. 例如这个问题如何影响到你? 目前 MIUITask 的行为是什么? 29 | validations: 30 | required: true 31 | - type: textarea 32 | attributes: 33 | label: Describe the Solution 34 | description: | 35 | 清晰明了地描述您的解决方案. 例如你想实现什么 Feature 特性或功能? 如何实现该功能? 36 | validations: 37 | required: true 38 | - type: textarea 39 | attributes: 40 | label: Describe Alternatives 41 | description: | 42 | 对您考虑过的任何替代解决方案或备选功能进行清晰、简洁的描述. 43 | validations: 44 | required: false 45 | - type: textarea 46 | attributes: 47 | label: Additional Context 48 | description: | 49 | 在此处添加关于功能请求的任何其他描述或屏幕截图. 50 | validations: 51 | required: false 52 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: 问题反馈 2 | description: Create a report to help us improve 3 | title: "[Bug] " 4 | labels: ["bug"] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | 如果你可以自己 Debug 并解决的话, 建议您直接提交 PR 或 描述解决方法, 非常感谢! 10 | - type: checkboxes 11 | id: verify_step 12 | attributes: 13 | label: Verify Steps 14 | description: | 15 | 在提交之前, 请确认 / Please verify that you've followed these steps. 16 | options: 17 | - label: Tracker 我已经在 [Issue Tracker](……/) 中找过我要提出的问题 18 | required: true 19 | - label: Latest 我已经使用最新版本测试过,问题依旧存在 20 | required: true 21 | - label: Code 这是 MIUITask 自身代码存在的问题,并非我所使用的 网络 或 设备 等特定问题 22 | required: true 23 | - label: Meaningful 我提交的不是无意义的 催促更新或修复 请求 24 | required: true 25 | - type: input 26 | id: miuitask_version 27 | attributes: 28 | label: MIUITask Version 29 | description: | 30 | MIUITask 版本号 31 | placeholder: "v1.6.1" 32 | validations: 33 | required: true 34 | - type: dropdown 35 | id: bug_os 36 | attributes: 37 | label: Bug Found in Environment 38 | description: | 39 | 发现问题所在的系统环境 / System Environment 40 | multiple: true 41 | options: 42 | - Windows 43 | - macOS 44 | - Linux 45 | - Docker 46 | - Other 47 | validations: 48 | required: true 49 | - type: dropdown 50 | id: bug_pyversion 51 | attributes: 52 | label: Bug Found in Python Version 53 | description: | 54 | 发现问题所在的Python版本 / Python Version 55 | multiple: true 56 | options: 57 | - 3.12 58 | - 3.11 59 | - 3.10 60 | - 3.9 61 | - 3.8 62 | - 3.7 63 | - 3.6 64 | validations: 65 | required: true 66 | - type: textarea 67 | id: describe_bug 68 | attributes: 69 | label: Describe the Bug 70 | description: | 71 | 对Bug本身清晰而简洁的描述 / Describe the Bug 72 | validations: 73 | required: true 74 | - type: textarea 75 | id: miuitask_log 76 | attributes: 77 | label: MIUITask Log 78 | description: | 79 | 在下方附上 MIUITask 输出日志 / MIUItask Log 80 | validations: 81 | required: true 82 | - type: textarea 83 | id: miuitask_config 84 | attributes: 85 | label: MIUITask Config 86 | description: | 87 | 可选 在下方附上 MIUITask 配置文件 / MIUITask config 88 | 隐私提示: 上传此日志前请注意检查、隐去账号、密码等相关敏感信息 89 | render: shell 90 | validations: 91 | required: false 92 | - type: textarea 93 | id: screenshots 94 | attributes: 95 | label: Screenshots 96 | description: | 97 | 添加图片以帮助解释您的问题 / Screenshots 98 | validations: 99 | required: false 100 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MIUI Task 2 | 一个适用于 社区 4.0 模拟网络功能请求的脚本 3 | 4 | [![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu) ![GitHub](https://img.shields.io/github/license/0-8-4/miui-auto-tasks) 5 | ![Python](https://img.shields.io/badge/python-3.7+-blue) ![DockerHub](https://github.com/0-8-4/miui-auto-tasks/actions/workflows/docker-image.yml/badge.svg) 6 | 7 | ## 我们收到反馈,部分用户已收到通知要求不得继续随意调用社区接口,否则社区账户将被永久封禁。
鉴于以上情况,我们作为项目维护者建议停用脚本。
感谢大家的支持,谢谢所有Star和Fork的人。 8 | 9 | ## **关于项目**: 10 | 11 | 受`東雲研究所` 的某位大佬启发 12 | 最初的源码由大佬授权 `0-8-4` 使用 `MIT` 开源 13 | 项目初期由`0-8-4` 和 `TardisLX` 进行维护,现已逐渐转为社区驱动 14 | 我们认为社区无权在无任何回报的情况下强制要求内测用户完成 KPI 任务,因此诞生了这个脚本 15 | 16 | 17 | ## **重要声明**: 18 | - 虽然理论上本脚本不会影响社区账户安全,但您需要自行承担使用本脚本的后果 19 | 20 | - **我们不鼓励,不支持一切商业使用** 21 | - 鉴于项目的特殊性,我们可能在任何时间 **停止更新** 或 **删除项目** 22 | 23 | 24 | ### **使用说明**: 25 | 项目支持本地、Docker、青龙面板等部署方式,详细使用说明请参见 **[WiKi](https://github.com/0-8-4/miui-auto-tasks/wiki)** 26 | 27 | 28 | ### **项目依赖**: 29 | 1. 需要前往 Python 官网自行下载自己系统对应的 Python 版本,或使用自己系统对应的包管理安装,推荐至少 Python 3.7 以上 30 | 31 | ``` 32 | https://www.python.org/downloads/ 33 | ``` 34 | 35 | 2. Python 3 安装完成之后,请在 **项目目录** 执行以下命令安装所需模块 36 | ```bash 37 | pip install -r requirements.txt 38 | ``` 39 | 注意:你可能需要使用管理员权限运行命令行 40 | 41 | 42 | ### **快速上手**: 43 | 44 | 1. 将 `config.template.yaml` 重命名为 `config.yaml` 并设置好运行配置 45 | 2. 使用终端 运行如下命令: 46 | 47 | 立即执行: 48 | ```bash 49 | python3 miuitask.py 50 | ``` 51 | 52 | 定时执行: 53 | ```bash 54 | python3 main.py 55 | ``` 56 | 进程守护: 57 | 假设目录为:`/root/miui-auto-tasks` 58 | ```bash 59 | sudo cat <<'TEXT' > /etc/systemd/system/miuitask.service 60 | [Unit] 61 | Description=miuitask Daemon 62 | After=network.target 63 | 64 | [Install] 65 | WantedBy=multi-user.target 66 | 67 | [Service] 68 | Type=simple 69 | WorkingDirectory=/root/miui-auto-tasks 70 | ExecStart=/usr/bin/python3 main.py 71 | Restart=always 72 | TEXT 73 | ``` 74 | 75 | ### **项目介绍**: 76 | - [x] 支持 多账号 配置 77 | - [x] 支持 Docker 部署 78 | - [x] 支持 青龙面板 部署 79 | - [x] 支持 定时运行 80 | - [x] 支持 自动登录账号刷新社区 Cookie 以便于实现自动化 81 | - [x] 绝大多数功能均可在配置文件中自行开关启用 82 | 83 | ⚠ 请注意,配置文件默认禁用了 MIUI Task 绝大多数模拟网络请求的功能能力,请注意修改配置文件按需启用。根据社区相关规则,模拟这些功能的网络请求可能存在一定风险。您需要自行承担使用本脚本的后果 84 | 85 | #### **其他**: 86 | * 在使用本脚本时请临时关闭网络代理工具及广告拦截程序 87 | * 在服务器上使用前建议先使用服务器IP登录 `https://account.xiaomi.com` 88 | * **欢迎提供有关的思路,提交BUG以及更多完成社区其他任务方式,我们会认真对待~** 89 | 90 | 91 | #### **贡献**: 92 | 93 | 如果你在使用过程中发现任何问题,可以使用模板 [提交 issue](https://github.com/0-8-4/miui-auto-tasks/issues/new) 或自行 Fork 修改后提交 Pull request 94 | 95 | 如果你要提交 Pull request,请确保你的代码风格和项目已有的代码保持一致,遵循 [PEP 8](https://www.python.org/dev/peps/pep-0008) ,变量命名清晰,有适当的注释 96 | 97 | 98 | # **License** 99 | ``` 100 | MIT License 101 | 102 | Copyright (c) 2021 東雲研究所 103 | 104 | Permission is hereby granted, free of charge, to any person obtaining a copy 105 | of this software and associated documentation files (the "Software"), to deal 106 | in the Software without restriction, including without limitation the rights 107 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 108 | copies of the Software, and to permit persons to whom the Software is 109 | furnished to do so, subject to the following conditions: 110 | 111 | The above copyright notice and this permission notice shall be included in all 112 | copies or substantial portions of the Software. 113 | 114 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 115 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 116 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 117 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 118 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 119 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 120 | SOFTWARE. 121 | ``` 122 | 123 | # **鸣谢** 124 | ## 社区 125 | 126 | 本项目所有贡献者感谢所有Star了本项目的人 127 | 128 | [![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) 129 | 130 | ## JetBrains 131 | 132 | 特别感谢 [JetBrains](https://www.jetbrains.com/) 为开源项目提供免费的 [PyCharm](https://www.jetbrains.com/pycharm/) 等 IDE 的授权 133 | [](https://www.jetbrains.com/) 134 | -------------------------------------------------------------------------------- /utils/utils.py: -------------------------------------------------------------------------------- 1 | import os 2 | import random 3 | import time 4 | import platform 5 | import dotenv 6 | import yaml 7 | 8 | from hashlib import md5 9 | from onepush import notify 10 | from urllib.request import getproxies 11 | 12 | logs = '' 13 | message = '' 14 | config = {'account': []} 15 | CONFIG_VERSION_REQUIRE: str = 'v1.6.1' 16 | 17 | 18 | def md5_crypto(passwd: str) -> str: 19 | return md5(passwd.encode('utf8')).hexdigest() 20 | 21 | 22 | def show_info(tip, info): 23 | return "{}: {}".format(tip, info) 24 | 25 | 26 | def system_info(): 27 | w_log(show_info('操作系统平台', platform.platform())) 28 | w_log(show_info('操作系统版本', platform.version())) 29 | w_log(show_info('操作系统名称', platform.system())) 30 | w_log(show_info('操作系统位元', platform.architecture())) 31 | w_log(show_info('操作系统类型', platform.machine())) 32 | w_log(show_info('处理器信息', platform.processor())) 33 | w_log(show_info('Python 版本', str(platform.python_version()) + ' ' + str(platform.python_build()))) 34 | if getproxies(): 35 | w_log(show_info('系统代理', getproxies())) 36 | 37 | 38 | def get_config() -> dict: 39 | global config 40 | config_path_legacy = dotenv.find_dotenv(filename='config.env') 41 | config_path_yaml = dotenv.find_dotenv(filename='config.yaml') 42 | 43 | # yaml config 44 | if config_path_yaml: 45 | w_log('正在加载 ' + config_path_yaml + ' 配置文件') 46 | with open(config_path_yaml, "rb") as stream: 47 | try: 48 | config = yaml.safe_load(stream) 49 | config_version: str = config.get('version') 50 | 51 | # check config file version 52 | # if config version not meet the requirement 53 | if CONFIG_VERSION_REQUIRE != config_version: 54 | w_log('配置文件版本和程序运行要求版本不匹配,请检查配置文件') 55 | w_log('配置文件版本: ' + config_version) 56 | w_log('运行程序配置版本要求: ' + CONFIG_VERSION_REQUIRE) 57 | exit(1) # exit the program 58 | w_log('配置文件已成功加载,文件版本 ' + config_version) 59 | 60 | except yaml.YAMLError as e: 61 | w_log('配置文件载入错误') 62 | w_log(e) 63 | return config 64 | else: 65 | w_log('配置文件不存在') 66 | exit(1) 67 | 68 | 69 | def w_log(text): 70 | global logs 71 | global message 72 | now_localtime = time.strftime("%H:%M:%S", time.localtime()) 73 | logs += now_localtime + ' | ' + str(text) + '\n' 74 | message += str(text) + '\n' 75 | print(now_localtime + ' | ' + str(text)) 76 | 77 | 78 | def s_log(flag): 79 | if flag: 80 | global logs 81 | folder = os.path.exists('./logs') 82 | if not folder: 83 | os.makedirs('./logs') 84 | now_localtime = time.strftime("%Y-%m-%d", time.localtime()) 85 | fname = now_localtime + '.log' 86 | with open('./logs/' + fname, 'a+', encoding='utf-8') as f: 87 | f.write(logs) 88 | 89 | 90 | def check_config(config: dict) -> bool: 91 | if config.get('accounts'): 92 | for i in config.get('accounts'): 93 | if not i.get('uid') or not i.get('password') or not i.get('user-agent'): 94 | return False 95 | if not isinstance(i.get('check-in'), bool): 96 | return False 97 | if not isinstance(i.get('browse-user-page'), bool): 98 | return False 99 | if not isinstance(i.get('browse-post'), bool): 100 | return False 101 | if not isinstance(i.get('thumb-up'), bool): 102 | return False 103 | if not isinstance(i.get('browse-specialpage'), bool): 104 | return False 105 | if not isinstance(i.get('board-follow'), bool): 106 | return False 107 | if not isinstance(i.get('carrot-pull'), bool): 108 | return False 109 | else: 110 | return False 111 | if not isinstance(config.get('logging'), bool): 112 | return False 113 | return True 114 | 115 | 116 | def format_config(config: dict) -> dict: 117 | for i in config.get('accounts'): 118 | i['uid'] = str(i.get('uid')) 119 | i['user-agent'] = str(i.get('user-agent')) 120 | if len(i.get('password')) != 32: 121 | i['password'] = md5_crypto(i.get('password')).upper() 122 | else: 123 | i['password'] = str(i.get('password')).upper() 124 | if i.get('device-id'): 125 | i['device-id'] = str(i.get('device-id')) 126 | else: 127 | i['device-id'] = None 128 | return config 129 | 130 | 131 | def random_sleep(): 132 | time.sleep(random.randint(1, 9)) 133 | 134 | 135 | def sleep_ten_sec_more(): 136 | time.sleep(random.randint(10, 12)) 137 | 138 | 139 | def notify_me(content=None): 140 | """ 141 | 默认推送日志 142 | """ 143 | global message 144 | global config 145 | if not content: 146 | content = message 147 | notifier = config.get('ONEPUSH', {}).get('notifier', '') 148 | params = config.get('ONEPUSH', {}).get('params', '') 149 | if not notifier or not params: 150 | s_log('未配置推送或未正确配置推送') 151 | return 152 | if not config.get('ONEPUSH', {}).get('title', ''): 153 | config['ONEPUSH']['title'] = '' 154 | return notify(notifier, content=content, **params) 155 | -------------------------------------------------------------------------------- /miuitask.py: -------------------------------------------------------------------------------- 1 | # -- coding:UTF-8 -- 2 | import re 3 | import requests 4 | import time 5 | import json 6 | import hashlib 7 | 8 | from urllib import request 9 | from http import cookiejar 10 | from typing import Any, Tuple 11 | 12 | from utils.utils import system_info, get_config, w_log, s_log, check_config, format_config, random_sleep, \ 13 | sleep_ten_sec_more, notify_me 14 | 15 | 16 | class MIUITask: 17 | 18 | def __init__(self, uid, password, user_agent, postid, device_id): 19 | self.uid = uid 20 | self.password = password 21 | self.user_agent = user_agent 22 | self.postid = postid 23 | self.device_id = device_id 24 | 25 | # 留空 26 | self.cookie = '' 27 | # 留空 28 | self.miui_vip_ph = '' 29 | 30 | # 签名 31 | def post_sign(self, data): 32 | s_data = [] 33 | for d in data: 34 | s_data.append(str(d) + '=' + str(data[d])) 35 | s_str = '&'.join(s_data) 36 | w_log('签名原文:' + str(s_str)) 37 | s_str = hashlib.md5(str(s_str).encode(encoding='UTF-8')).hexdigest() + '067f0q5wds4' 38 | s_sign = hashlib.md5(str(s_str).encode(encoding='UTF-8')).hexdigest() 39 | w_log('签名结果:' + str(s_sign)) 40 | return s_sign, data['timestamp'] 41 | 42 | # 点赞 43 | def thumb_up(self): 44 | headers = { 45 | 'cookie': str(self.cookie) 46 | } 47 | sign_data = { 48 | 'postId': self.postid, 49 | 'timestamp': int(round(time.time() * 1000)) 50 | } 51 | sign = self.post_sign(sign_data) 52 | data = { 53 | 'postId': self.postid, 54 | 'sign': sign[0], 55 | 'timestamp': sign[1] 56 | } 57 | try: 58 | response = requests.get('https://api.vip.miui.com/mtop/planet/vip/content/announceThumbUp', headers=headers, 59 | params=data) 60 | r_json = response.json() 61 | if r_json['code'] == 401: 62 | return w_log("点赞失败:Cookie无效") 63 | elif r_json['code'] != 200: 64 | return w_log("点赞失败:" + str(r_json['message'])) 65 | w_log("点赞成功") 66 | except Exception as e: 67 | w_log("点赞出错") 68 | w_log(e) 69 | 70 | # 取消点赞 71 | def cancel_thumb_up(self): 72 | headers = { 73 | 'cookie': str(self.cookie) 74 | } 75 | data = { 76 | 'postId': self.postid 77 | } 78 | try: 79 | response = requests.get('https://api.vip.miui.com/mtop/planet/vip/content/announceCancelThumbUp', 80 | headers=headers, params=data) 81 | r_json = response.json() 82 | if r_json['code'] == 401: 83 | return w_log("取消点赞失败:Cookie无效") 84 | elif r_json['code'] != 200: 85 | return w_log("取消点赞失败:" + str(r_json['message'])) 86 | w_log("取消点赞成功") 87 | except Exception as e: 88 | w_log("取消点赞出错") 89 | w_log(e) 90 | 91 | def get_vip_cookie(self, url): 92 | 93 | try: 94 | r_cookie = cookiejar.CookieJar() 95 | handler = request.HTTPCookieProcessor(r_cookie) 96 | opener = request.build_opener(handler) 97 | response = opener.open(url) 98 | for item in r_cookie: 99 | self.cookie += item.name + '=' + item.value + ';' 100 | if self.cookie == '': 101 | return False 102 | ck_list = self.cookie.replace(" ", "").split(';') 103 | for ph in ck_list: 104 | if "miui_vip_ph=" in ph: 105 | self.miui_vip_ph = ph.replace("miui_vip_ph=", "") 106 | break 107 | return True 108 | except Exception as e: 109 | w_log(e) 110 | return False 111 | 112 | # 浏览帖子10s 113 | def browse_post(self): 114 | headers = { 115 | 'cookie': str(self.cookie) 116 | } 117 | params = { 118 | 'ref': 'vipAccountShortcut', 119 | 'pathname': '/mio/detail', 120 | 'version': 'dev.231026', 121 | 'miui_vip_ph': str(self.miui_vip_ph) 122 | } 123 | data = { 124 | 'action': 'BROWSE_POST_10S', 125 | 'miui_vip_ph': str(self.miui_vip_ph) 126 | } 127 | try: 128 | response = requests.post( 129 | 'https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByActionV2', 130 | params=params, headers=headers, data=data) 131 | r_json = response.json() 132 | if r_json['status'] == 401: 133 | return w_log("浏览帖子失败:Cookie无效") 134 | elif r_json['status'] != 200: 135 | return w_log("浏览帖子完成,但有错误:" + str(r_json['message'])) 136 | score = r_json['entity']['score'] 137 | w_log("浏览帖子完成,成长值+" + str(score)) 138 | except Exception as e: 139 | w_log("浏览帖子出错") 140 | w_log(e) 141 | 142 | # 浏览个人主页10s 143 | def browse_user_page(self): 144 | headers = { 145 | 'cookie': str(self.cookie) 146 | } 147 | params = { 148 | 'ref': 'vipAccountShortcut', 149 | 'pathname': '/mio/detail', 150 | 'version': 'dev.231026', 151 | 'miui_vip_ph': str(self.miui_vip_ph) 152 | } 153 | data = { 154 | 'action': 'BROWSE_SPECIAL_PAGES_USER_HOME', 155 | 'miui_vip_ph': str(self.miui_vip_ph) 156 | } 157 | try: 158 | response = requests.post( 159 | 'https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByActionV2', 160 | params=params, headers=headers) 161 | r_json = response.json() 162 | if r_json['status'] == 401: 163 | return w_log("浏览个人主页失败:Cookie无效") 164 | elif r_json['status'] != 200: 165 | return w_log("浏览个人主页完成,但有错误:" + str(r_json['message'])) 166 | score = r_json['entity']['score'] 167 | w_log("浏览个人主页完成,成长值+" + str(score)) 168 | except Exception as e: 169 | w_log("浏览个人主页出错") 170 | w_log(e) 171 | 172 | # 浏览指定专题页 173 | def browse_specialpage(self): 174 | headers = { 175 | 'cookie': str(self.cookie) 176 | } 177 | params = { 178 | 'ref': 'vipAccountShortcut', 179 | 'pathname': '/mio/detail', 180 | 'version': 'dev.231026', 181 | 'miui_vip_ph': str(self.miui_vip_ph) 182 | } 183 | data = { 184 | 'action': 'BROWSE_SPECIAL_PAGES_SPECIAL_PAGE', 185 | 'miui_vip_ph': str(self.miui_vip_ph) 186 | } 187 | try: 188 | response = requests.post( 189 | 'https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByActionV2', 190 | params=params, headers=headers, data=data) 191 | r_json = response.json() 192 | if r_json['status'] == 401: 193 | return w_log("浏览专题页失败:Cookie无效") 194 | elif r_json['status'] != 200: 195 | return w_log("浏览专题页完成,但有错误:" + str(r_json['message'])) 196 | score = r_json['entity']['score'] 197 | w_log("浏览专题页完成,成长值+" + str(score)) 198 | except Exception as e: 199 | w_log("浏览专题页出错") 200 | w_log(e) 201 | 202 | # 加入小米圈子 203 | def board_follow(self): 204 | headers = { 205 | 'cookie': str(self.cookie) 206 | } 207 | params = { 208 | 'boardId': '558495', 209 | 'miui_vip_ph': str(self.miui_vip_ph) 210 | } 211 | try: 212 | response = requests.post( 213 | 'https://api.vip.miui.com/api/community/board/follow?' 214 | '&pathname=/mio/allboard&version=dev.20051', 215 | headers=headers, params=params) 216 | r_json = response.json() 217 | if r_json['status'] == 401: 218 | return w_log("加入小米圈子失败:Cookie无效") 219 | elif r_json['status'] != 200: 220 | return w_log("加入小米圈子失败:" + str(r_json['message'])) 221 | w_log("加入小米圈子结果:" + str(r_json['message'])) 222 | except Exception as e: 223 | w_log("加入小米圈子出错") 224 | w_log(e) 225 | 226 | # 退出小米圈子 227 | def board_unfollow(self): 228 | headers = { 229 | 'cookie': str(self.cookie) 230 | } 231 | params = { 232 | 'boardId': '558495', 233 | 'miui_vip_ph': str(self.miui_vip_ph) 234 | } 235 | try: 236 | response = requests.post('https://api.vip.miui.com/api/community/board/unfollow?' 237 | '&pathname=/mio/allboard&version=dev.20051', headers=headers, params=params) 238 | r_json = response.json() 239 | if r_json['status'] == 401: 240 | return w_log("退出小米圈子失败:Cookie无效") 241 | elif r_json['status'] != 200: 242 | return w_log("退出小米圈子失败:" + str(r_json['message'])) 243 | w_log("退出小米圈子结果:" + str(r_json['message'])) 244 | except Exception as e: 245 | w_log("退出小米圈子出错") 246 | w_log(e) 247 | 248 | # 社区拔萝卜 249 | def carrot_pull(self): 250 | headers = { 251 | 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8', 252 | 'cookie': str(self.cookie) 253 | } 254 | data = { 255 | 'miui_vip_ph': str(self.miui_vip_ph) 256 | } 257 | try: 258 | response = requests.post('https://api.vip.miui.com/api/carrot/pull', headers=headers, 259 | data=data) 260 | r_json = response.json() 261 | if r_json['code'] == 401: 262 | return w_log("社区拔萝卜失败:Cookie无效") 263 | elif r_json['code'] != 200: 264 | return w_log("社区拔萝卜失败:" + str(r_json['entity']['message'])) 265 | w_log("社区拔萝卜结果:" + str(r_json['entity']['message'])) 266 | money_count = r_json['entity']['header']['moneyCount'] 267 | w_log("当前金币数:" + str(money_count)) 268 | except Exception as e: 269 | w_log("社区拔萝卜出错") 270 | w_log(e) 271 | 272 | # 每日签到 273 | def check_in(self): 274 | headers = { 275 | 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8', 276 | 'cookie': str(self.cookie) 277 | } 278 | params = { 279 | 'ref': 'vipAccountShortcut', 280 | 'pathname': '/mio/checkIn', 281 | 'version': 'dev.231026', 282 | 'miui_vip_ph': str(self.miui_vip_ph) 283 | } 284 | try: 285 | response = requests.post( 286 | 'https://api.vip.miui.com/mtop/planet/vip/user/checkinV2', 287 | headers=headers, params=params) 288 | r_json = response.json() 289 | if r_json['status'] == 401: 290 | return w_log("每日签到失败:Cookie无效") 291 | elif r_json['status'] != 200: 292 | return w_log("每日签到失败:" + str(r_json['message'])) 293 | w_log("每日签到结果:成长值+" + str(r_json['entity'])) 294 | except Exception as e: 295 | w_log("每日签到出错") 296 | w_log(e) 297 | 298 | # 登录社区 299 | def login_app(self): 300 | headers = { 301 | 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8', 302 | 'cookie': str(self.cookie) 303 | } 304 | params = { 305 | 'miui_vip_ph': str(self.miui_vip_ph) 306 | } 307 | try: 308 | response = requests.get('https://api.vip.miui.com/mtop/planet/vip/app/init/start/infos', headers=headers, 309 | params=params) 310 | r_code = response.status_code 311 | if r_code == 401: 312 | return w_log("登录社区失败:Cookie无效") 313 | elif r_code != 200: 314 | return w_log("登录社区失败") 315 | w_log("登录社区成功") 316 | except Exception as e: 317 | w_log("登录社区出错") 318 | w_log(e) 319 | 320 | def mi_login(self): 321 | proxies = { 322 | 'https': None, 323 | 'http': None 324 | } 325 | headers = { 326 | 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 327 | 'Referer': 'https://account.xiaomi.com/fe/service/login/password?sid=miui_vip&qs=%253Fcallback%253Dhttp' 328 | '%25253A%25252F%25252Fapi.vip.miui.com%25252Fsts%25253Fsign%25253D4II4ABwZkiJzkd2YSkyEZukI4Ak' 329 | '%2525253D%252526followup%25253Dhttps%2525253A%2525252F%2525252Fapi.vip.miui.com%2525252Fpage' 330 | '%2525252Flogin%2525253FdestUrl%2525253Dhttps%252525253A%252525252F%252525252Fweb.vip.miui.com' 331 | '%252525252Fpage%252525252Finfo%252525252Fmio%252525252Fmio%252525252FinternalTest%252525253Fref' 332 | '%252525253Dhomepage%2526sid%253Dmiui_vip&callback=http%3A%2F%2Fapi.vip.miui.com%2Fsts%3Fsign' 333 | '%3D4II4ABwZkiJzkd2YSkyEZukI4Ak%253D%26followup%3Dhttps%253A%252F%252Fapi.vip.miui.com%252Fpage' 334 | '%252Flogin%253FdestUrl%253Dhttps%25253A%25252F%25252Fweb.vip.miui.com%25252Fpage%25252Finfo' 335 | '%25252Fmio%25252Fmio%25252FinternalTest%25253Fref%25253Dhomepage&_sign=L%2BdSQY6sjSQ%2FCRjJs4p' 336 | '%2BU1vNYLY%3D&serviceParam=%7B%22checkSafePhone%22%3Afalse%2C%22checkSafeAddress%22%3Afalse%2C' 337 | '%22lsrp_score%22%3A0.0%7D&showActiveX=false&theme=&needTheme=false&bizDeviceType=', 338 | 'User-Agent': str(self.user_agent), 339 | 'Origin': 'https://account.xiaomi.com', 340 | 'X-Requested-With': 'XMLHttpRequest', 341 | 'Cookie': 'deviceId=' + str(self.device_id) + '; pass_ua=web; uLocale=zh_CN' 342 | } 343 | data = { 344 | 'bizDeviceType': '', 345 | 'needTheme': 'false', 346 | 'theme': '', 347 | 'showActiveX': 'false', 348 | 'serviceParam': '{"checkSafePhone":false,"checkSafeAddress":false,"lsrp_score":0.0}', 349 | 'callback': 'http://api.vip.miui.com/sts?sign=4II4ABwZkiJzkd2YSkyEZukI4Ak%3D&followup=https%3A%2F%2Fapi.vip' 350 | '.miui.com%2Fpage%2Flogin%3FdestUrl%3Dhttps%253A%252F%252Fweb.vip.miui.com%252Fpage%252Finfo' 351 | '%252Fmio%252Fmio%252FinternalTest%253Fref%253Dhomepage', 352 | 'qs': '%3Fcallback%3Dhttp%253A%252F%252Fapi.vip.miui.com%252Fsts%253Fsign%253D4II4ABwZkiJzkd2YSkyEZukI4Ak' 353 | '%25253D%2526followup%253Dhttps%25253A%25252F%25252Fapi.vip.miui.com%25252Fpage%25252Flogin' 354 | '%25253FdestUrl%25253Dhttps%2525253A%2525252F%2525252Fweb.vip.miui.com%2525252Fpage%2525252Finfo' 355 | '%2525252Fmio%2525252Fmio%2525252FinternalTest%2525253Fref%2525253Dhomepage%26sid%3Dmiui_vip', 356 | 'sid': 'miui_vip', 357 | '_sign': 'L+dSQY6sjSQ/CRjJs4p+U1vNYLY=', 358 | 'user': str(self.uid), 359 | 'cc': '+86', 360 | 'hash': str(self.password), 361 | '_json': 'true' 362 | } 363 | try: 364 | response = requests.post('https://account.xiaomi.com/pass/serviceLoginAuth2', headers=headers, data=data, 365 | proxies=proxies) 366 | response_data = response.text.lstrip('&').lstrip('START').lstrip('&') 367 | r_json = json.loads(response_data) 368 | if r_json['code'] == 70016: 369 | w_log('小米账号登录失败:用户名或密码不正确') 370 | return False 371 | if r_json['code'] != 0: 372 | w_log('小米账号登录失败:' + r_json['desc']) 373 | return False 374 | if r_json['pwd'] != 1: 375 | w_log('当前账号需要短信验证码,请尝试修改UA或设备ID') 376 | return False 377 | if not self.get_vip_cookie(r_json['location']): 378 | w_log('小米账号登录成功,社区获取 Cookie 失败') 379 | return False 380 | w_log('账号登录完成') 381 | return True 382 | except Exception as e: 383 | w_log("登录小米账号出错") 384 | w_log(e) 385 | return False 386 | 387 | def check_daily_tasks(self): 388 | headers = { 389 | 'cookie': str(self.cookie) 390 | } 391 | try: 392 | response = requests.get('https://api.vip.miui.com/mtop/planet/vip/member/getCheckinPageCakeList', 393 | headers=headers) 394 | r_json = response.json() 395 | if r_json['status'] != 200: 396 | w_log("获取每日任务状态失败:" + str(r_json['message'])) 397 | return None 398 | 399 | tasks = r_json['entity'] 400 | task_status = {} 401 | for task in tasks: 402 | if task['head']['title'] == "每日任务": 403 | for daily_task in task['data']: 404 | task_status[daily_task['title']] = daily_task['showType'] 405 | task_name = daily_task['title'] 406 | task_desc = daily_task.get('desc', '') 407 | task_completion_status = "完成" if daily_task['showType'] == 0 else "未完成" 408 | task_status[task_name] = {'showType': daily_task['showType'], 'desc': task_desc} 409 | w_log("获取到信息: " + str(task_name) + ", " + str(task_completion_status) + ", 描述: " + str( 410 | task_desc)) 411 | 412 | return task_status 413 | 414 | except Exception as e: 415 | w_log("获取每日任务信息出错") 416 | w_log(e) 417 | return None 418 | 419 | def get_point(self) -> Tuple[Any, Any]: 420 | """ 421 | 这个方法带返回值的原因是,可以调用这个方法获取返回值,可根据这个方法定制自己的“消息提示功能”。 422 | 如:Qmsg发送到QQ 或者 发送邮件提醒 423 | :return: 当前的成长值 424 | """ 425 | headers = { 426 | 'cookie': str(self.cookie) 427 | } 428 | params = { 429 | 'userId': str(self.uid), 430 | 'miui_vip_ph': str(self.miui_vip_ph) 431 | } 432 | try: 433 | response = requests.get('https://api.vip.miui.com/mtop/planet/vip/member/getGrowUpPageData', 434 | headers=headers, params=params) 435 | r_json = response.json() 436 | 437 | your_point = re.findall(r"'title': '成长值'.*'title': '(\d+)'.*'title': '/'", str(r_json['entity']))[0] 438 | your_level = re.findall(r"'title': '(\d+段)', 'desc': '当前等级'", str(r_json['entity']))[0] 439 | 440 | w_log('当前等级:' + str(your_level) + ', 当前成长值:' + str(your_point)) 441 | 442 | return your_point, your_level 443 | except Exception as e: 444 | w_log('成长值和等级获取失败') 445 | w_log(e) 446 | process_exception(e) 447 | 448 | 449 | def process_exception(e: Exception): 450 | """ 451 | 全局异常处理 452 | :param e: 异常实例 453 | :return: No return 454 | """ 455 | if e.__str__() == 'check_hostname requires server_hostname': 456 | w_log('系统设置了代理,出现异常') 457 | 458 | 459 | def start(miui_task: MIUITask, check_in: bool, browse_post: bool, browse_user_page: bool, thumb_up: bool, 460 | browse_specialpage: bool, board_follow: bool, carrot_pull: bool): 461 | if miui_task.mi_login(): 462 | w_log("本脚本用于模拟网络请求测试,仅供测试学习使用,禁止用于其他用途") 463 | w_log("本脚本默认不做任何操作,如您愿意承担一切可能的后果,可编辑配置文件手动打开需要的功能") 464 | w_log("为避免重复模拟请求,脚本将自动获取状态并决定是否继续模拟网络请求") 465 | miui_task.login_app() 466 | task_status = miui_task.check_daily_tasks() 467 | if task_status is None: 468 | w_log("无法获取状态,将跳过多数模拟请求功能") 469 | else: 470 | if "每日签到" in task_status and task_status["每日签到"].get("showType", 0) == 1 and check_in: 471 | w_log("模拟请求「每日签到」") 472 | random_sleep() 473 | miui_task.check_in() 474 | else: 475 | w_log("自动跳过模拟请求「每日签到」") 476 | 477 | if "浏览帖子超过10秒" in task_status and task_status["浏览帖子超过10秒"].get("showType", 478 | 0) == 1 and browse_post: 479 | w_log("模拟请求「浏览帖子超过10秒」") 480 | sleep_ten_sec_more() 481 | miui_task.browse_post() 482 | else: 483 | w_log("自动跳过模拟请求「浏览帖子超过10秒」") 484 | 485 | if "浏览个人/他人主页超过10秒" in task_status and task_status["浏览个人/他人主页超过10秒"].get("showType", 486 | 0) == 1 and browse_user_page: 487 | w_log("模拟请求「浏览个人/他人主页超过10秒」") 488 | sleep_ten_sec_more() 489 | miui_task.browse_user_page() 490 | else: 491 | w_log("自动跳过模拟请求「浏览个人/他人主页超过10秒」") 492 | 493 | if "点赞他人帖子" in task_status and task_status["点赞他人帖子"].get("showType", 0) == 1 and thumb_up: 494 | w_log("模拟请求「点赞他人帖子」") 495 | random_sleep() 496 | miui_task.thumb_up() 497 | random_sleep() 498 | miui_task.cancel_thumb_up() 499 | else: 500 | w_log("自动跳过模拟请求「点赞他人帖子」") 501 | 502 | special_page_desc = "浏览超过10秒成长值+1,每日上限1分" 503 | special_page_task = None 504 | 505 | for task, details in task_status.items(): 506 | if special_page_desc in details.get('desc', '') and details.get('showType', 1) == 1: 507 | special_page_task = task 508 | break 509 | 510 | if special_page_task and browse_specialpage: 511 | w_log("模拟请求「" + str(special_page_task) + "」") 512 | sleep_ten_sec_more() 513 | miui_task.browse_specialpage() 514 | else: 515 | w_log("自动跳过模拟请求「" + str(special_page_task) + "」") 516 | 517 | if "加入小米社区圈子" in task_status and task_status["加入小米社区圈子"].get("showType", 518 | 0) == 1 and board_follow: 519 | w_log("模拟请求「加入小米社区圈子」") 520 | random_sleep() 521 | miui_task.board_follow() 522 | random_sleep() 523 | miui_task.board_unfollow() 524 | else: 525 | w_log("自动跳过模拟请求「加入小米社区圈子」") 526 | w_log("请注意,未在配置文件启用或不需要执行的功能请求将被自动跳过,且不会支持“灌水”的功能") 527 | if carrot_pull: 528 | w_log("模拟请求「社区拔萝卜」") 529 | random_sleep() 530 | miui_task.carrot_pull() 531 | random_sleep() 532 | miui_task.get_point() 533 | 534 | 535 | def main(): 536 | try: 537 | if __name__ != "main.py": 538 | config = get_config() 539 | w_log("MIUI-AUTO-TASK v1.6.1") 540 | w_log('---------- 系统信息 -------------') 541 | system_info() 542 | w_log('---------- 项目信息 -------------') 543 | w_log("这是一个免费且开源的项目,如果你是付费购买获得请务必退款") 544 | w_log("项目地址:https://github.com/0-8-4/miui-auto-tasks") 545 | w_log("欢迎 star,感谢東雲研究所中的大佬") 546 | w_log('---------- 配置检测 -------------') 547 | 548 | if not check_config(config): 549 | w_log('配置文件没有正确配置') 550 | exit(1) 551 | else: 552 | config = format_config(config) 553 | 554 | for i in config.get('accounts'): 555 | w_log('---------- EXECUTING -------------') 556 | start( 557 | MIUITask(i.get('uid'), i.get('password'), i.get('user-agent'), i.get('postid'), device_id=i.get('device-id')), 558 | i.get('check-in'), i.get('browse-post'), i.get('browse-user-page'), i.get('thumb-up'), 559 | i.get('browse-specialpage'), i.get('board-follow'), i.get('carrot-pull') 560 | ) 561 | time.sleep(5) 562 | s_log(config.get('logging')) 563 | notify_me() 564 | except KeyboardInterrupt: 565 | pass 566 | except Exception as err: 567 | w_log("程序出现异常!\n:".err) 568 | 569 | def main_handler(event, context): 570 | main() 571 | 572 | 573 | if __name__ == "__main__": 574 | main() 575 | --------------------------------------------------------------------------------