Skip to content

Commit 0a7e0f0

Browse files
committed
Added use_wechat option
You can use this without using WeChat now
1 parent 2adc51f commit 0a7e0f0

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77
headless = False
88

99
app_token = 'AT_ABCDEF0123456789abcdef0123456789'
10+
# app_toten = None if do not use WeChat push
1011

1112
users = [
1213
{
1314
'username': '20201234567',
1415
'password': '123456',
16+
'use_wechat': True,
1517
'uid': 'UID_ABCDEF0123456789abcdef012345'
1618
},
1719
{
1820
'username': '20201234568',
1921
'password': '654321',
20-
'uid': 'UID_ABCDEF0123456789abcdef012346'
22+
'use_wechat': False,
23+
'uid': None
2124
},
2225
]

daily_reporter.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def send_wechat(user_index, msg):
1515
wechat_url += '?appToken=' + config.app_token
1616
wechat_url += '&content=' + msg
1717
wechat_url += '&uid=' + config.users[user_index]['uid']
18-
response = requests.get(wechat_url)
18+
requests.get(wechat_url)
1919

2020

2121
def report(user_index):
@@ -57,7 +57,8 @@ def report(user_index):
5757
browser.find_element_by_class_name('success')
5858
except exceptions.NoSuchElementException:
5959
print('[Error] Login failed')
60-
send_wechat(user_index, strings.get_msg_failed(user_index))
60+
if config.users[user_index]['use_wechat']:
61+
send_wechat(user_index, strings.get_msg_failed(user_index))
6162
browser.quit()
6263
quit(1)
6364

@@ -106,7 +107,8 @@ def report(user_index):
106107
browser.find_element_by_id('fineui_27')
107108
except IndexError:
108109
print('[Error] Submit failed')
109-
send_wechat(user_index, strings.get_msg_failed(user_index))
110+
if config.users[user_index]['use_wechat']:
111+
send_wechat(user_index, strings.get_msg_failed(user_index))
110112
browser.quit()
111113
quit(0)
112114

@@ -129,7 +131,8 @@ def report(user_index):
129131
browser.find_element_by_id('fineui_32')
130132
except exceptions.NoSuchElementException:
131133
print('[Error] Submit timeout')
132-
send_wechat(user_index, strings.get_msg_failed(user_index))
134+
if config.users[user_index]['use_wechat']:
135+
send_wechat(user_index, strings.get_msg_failed(user_index))
133136
browser.quit()
134137
quit(0)
135138

@@ -150,7 +153,8 @@ def report(user_index):
150153

151154
if txt.find(strings.msg['success_msg']) == -1:
152155
print('[Error] Check failed')
153-
send_wechat(user_index, strings.get_msg_failed(user_index))
156+
if config.users[user_index]['use_wechat']:
157+
send_wechat(user_index, strings.get_msg_failed(user_index))
154158
browser.quit()
155159
quit(1)
156160

@@ -165,8 +169,9 @@ def report(user_index):
165169
date = datas.group(1) + '-' + datas.group(2) + '-' + datas.group(3)
166170

167171
print('[Info] ' + 'Date: ' + date + ', Rank: ' + str(rank))
168-
send_wechat(user_index, strings.get_msg_success(
169-
user_index, date, rank, temperature))
172+
if config.users[user_index]['use_wechat']:
173+
send_wechat(user_index, strings.get_msg_success(
174+
user_index, date, rank, temperature))
170175
time.sleep(1)
171176

172177
browser.quit()

0 commit comments

Comments
 (0)