feat: 添加工作时间飞书新消息通知功能
This commit is contained in:
@@ -5,6 +5,8 @@ import queue
|
||||
import logging
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
class Subscription:
|
||||
def __init__(self, queue):
|
||||
@@ -234,6 +236,34 @@ class WXBot(WebWeixin):
|
||||
params["content"] = "[未识别消息]" + msg["Content"]
|
||||
self.db_conn.execute(sql, params)
|
||||
self.db_conn.commit()
|
||||
|
||||
# 工作时间发送新消息提醒到飞书
|
||||
curr_time_struct = time.localtime(time.time())
|
||||
if curr_time_struct.tm_hour >= 10 and curr_time_struct.tm_hour < 19:
|
||||
requests.post(
|
||||
"https://open.feishu.cn/open-apis/bot/v2/hook/30bda541-46de-40b7-8881-31b77deadc35",
|
||||
headers={"Content-Type": "application/json"},
|
||||
json={
|
||||
"msg_type": "post",
|
||||
"content": {
|
||||
"post": {
|
||||
"zh_cn": {
|
||||
"title": "【" + params["from_name"] + "】发来一条新消息",
|
||||
"content": [
|
||||
[
|
||||
{
|
||||
"tag": "text",
|
||||
"text": "【微信】收到一条来自【"
|
||||
+ params["from_name"]
|
||||
+ "】的消息",
|
||||
}
|
||||
]
|
||||
],
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
for subscription in self.subscriptions:
|
||||
if (
|
||||
not subscription.queue.empty()
|
||||
|
||||
Reference in New Issue
Block a user