Skip to content
TardisX edited this page Nov 2, 2022 · 47 revisions

简介

MIUI Task 是一个适用于 小米社区4.0 自动完成 KPI 任务的脚本

使用方法

在第一次运行此脚本前,在你想要部署MIUI Task的设备上用浏览器在小米社区执行一次成功的登录操作,并将浏览器的 User-Agent 写入配置文件

配置文件

MIUI Task 从 v1.4 开始采用 YAML 作为默认配置文件,但同时兼容旧版的 config.env 配置文件

config.yaml 支持为多账号进行配置,可根据以下配置文档进行配置,或使用 MIUI Task Dashboard 生成配置文件

默认配置文件的结构如下:

accounts:
  - uid: 100000
    password: abc123
    user-agent: 'Mozilla/5.0 (Android 11; Mobile; rv:95.0) Gecko/95.0 Firefox/95.0'
    carrot-pull: false
    check-in: false
    browse-specialpage: false

选项含义:

  • uid
    小米账户的 UID,并非用户名
  • password
    小米账户的密码,也可以是其 MD5 哈希
  • user-agent
    登录小米账户的浏览器 User-Agent
    可用此 工具 查看当前浏览器的 User-Agent
  • carrot-pull
    社区拔萝卜的开关,如需启用,将 false 改为 true
  • check-id
    社区每日签到的开关,如需启用,将 false 改为 true
  • browse-specialpage
    浏览社区限时专题页的开关,如需启用,将 false 改为 true
  • logging
    以文件形式归档执行日志
  • version
    用于检测配置文件版本是否满足脚本最低版本要求,请勿修改

注意:一般情况下,本脚本只会执行登录社区、三次点赞、三次浏览十秒帖子及浏览十秒个人主页成长值任务的基本操作。根据小米社区相关规定,社区签到 与 拔萝卜 等功能有可能导致封号

若要为多个小米账号进行配置,参考以下配置:

accounts:
    # 账号 1
  - uid: 100000
    password: abc123
    user-agent: 'Mozilla/5.0 (Android 11; Mobile; rv:95.0) Gecko/95.0 Firefox/95.0'
    carrot-pull: false
    check-in: false
    browse-specialpage: false
    # 账号 2
  - uid: 100001
    password: abc123
    user-agent: 'Mozilla/5.0 (Android 11; Mobile; rv:95.0) Gecko/95.0 Firefox/95.0'
    carrot-pull: false
    check-in: false
    browse-specialpage: false
logging: false

若不熟悉 YAML 格式,程序目前仍然支持旧版 config.env 配置:

MI_ID='100000'
MI_PASSWORD='abc123'
USER_AGENT='Mozilla/5.0 (Android 11; Mobile; rv:95.0) Gecko/95.0 Firefox/95.0'
SIGN_IN='N'
LOG_SAVE='N'
CARROT_PULL='N'
BROWSE_SPECIALPAGE='N'

手动执行

  1. 安装依赖
    pip install -r requirements.txt
  2. 执行
    python miuitask.py

注意:确保当前安装的 Python 版本 >= 3.6

Docker

  1. 拉取镜像
    docker pull o1si/miui-auto-tasks:latest
  2. 编辑 config.yaml 配置文件,挂载到容器 /srv/config.yaml 并运行
    2.1 若使用 config.env 作为配置文件,需要挂载到容器 /srv/config.env
docker run -d \
-v /path/to/config.yaml:/srv/config.yaml \
o1si/miui-auto-tasks:latest

注意:默认将于每天 04:00 进行签到

定时任务
若有自定义执行时间的需求,创建一个 LINUX crontab 文件,其格式为
* * * * * python /srv/miuitask.py

创建 Docker 容器时挂载到容器路径 /var/spool/cron/crontabs/root

docker run -d \
-v /path/to/config.yaml:/srv/config.yaml \
-v /path/to/crontab:/var/spool/cron/crontabs/root \
o1si/miui-auto-tasks:latest

Crontab 在线工具

腾讯云函数

云函数(Serverless Cloud Function,SCF)是腾讯提供的 Function-as-a-Service 服务。

  1. 下载最新 SCF Release
  2. 解压并修改其中的 config.yaml 配置文件,并重新压缩为 .zip 格式
  3. 注册并开通 腾讯云 SCF 服务
  4. 新建自定义云函数
  5. 配置云函数
    函数类型: 事件函数
    地域: 广州
    部署方式: 代码部署
    运行环境: Python 3.6
  6. 上传 .zip 代码
    提交方法: 本地上传zip包
    执行方法: miuitask.main_handler
  7. 设置触发器
    触发版本: 默认流量 触发方式: 定时触发 触发周期: 每1天(每天0点0分执行一次) 立即启用: 启用

注意:腾讯云函数有可能触发小米账户异地登录的风控,可能导致需要验证码且无法正常执行。尝试通过寻求云函数服务器选区的朋友帮助,用当地 IP 电脑登录一次小米社区。或租赁一台与云函数同区的按需实例进行一次成功的正常登录

License

MIT License

Copyright (c) 2021 東雲研究所

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
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
SOFTWARE.
Clone this wiki locally