MCPcopy Index your code
hub / github.com/smallfawn/QLScriptPublic / pushplus_bot

Function pushplus_bot

daily/notify.py:384–426  ·  view source on GitHub ↗

通过 pushplus 推送消息。

(title: str, content: str)

Source from the content-addressed store, hash-verified

382
383
384def pushplus_bot(title: str, content: str) -> None:
385 """
386 通过 pushplus 推送消息。
387 """
388 if not push_config.get("PUSH_PLUS_TOKEN"):
389 return
390 print("PUSHPLUS 服务启动")
391
392 url = "https://www.pushplus.plus/send"
393 data = {
394 "token": push_config.get("PUSH_PLUS_TOKEN"),
395 "title": title,
396 "content": content,
397 "topic": push_config.get("PUSH_PLUS_USER"),
398 "template": push_config.get("PUSH_PLUS_TEMPLATE"),
399 "channel": push_config.get("PUSH_PLUS_CHANNEL"),
400 "webhook": push_config.get("PUSH_PLUS_WEBHOOK"),
401 "callbackUrl": push_config.get("PUSH_PLUS_CALLBACKURL"),
402 "to": push_config.get("PUSH_PLUS_TO"),
403 }
404 body = json.dumps(data).encode(encoding="utf-8")
405 headers = {"Content-Type": "application/json"}
406 response = requests.post(url=url, data=body, headers=headers).json()
407
408 code = response["code"]
409 if code == 200:
410 print("PUSHPLUS 推送请求成功,可根据流水号查询推送结果:" + response["data"])
411 print(
412 "注意:请求成功并不代表推送成功,如未收到消息,请到pushplus官网使用流水号查询推送最终结果"
413 )
414 elif code == 900 or code == 903 or code == 905 or code == 999:
415 print(response["msg"])
416
417 else:
418 url_old = "http://pushplus.hxtrip.com/send"
419 headers["Accept"] = "application/json"
420 response = requests.post(url=url_old, data=body, headers=headers).json()
421
422 if response["code"] == 200:
423 print("PUSHPLUS(hxtrip) 推送成功!")
424
425 else:
426 print("PUSHPLUS 推送失败!")
427
428
429def weplus_bot(title: str, content: str) -> None:

Callers

nothing calls this directly

Calls 3

printFunction · 0.70
getMethod · 0.45
postMethod · 0.45

Tested by

no test coverage detected