Skip to content

Commit 4176ae4

Browse files
Amend PR
1 parent 4929140 commit 4176ae4

File tree

5 files changed

+73
-18
lines changed

5 files changed

+73
-18
lines changed
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: 画爱心macos版
5+
6+
on:
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
pyinstaller-build:
14+
runs-on: macos-latest
15+
steps:
16+
- name: Create Executable
17+
uses: sayyid5416/pyinstaller@v1
18+
with:
19+
python_ver: '3.12'
20+
spec: 'love_heart.py'
21+
upload_exe_with_name: 'love_heart'
22+
options: --onefile, --name "love_heart", --windowed,
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: 画爱心Ubuntu版
5+
6+
on:
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
pyinstaller-build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Create Executable
17+
uses: sayyid5416/pyinstaller@v1
18+
with:
19+
python_ver: '3.12'
20+
spec: 'love_heart.py'
21+
upload_exe_with_name: 'love_heart'
22+
options: --onefile, --name "love_heart", --windowed,
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: 画爱心Windows版
5+
6+
on:
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
pyinstaller-build:
14+
runs-on: windows-latest
15+
steps:
16+
- name: Create Executable
17+
uses: sayyid5416/pyinstaller@v1
18+
with:
19+
python_ver: '3.12'
20+
spec: 'love_heart.py'
21+
upload_exe_with_name: 'love_heart'
22+
options: --onefile, --name "love_heart", --windowed,

.github/workflows/weather_report.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ name: 天气预报推送
55

66
on:
77
schedule:
8-
# 设置启动时间,为 UTC 时间
8+
# 设置启动时间,为 UTC 时间, UTC23点 对应北京时间早7点
99
- cron : '00 23 * * *'
1010
workflow_dispatch:
1111

@@ -36,4 +36,3 @@ jobs:
3636
APP_SECRET: ${{ secrets.APP_SECRET }}
3737
OPEN_ID: ${{ secrets.OPEN_ID }}
3838
TEMPLATE_ID: ${{ secrets.TEMPLATE_ID }}
39-
LOCATION_LIST: ${{ secrets.LOCATION_LIST }}

weather_report.py

+6-16
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
appID = os.environ.get("APP_ID")
99
appSecret = os.environ.get("APP_SECRET")
1010
# 收信人ID即 用户列表中的微信号
11-
openId_str = os.environ.get("OPEN_ID", "")
12-
openId_list = [id.strip() for id in openId_str.split('\n') if id.strip()]
13-
# 读入地址列表
14-
location_str = os.environ.get("LOCATION_LIST", "")
15-
Location_list = [loc.strip() for loc in location_str.split('\n') if loc.strip()]
16-
11+
openId = os.environ.get("OPEN_ID")
1712
# 天气预报模板ID
1813
weather_template_id = os.environ.get("TEMPLATE_ID")
1914

@@ -83,7 +78,7 @@ def get_daily_love():
8378
return daily_love
8479

8580

86-
def send_weather(access_token, openId, weather):
81+
def send_weather(access_token, weather):
8782
# touser 就是 openID
8883
# template_id 就是模板ID
8984
# url 就是点击模板跳转的url
@@ -92,7 +87,7 @@ def send_weather(access_token, openId, weather):
9287
import datetime
9388
today = datetime.date.today()
9489
today_str = today.strftime("%Y年%m月%d日")
95-
90+
9691
body = {
9792
"touser": openId.strip(),
9893
"template_id": weather_template_id.strip(),
@@ -123,21 +118,16 @@ def send_weather(access_token, openId, weather):
123118

124119

125120

126-
def weather_report(this_user, this_city):
121+
def weather_report(this_city):
127122
# 1.获取access_token
128123
access_token = get_access_token()
129124
# 2. 获取天气
130125
weather = get_weather(this_city)
131126
print(f"天气信息: {weather}")
132-
# 3. 获取用户列表
133-
print(f"用户: {this_user}")
134127
# 3. 发送消息
135-
send_weather(access_token, this_user, weather)
128+
send_weather(access_token, weather)
136129

137130

138131

139132
if __name__ == '__main__':
140-
print(f"用户列表: {openId_list}")
141-
print(f"地点列表: {Location_list}")
142-
for _ in range(0,len(openId_list)):
143-
weather_report(openId_list[_],Location_list[_])
133+
weather_report("淄博")

0 commit comments

Comments
 (0)