mirror of
https://github.com/0-8-4/miui-auto-tasks.git
synced 2025-02-07 19:09:59 +00:00
添加推送功能 (#82)
* 修复无法获取成长值的问题 更改成长值获取接口 * 修复无法获取成长值的问题 更改成长值获取接口 * 改用正则获取成长值 * 推送配置说明 * 更新推送 * 更新推送 * Update config.yaml * Update config.yaml * Update requirements.txt * Update config.yaml * format the file * 提升版本号 * 提升版本号 * 提升版本号 --------- Co-authored-by: 0-8-4 <ljd69154@liangjundi.cn>
This commit is contained in:
parent
6c3c31a58a
commit
371577c001
76
README.md
76
README.md
@ -56,6 +56,82 @@
|
||||
⚠ 请注意,修改配置文件开启完成限时专题任务后 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`
|
||||
|
10
config.yaml
10
config.yaml
@ -21,7 +21,15 @@ accounts:
|
||||
# carrot-pull: false
|
||||
# check-in: false
|
||||
# browse-specialpage: false
|
||||
ONEPUSH:
|
||||
notifier: telegram
|
||||
params:
|
||||
title:
|
||||
markdown: false
|
||||
token:
|
||||
userid:
|
||||
|
||||
logging: false
|
||||
# 归档日志到本地文件
|
||||
version: v1.5.2
|
||||
version: v1.5.3
|
||||
# config 文件版本号,debug用
|
||||
|
@ -9,7 +9,7 @@ from urllib import request
|
||||
from http import cookiejar
|
||||
|
||||
from utils.utils import system_info, get_config, w_log, s_log, check_config, format_config, random_sleep, \
|
||||
sleep_ten_sec_more
|
||||
sleep_ten_sec_more, notify_me
|
||||
|
||||
|
||||
class MIUITask:
|
||||
@ -432,7 +432,7 @@ def start(miui_task: MIUITask, check_in: bool, carrot_pull: bool, browse_special
|
||||
|
||||
|
||||
def main():
|
||||
w_log("MIUI-AUTO-TASK v1.5.2")
|
||||
w_log("MIUI-AUTO-TASK v1.5.3")
|
||||
w_log('---------- 系统信息 -------------')
|
||||
system_info()
|
||||
w_log('---------- 项目信息 -------------')
|
||||
@ -447,7 +447,7 @@ def main():
|
||||
exit(1)
|
||||
else:
|
||||
config = format_config(config)
|
||||
|
||||
|
||||
for i in config.get('accounts'):
|
||||
w_log('---------- EXECUTING -------------')
|
||||
start(
|
||||
@ -456,6 +456,7 @@ def main():
|
||||
)
|
||||
time.sleep(5)
|
||||
s_log(config.get('logging'))
|
||||
notify_me()
|
||||
|
||||
|
||||
def main_handler(event, context):
|
||||
|
@ -1,3 +1,4 @@
|
||||
requests>=2.25.1
|
||||
python-dotenv>=0.19.2
|
||||
PyYAML>=6.0
|
||||
PyYAML>=6.0
|
||||
onepush
|
||||
|
@ -2,13 +2,17 @@ import os
|
||||
import random
|
||||
import time
|
||||
import platform
|
||||
import dotenv, yaml
|
||||
import dotenv
|
||||
import yaml
|
||||
|
||||
from hashlib import md5
|
||||
from onepush import notify
|
||||
from urllib.request import getproxies
|
||||
|
||||
logs = ''
|
||||
CONFIG_VERSION_REQUIRE: str = 'v1.5.2'
|
||||
message = ''
|
||||
config = {'account': []}
|
||||
CONFIG_VERSION_REQUIRE: str = 'v1.5.3'
|
||||
|
||||
|
||||
def md5_crypto(passwd: str) -> str:
|
||||
@ -32,7 +36,7 @@ def system_info():
|
||||
|
||||
|
||||
def get_config() -> dict:
|
||||
config = {'account': []}
|
||||
global config
|
||||
config_path_legacy = dotenv.find_dotenv(filename='config.env')
|
||||
config_path_yaml = dotenv.find_dotenv(filename='config.yaml')
|
||||
|
||||
@ -89,8 +93,10 @@ def get_config() -> dict:
|
||||
|
||||
def w_log(text):
|
||||
global logs
|
||||
global message
|
||||
now_localtime = time.strftime("%H:%M:%S", time.localtime())
|
||||
logs += now_localtime + ' | ' + str(text) + '\n'
|
||||
message += str(text) + '\n'
|
||||
print(now_localtime + ' | ' + str(text))
|
||||
|
||||
|
||||
@ -145,3 +151,21 @@ def random_sleep():
|
||||
|
||||
def sleep_ten_sec_more():
|
||||
time.sleep(random.randint(10, 12))
|
||||
|
||||
|
||||
def notify_me(content=None):
|
||||
"""
|
||||
默认推送日志
|
||||
"""
|
||||
global message
|
||||
global config
|
||||
if not content:
|
||||
content = message
|
||||
notifier = config.get('ONEPUSH', {}).get('notifier', '')
|
||||
params = config.get('ONEPUSH', {}).get('params', '')
|
||||
if not notifier or not params:
|
||||
s_log('未配置推送或未正确配置推送')
|
||||
return
|
||||
if not config.get('ONEPUSH', {}).get('title', ''):
|
||||
config['ONEPUSH']['title'] = ''
|
||||
return notify(notifier, content=content, **params)
|
||||
|
Loading…
Reference in New Issue
Block a user