ding: send by webhook

close: #189

Feature: 钉钉添加 `send_by_webhook` 方法 #189
This commit is contained in:
Artin
2021-03-11 13:21:18 +08:00
committed by lengthmin
parent 46c65b919f
commit 0fec9915de
7 changed files with 173 additions and 34 deletions

View File

@ -1,3 +1,15 @@
import hmac
from nonebot.utils import logger_wrapper
import hashlib
import base64
log = logger_wrapper("DING")
def calc_hmac_base64(timestamp: str, secret: str):
secret_enc = secret.encode('utf-8')
string_to_sign = '{}\n{}'.format(timestamp, secret)
string_to_sign_enc = string_to_sign.encode('utf-8')
hmac_code = hmac.new(secret_enc,
string_to_sign_enc,
digestmod=hashlib.sha256).digest()
return base64.b64encode(hmac_code)