mirror of
https://github.com/daiyanan1992/qinglongtest
synced 2025-12-22 17:54:35 +08:00
优化代码
This commit is contained in:
@@ -6,12 +6,14 @@
|
||||
# -------------------------------
|
||||
from requests import post
|
||||
from json import dumps
|
||||
from sys import path
|
||||
path.append("./tools")
|
||||
from tool import get_environ
|
||||
|
||||
tg_userId = get_environ("TG_USER_ID")
|
||||
tgbot_token = get_environ("TG_BOT_TOKEN")
|
||||
tg_push_api = get_environ("TG_API_HOST")
|
||||
pushplus_token = get_environ("PUSH_PLUS_TOKEN")
|
||||
tg_userId = get_environ("TG_USER_ID", "", False)
|
||||
tgbot_token = get_environ("TG_BOT_TOKEN", "", False)
|
||||
tg_push_api = get_environ("TG_API_HOST", "", False)
|
||||
pushplus_token = get_environ("PUSH_PLUS_TOKEN", "", False)
|
||||
|
||||
def tgpush(title, content):
|
||||
url = f"https://api.telegram.org/bot{tgbot_token}/sendMessage"
|
||||
@@ -37,8 +39,8 @@ def pushplus(title, content):
|
||||
post(url, headers=headers, data=dumps(data))
|
||||
except:
|
||||
print('推送失败')
|
||||
def push(self, title, content):
|
||||
def push(title, content):
|
||||
if pushplus_token != "":
|
||||
self.pushplus(title, content)
|
||||
pushplus(title, content)
|
||||
if tgbot_token != "" and tg_userId != "":
|
||||
self.tgpush(title, content)
|
||||
tgpush(title, content)
|
||||
Reference in New Issue
Block a user