Skip to content

Commit

Permalink
Amend PR
Browse files Browse the repository at this point in the history
  • Loading branch information
NoobHumiliator committed Jan 7, 2024
1 parent 4929140 commit 4176ae4
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 18 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/love_heart_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: 画爱心macos版

on:
workflow_dispatch:

permissions:
contents: read

jobs:
pyinstaller-build:
runs-on: macos-latest
steps:
- name: Create Executable
uses: sayyid5416/pyinstaller@v1
with:
python_ver: '3.12'
spec: 'love_heart.py'
upload_exe_with_name: 'love_heart'
options: --onefile, --name "love_heart", --windowed,
22 changes: 22 additions & 0 deletions .github/workflows/love_heart_ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: 画爱心Ubuntu版

on:
workflow_dispatch:

permissions:
contents: read

jobs:
pyinstaller-build:
runs-on: ubuntu-latest
steps:
- name: Create Executable
uses: sayyid5416/pyinstaller@v1
with:
python_ver: '3.12'
spec: 'love_heart.py'
upload_exe_with_name: 'love_heart'
options: --onefile, --name "love_heart", --windowed,
22 changes: 22 additions & 0 deletions .github/workflows/love_heart_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: 画爱心Windows版

on:
workflow_dispatch:

permissions:
contents: read

jobs:
pyinstaller-build:
runs-on: windows-latest
steps:
- name: Create Executable
uses: sayyid5416/pyinstaller@v1
with:
python_ver: '3.12'
spec: 'love_heart.py'
upload_exe_with_name: 'love_heart'
options: --onefile, --name "love_heart", --windowed,
3 changes: 1 addition & 2 deletions .github/workflows/weather_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: 天气预报推送

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

Expand Down Expand Up @@ -36,4 +36,3 @@ jobs:
APP_SECRET: ${{ secrets.APP_SECRET }}
OPEN_ID: ${{ secrets.OPEN_ID }}
TEMPLATE_ID: ${{ secrets.TEMPLATE_ID }}
LOCATION_LIST: ${{ secrets.LOCATION_LIST }}
22 changes: 6 additions & 16 deletions weather_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
appID = os.environ.get("APP_ID")
appSecret = os.environ.get("APP_SECRET")
# 收信人ID即 用户列表中的微信号
openId_str = os.environ.get("OPEN_ID", "")
openId_list = [id.strip() for id in openId_str.split('\n') if id.strip()]
# 读入地址列表
location_str = os.environ.get("LOCATION_LIST", "")
Location_list = [loc.strip() for loc in location_str.split('\n') if loc.strip()]

openId = os.environ.get("OPEN_ID")
# 天气预报模板ID
weather_template_id = os.environ.get("TEMPLATE_ID")

Expand Down Expand Up @@ -83,7 +78,7 @@ def get_daily_love():
return daily_love


def send_weather(access_token, openId, weather):
def send_weather(access_token, weather):
# touser 就是 openID
# template_id 就是模板ID
# url 就是点击模板跳转的url
Expand All @@ -92,7 +87,7 @@ def send_weather(access_token, openId, weather):
import datetime
today = datetime.date.today()
today_str = today.strftime("%Y年%m月%d日")

body = {
"touser": openId.strip(),
"template_id": weather_template_id.strip(),
Expand Down Expand Up @@ -123,21 +118,16 @@ def send_weather(access_token, openId, weather):



def weather_report(this_user, this_city):
def weather_report(this_city):
# 1.获取access_token
access_token = get_access_token()
# 2. 获取天气
weather = get_weather(this_city)
print(f"天气信息: {weather}")
# 3. 获取用户列表
print(f"用户: {this_user}")
# 3. 发送消息
send_weather(access_token, this_user, weather)
send_weather(access_token, weather)



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

0 comments on commit 4176ae4

Please sign in to comment.