资源加载中... loading...

钉钉群机器人推送【超长信息】必备

Author: BTC【策略代写】团队, Date: 2022-04-02 14:58:42
Tags:


#!Python3

"""
《策略代写》 与 (此程序帮助),致信QQ:35787501

钉钉长消息推送,用于群自定义机器人
由于@可推送的信息过短,在字符串长度过长时,可以使用此程序
"""

import time
import json
import hmac
import hashlib
import base64
import urllib.parse
import urllib.request


def send_request(url, data):
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
                      'AppleWebKit/537.36 (KHTML, like Gecko) '
                      'Chrome/92.0.4515.159 Safari/537.36',
        'Accept': 'text/html,application/xhtml+xml,application/xml;'
                  'q=0.9,image/avif,image/webp,image/apng,*/*;'
                  'q=0.8,application/signed-exchange;v=b3;q=0.9',
        "Content-Type": "application/json",
        "Charset": "UTF-8",
    }
    request = urllib.request.Request(url=url, data=json.dumps(data).encode("utf-8"), headers=headers)
    opener = urllib.request.urlopen(request)
    return opener.read().decode()


def get_time_sign(secret):
    timestamp = str(round(time.time() * 1000))
    secret_enc = secret.encode('utf-8')
    string_to_sign = '{}\n{}'.format(timestamp, secret)
    string_to_sign_enc = string_to_sign.encode('utf-8')
    h_mac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
    sign = urllib.parse.quote_plus(base64.b64encode(h_mac_code))
    return timestamp, sign


def send(text):
    timestamp, sign = get_time_sign(ding_secret)
    my_url = "{}&timestamp={}&sign={}".format(ding_url, timestamp, sign)
    data = {"msgtype": "text", "text": {"content": text}}
    return send_request(my_url, data)


def LogDing(*args):
    Log(send(" ".join(args)))


def main():
    LogDing(" test " * 1000)


ext.LogDing = LogDing


More

阿乐 能出一个企业微信webhook推送的吗

hexie8 有没有微信推送,大佬

轻轻的云 微信用QQ邮箱,FMZ推送绑定QQ邮箱,然后微信把QQ邮箱公众号关注上,绑订QQ邮箱,然后有消息就会邮箱APP提示 微信也提示了。