|
|
|
|
import requests
|
|
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
|
from config.logger import setup_logging
|
|
|
|
|
from plugins_func.register import register_function, ToolType, ActionResponse, Action
|
|
|
|
|
import json
|
|
|
|
|
import base64
|
|
|
|
|
import urllib.parse
|
|
|
|
|
|
|
|
|
|
TAG = __name__
|
|
|
|
|
logger = setup_logging()
|
|
|
|
|
|
|
|
|
|
SEND_NOTICE_FUNCTION_DESC = {
|
|
|
|
|
"type": "function",
|
|
|
|
|
"function": {
|
|
|
|
|
"name": "send_notice",
|
|
|
|
|
"description": (
|
|
|
|
|
"用户发送通知,用户需要提供通知标题和通知内容"
|
|
|
|
|
"如果用户没有提供具体的通知标题,需要进行分析得出通知标题"
|
|
|
|
|
"注意时间的格式,例如:16:00,决不能是1600"
|
|
|
|
|
),
|
|
|
|
|
"parameters": {
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"title": {
|
|
|
|
|
"type": "string",
|
|
|
|
|
"description": "通知标题"
|
|
|
|
|
},
|
|
|
|
|
"content": {
|
|
|
|
|
"type": "string",
|
|
|
|
|
"description": "通知内容"
|
|
|
|
|
},
|
|
|
|
|
"lang": {
|
|
|
|
|
"type": "string",
|
|
|
|
|
"description": "返回用户使用的语言code,例如zh_CN/zh_HK/en_US/ja_JP等,默认zh_CN"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"required": ["lang"]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HEADERS = {
|
|
|
|
|
'User-Agent': (
|
|
|
|
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '
|
|
|
|
|
'(KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36'
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@register_function('send_notice', SEND_NOTICE_FUNCTION_DESC, ToolType.SYSTEM_CTL)
|
|
|
|
|
def send_notice(conn, title: str = None, content: str = None, lang: str = "zh_CN"):
|
|
|
|
|
print("通知标题:"+title)
|
|
|
|
|
print("通知内容:"+content)
|
|
|
|
|
|
|
|
|
|
# 对中文内容进行BASE64编码
|
|
|
|
|
title_base64 = base64.b64encode(title.encode('utf-8')).decode('utf-8')
|
|
|
|
|
content_base64 = base64.b64encode(content.encode('utf-8')).decode('utf-8')
|
|
|
|
|
|
|
|
|
|
# 对BASE64结果进行URL编码
|
|
|
|
|
title_urlencoded = urllib.parse.quote(title_base64)
|
|
|
|
|
content_urlencoded = urllib.parse.quote(content_base64)
|
|
|
|
|
|
|
|
|
|
url = "https://www.edusoa.com/dsideal_yy/new_notice/kjAddNotice"
|
|
|
|
|
|
|
|
|
|
payload = f'notice_content=通知¬ice_title=通知¬iceJson=%7B%22notice_title%22%3A%22{title_urlencoded}%22%2C%22notice_content%22%3A%22{content_urlencoded}%22%2C%22notice_level%22%3A%221%22%2C%22thumb_id%22%3A%22%22%2C%22notice_receipt%22%3A0%2C%22notice_public%22%3A0%2C%22sender_bureau_id%22%3A900008135%2C%22sender_person_id%22%3A%22546097%22%2C%22send_status%22%3A1%2C%22bureau_list%22%3A%5B900008135%5D%2C%22org_list%22%3A%5B%5D%2C%22person_list%22%3A%5B%5D%2C%22group_list%22%3A%5B%5D%2C%22attachments%22%3A%5B%5D%7D¬iceSourceJson=333'
|
|
|
|
|
headers = {
|
|
|
|
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:137.0) Gecko/20100101 Firefox/137.0',
|
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
|
'Cookie': 'HWWAFSESID=9e32376ecea1f188cd; HWWAFSESTIME=1744869321310; identity_id=5; person_id=546097; token=ae368e8a2633498a0217c67510668754'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
response = requests.request("POST", url, headers=headers, data=payload)
|
|
|
|
|
|
|
|
|
|
print(response.text)
|
|
|
|
|
|
|
|
|
|
report= f"您的通知已成功发送!"
|
|
|
|
|
|
|
|
|
|
report += (
|
|
|
|
|
f"(只回复您的通知已成功发送即可,其他信息无需回复)"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ActionResponse(Action.REQLLM, report, None)
|