import requests
import base64
import hashlib
import os
#参数bot是指机器人的key,具体可参考企业微信机器人官网
#发送普通消息,text是文本内容
def send_text(text,bot):
url = f"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={bot}"
headers = {"Content-Type": "text/plain"}
data = {
"msgtype": "text",
"text": {
"content": text,
}
}
r = requests.post(url, headers=headers, json=data)
print(r.text)
#发送markdown消息,text是文本内容,可接受markdown语法
def send_markdown(text,bot):
url = f"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={bot}"
data = {
"msgtype": "markdown",
"markdown": {
"content": text