python 飞书 机器人

!在这里插入图片描述(https://img-blog.csdnimg.cn/e4758957286342999266a4ed01e19d59.png

废话 不多说 直接上 代码!!!

python 复制代码
"""
    coding:utf-8
    @Software:PyCharm
    @Time:2022/9/24 10:15
    @Author:Startao
    @Description:
"""
import base64
import hashlib
import hmac
import time

import requests


def gen_sign(timestamp, secret):
    # 拼接timestamp和secret
    string_to_sign = '{}\n{}'.format(timestamp, secret)
    hmac_code = hmac.new(string_to_sign.encode("utf-8"), digestmod=hashlib.sha256).digest()
    print(hmac_code)
    # 对结果进行base64处理
    sign = base64.b64encode(hmac_code).decode('utf-8')
    return sign


def send_message(message):
    webhook = "your_webhook"
    secret = "your_secret"
    timestamp = int(time.time())
    headers = {
        "Content-Type": "application/json"
    }
    a_sign = gen_sign(timestamp, secret)

    message_txt = {
        "sign": a_sign,
        "timestamp": timestamp,
        "msg_type": "text",
        "content": {
            "text": message
        }
    }
    response = requests.post(url=webhook, headers=headers, json=message_txt)
相关推荐
kunicoding6 小时前
C++ 策略模式实战:写一个可以“一键换输出“的日志系统
开发语言·c++·策略模式
y = xⁿ6 小时前
拆解cloud code记忆系统
java·人工智能·python·github
zzu123zsw6 小时前
打破单模型幻觉与信息茧房:24k Star 开源 BettaFish 的多智能体辩论拓扑与实时舆情研判实战
python
纪念 2296 小时前
C++算法(三)
开发语言·c++·算法
csdn_zhangchunfeng6 小时前
linux 如何安装rst2man命令
开发语言·chrome·python
滴啦嘟啦哒6 小时前
【具身笔记】【π0.5 微调与仿真】三、libero数据可视化
笔记·python·ros·vla
浩腾数字多媒体6 小时前
展厅中控源头厂家怎么选要看哪些核心指标?
网络·python
sejinan7 小时前
新版!IPTV直播源列表 V1.7 正式发布:接口大厅与会员定制生态解读
开发语言·php
全栈练习生7 小时前
大模型评测可信
python·ai
我喜欢就喜欢7 小时前
DeepSeek Harness 开源贡献手记:从零到合入主线的完整历程
开发语言·人工智能·copilot