Skip to content

Commit ee6f53e

Browse files
committed
修改对环境变量的判断
1 parent 1f9d968 commit ee6f53e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

main.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919
TBS_URL = "http://tieba.baidu.com/dc/common/tbs"
2020
SIGN_URL = "http://c.tieba.baidu.com/c/c/forum/sign"
2121

22-
# EMAIL
23-
HOST = os.environ['HOST']
24-
FROM = os.environ['FROM']
25-
TO = os.environ['TO'].split('#')
26-
AUTH = os.environ['AUTH']
22+
ENV = os.environ
2723

2824
HEADERS = {
2925
'Host': 'tieba.baidu.com',
@@ -178,9 +174,13 @@ def client_sign(bduss, tbs, fid, kw):
178174
return res
179175

180176
def send_email(sign_list):
181-
if HOST is None or FROM is None or TO is None or AUTH is None:
182-
logger.info("未配置邮箱")
177+
if ('HOST' not in ENV or 'FROM' not in ENV or 'TO' not in ENV or 'AUTH' not in ENV):
178+
logger.error("未配置邮箱")
183179
return
180+
HOST = ENV['HOST']
181+
FROM = ENV['FROM']
182+
TO = ENV['TO'].split('#')
183+
AUTH = ENV['AUTH']
184184
length = len(sign_list)
185185
subject = f"{time.strftime('%Y-%m-%d', time.localtime())} 签到{length}个贴吧"
186186
body = """
@@ -212,11 +212,11 @@ def send_email(sign_list):
212212
smtp.quit()
213213

214214
def main():
215-
b = os.environ['BDUSS'].split('#')
215+
if ('BDUSS' not in ENV):
216+
logger.error("未配置BDUSS")
217+
return
218+
b = ENV['BDUSS'].split('#')
216219
for n, i in enumerate(b):
217-
if(len(i) <= 0):
218-
logger.info("未检测到BDUSS")
219-
continue
220220
logger.info("开始签到第" + str(n) + "个用户" + i)
221221
tbs = get_tbs(i)
222222
favorites = get_favorite(i)

0 commit comments

Comments
 (0)