commit
c90f820c70
11
config.py
11
config.py
@ -130,3 +130,14 @@ def clear_cookies():
|
||||
else:
|
||||
log.info("Cookie删除完毕")
|
||||
f.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 初始化配置文件
|
||||
# try:
|
||||
# account_cookie = config['account']['cookie']
|
||||
# config = load_config()
|
||||
# config['account']['cookie'] = account_cookie
|
||||
# except OSError:
|
||||
# pass
|
||||
# save_config()
|
||||
pass
|
@ -105,6 +105,32 @@
|
||||
* push_server 可选范围 cqhttp ftqq(sever酱) pushplus telegram dingrobot
|
||||
|
||||
|
||||
## Wecom
|
||||
企业微信
|
||||
|
||||
**wechat_id**填写**企业ID**,见: 我的企业 -> 企业设置 -> 企业ID
|
||||
|
||||
**agentid**填写**AgentId**,见: 应用管理 -> 自建 -> 「你自己的应用」 -> 复制数字
|
||||
**secret**填写**Secret**,见: 应用管理 -> 自建 -> 「你自己的应用」-> 点<u>查看</u>链接
|
||||
|
||||
**touser**填写**接收人**,默认 @all 通知企业内所有人,指定接收人时使用大驼峰拼音,多个可用|隔开
|
||||
|
||||
填写示例
|
||||
|
||||
```ini
|
||||
[setting]
|
||||
enable=true
|
||||
push_server=wecom
|
||||
|
||||
[wecom]
|
||||
#企业微信的corpid
|
||||
wechat_id=
|
||||
#企业微信的应用配置
|
||||
agentid=
|
||||
secret=
|
||||
touser=@all
|
||||
```
|
||||
|
||||
## dingrobot
|
||||
钉钉群机器人
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[setting]
|
||||
enable=false
|
||||
#共有 cqhttp ftqq(sever酱) pushplus telegram dingrobot
|
||||
#共有 cqhttp ftqq(sever酱) pushplus telegram wecom dingrobot
|
||||
push_server=cqhttp
|
||||
#server酱 pushplus dingrobot 的推送token
|
||||
push_token=123456
|
||||
@ -17,10 +17,12 @@ bot_token=123465:abcdefg
|
||||
chat_id=123456
|
||||
|
||||
[wecom]
|
||||
#企业微信的appid
|
||||
#企业微信的corpid
|
||||
wechat_id=
|
||||
#企业微信的应用配置
|
||||
agentid=
|
||||
secret=
|
||||
wechat_id=
|
||||
touser=@all
|
||||
|
||||
[pushdeer]
|
||||
api_url=https://api2.pushdeer.com
|
||||
|
23
push.py
23
push.py
@ -77,17 +77,26 @@ def cqhttp(status, push_message):
|
||||
# 企业微信 感谢linjie5492@github
|
||||
def wecom(status, push_message):
|
||||
secret = cfg.get('wecom', 'secret')
|
||||
wechat_id = cfg.get('wecom', 'wechat_id')
|
||||
corpid = cfg.get('wecom', 'wechat_id')
|
||||
try:
|
||||
touser = cfg.get('wecom', 'touser')
|
||||
except:
|
||||
# 没有配置时赋默认值
|
||||
touser = '@all'
|
||||
|
||||
push_token = http.post(
|
||||
url=f'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={wechat_id}&corpsecret={secret}',
|
||||
data="").json()['access_token']
|
||||
url=f'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={corpid}&corpsecret={secret}',
|
||||
data=""
|
||||
).json()['access_token']
|
||||
push_data = {
|
||||
"agentid": cfg.get('wecom', 'agentid'),
|
||||
"msgtype": "text",
|
||||
"touser": "@all",
|
||||
"touser": touser,
|
||||
"text": {
|
||||
"content": title(status) + "\r\n" + push_message
|
||||
}, "safe": 0}
|
||||
},
|
||||
"safe": 0
|
||||
}
|
||||
http.post(f'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={push_token}', json=push_data)
|
||||
|
||||
|
||||
@ -150,8 +159,8 @@ def push(status, push_message):
|
||||
# eval(push_server[:10] + "(status, push_message)")
|
||||
# 与面代码等效 20220508
|
||||
func(status, push_message)
|
||||
except:
|
||||
log.warning("推送执行错误")
|
||||
except Exception as r:
|
||||
log.warning(f"推送执行错误:{str(r)}")
|
||||
return 0
|
||||
else:
|
||||
log.info("推送完毕......")
|
||||
|
Loading…
Reference in New Issue
Block a user