支持更多任务
配置文件新增成长值签到开关及拔萝卜开关
This commit is contained in:
TardisX 2022-08-26 00:26:04 +08:00 committed by GitHub
parent 528d035c2e
commit c819afdeab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 13 deletions

View File

@ -45,6 +45,7 @@
- [x] 选择性启用小米社区拔萝卜签到
- [x] 选择性启用小米社区成长值签到
- [x] 自动完成以下小米社区成长值任务且不留下可见痕迹
- “每日登录小米社区App” 成长值任务
- “浏览帖子超过10秒” 成长值任务
- “点赞他人帖子” 成长值任务

View File

@ -6,13 +6,16 @@ accounts:
user-agent: 'Mozilla/5.0 (Android 11; Mobile; rv:95.0) Gecko/95.0 Firefox/95.0'
# 登录小米社区时所用浏览器的 User-Agent
# 可在此工具查看https://tool.chinaz.com/useragent
carrot-pull: false
# 小米社区拔萝卜,可能存在封号风险
check-in: false
# 小米社区拔萝卜和签到,可能存在封号风险
# 本脚本默认完成三次点赞及三次浏览十秒帖子的成长值任务
# 小米社区成长值签到,可能存在封号风险
# 本脚本默认完成登录社区和三次点赞及三次浏览十秒帖子的成长值任务
# 若有多个小米账户,按照以下模板进行修改,使用时删除前端 #注释
# - 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
logging: false
# 归档日志到本地文件

View File

@ -126,7 +126,7 @@ class MIUITask:
w_log(e)
# 社区拔萝卜
def vip_check_in(self):
def carrot_pull(self):
headers = {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
'cookie': str(self.cookie)
@ -155,9 +155,6 @@ class MIUITask:
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
'cookie': str(self.cookie)
}
data = {
'miui_vip_ph': str(self.miui_vip_ph)
}
try:
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/user/checkin?pathname=/mio/checkIn&version=dev.1144', headers=headers)
r_json = response.json()
@ -170,6 +167,24 @@ class MIUITask:
w_log("社区成长值签到出错")
w_log(e)
# 登录社区App
def login_app(self):
headers = {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
'cookie': str(self.cookie)
}
try:
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/app/init/start/infos', headers=headers)
r_code = response.status_code
if r_code == 401:
return w_log("登录社区App失败Cookie无效")
elif r_code != 200:
return w_log("登录社区App失败")
w_log("登录社区App成功")
except Exception as e:
w_log("登录社区App出错")
w_log(e)
def mi_login(self):
proxies = {
'https': None,
@ -267,16 +282,20 @@ def process_exception(e: Exception):
w_log('系统设置了代理,出现异常')
def start(miui_task: MIUITask, check_in: bool):
def start(miui_task: MIUITask, check_in: bool, carrot_pull: bool):
if miui_task.mi_login():
w_log("本脚本支持社区签到,因该功能存在风险默认禁用")
w_log("本脚本支持社区拔萝卜及成长值签到,因该功能存在风险默认禁用")
w_log("如您愿意承担一切可能的后果,可编辑配置文件手动打开该功能")
miui_task.login_app()
if carrot_pull:
w_log("风险功能提示:正在进行社区拔萝卜")
time.sleep(0.5)
miui_task.carrot_pull()
if check_in:
w_log("风险功能提示:正在进行社区签到")
miui_task.vip_check_in()
w_log("风险功能提示:正在进行成长值签到")
time.sleep(0.5)
miui_task.check_in()
time.sleep(1)
w_log("正在完成浏览帖子10s任务第一次")
time.sleep(10.5)
miui_task.browse_post()
@ -303,7 +322,7 @@ def start(miui_task: MIUITask, check_in: bool):
def main():
w_log("MIUI-AUTO-TASK v1.5")
w_log("MIUI-AUTO-TASK v1.5.1")
w_log('---------- 系统信息 -------------')
system_info()
w_log('---------- 项目信息 -------------')
@ -323,7 +342,7 @@ def main():
w_log('---------- EXECUTING -------------')
start(
MIUITask(i.get('uid'), i.get('password'), i.get('user-agent'), device_id=i.get('device-id')),
i.get('check-in'),
i.get('check-in'), i.get('carrot-pull'),
)
s_log(config.get('logging'))

View File

@ -45,6 +45,10 @@ def get_config() -> dict:
config['account'][0]['check-in'] = True
else:
config['account'][0]['check-in'] = False
if legacy_config.get('CARROT_PULL') and legacy_config.get('CARROT_PULL').upper() in ('Y', 'YES'):
config['account'][0]['carrot-pull'] = True
else:
config['account'][0]['carrot-pull'] = False
if legacy_config.get('LOG_SAVE') and legacy_config.get('LOG_SAVE').upper() in ('Y', 'YES'):
config['logging'] = True
else:
@ -90,6 +94,8 @@ def check_config(config: dict) -> bool:
return False
if not isinstance(i.get('check-in'), bool):
return False
if not isinstance(i.get('carrot-pull'), bool):
return False
else:
return False
if not isinstance(config.get('logging'), bool):