forked from lxl66566/ecust-electricity-statistics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
24 lines (21 loc) · 662 Bytes
/
utils.py
File metadata and controls
24 lines (21 loc) · 662 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import json
import logging
import requests
def sendMsgToWechat(token: str, title: str, text: str, template: str) -> None:
"""
token:PushPlus token
title:text's title
text:text's body
template:html,txt,json,markdown
Send message to Wechat(SMS,E-mail,Dingtalk...) via PushPlus.
default channel is wechat
"""
url = "http://www.pushplus.plus/send"
data = {"token": token, "title": title, "content": text, "template": template}
try:
requests.post(
url=url, data=(json.dumps(data).encode(encoding="utf-8")), timeout=20
)
except Exception as e:
logging.exception(e)
raise e