代码拉取完成,页面将自动刷新
同步操作将从 Q/JD-SHOPPER 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import json
import requests
from logger import logger
from config import global_config
def sendMessage(message):
enabled = global_config.getRaw("messenger", "enable")
if not enabled:
return
mode = global_config.getRaw("messenger", "mode")
if mode == "group":
groupid = global_config.getRaw("messenger", "group_id")
sendGroupMessage(message, groupid)
else:
userid = global_config.getRaw("messenger", "user_id")
sendFriendMessage(message, userid)
def sendFriendMessage(message, userid):
URL = global_config.getRaw("messenger", "server_address")
path = "sendFriendMessage"
try:
URL = "http://{}/{}".format(URL, path)
body = {
"sessionKey": "YourSession",
"target": userid,
"messageChain": [
{"type": "Plain", "text": message}
]
}
# sender = requests.post(URL, params = params, data=json.dumps(body))
sender = requests.post(URL, data=json.dumps(body))
mes = message.replace("\n", " ")
if len(mes) > 10:
mes = mes[:10] + "···"
logger.info("Send {}".format(mes))
# print(sender.request.url)
# sender.raise_for_status()
# print(sender.text)
return True
except:
logger.error("Message Send Failed")
return False
def sendGroupMessage(message, groupid):
URL = global_config.getRaw("messenger", "server_address")
path = "sendGroupMessage"
try:
URL = "http://{}/{}".format(URL, path)
body = {
"sessionKey": "YourSession",
"target": groupid,
"messageChain": [
{"type": "Plain", "text": message}
]
}
# sender = requests.post(URL, params = params, data=json.dumps(body))
sender = requests.post(URL, data=json.dumps(body))
mes = message.replace("\n", " ")
if len(mes) > 10:
mes = mes[:10] + "···"
logger.info("Send {}".format(mes))
# print(sender.request.url)
# sender.raise_for_status()
# print(sender.text)
return True
except:
logger.error("Message Send Failed")
return False
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。