diff --git a/.github/workflows/love_heart_macos.yml b/.github/workflows/love_heart_macos.yml new file mode 100644 index 0000000..6e4f824 --- /dev/null +++ b/.github/workflows/love_heart_macos.yml @@ -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, diff --git a/.github/workflows/love_heart_ubuntu.yml b/.github/workflows/love_heart_ubuntu.yml new file mode 100644 index 0000000..18fb82e --- /dev/null +++ b/.github/workflows/love_heart_ubuntu.yml @@ -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, diff --git a/.github/workflows/love_heart_windows.yml b/.github/workflows/love_heart_windows.yml new file mode 100644 index 0000000..5f286eb --- /dev/null +++ b/.github/workflows/love_heart_windows.yml @@ -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, diff --git a/.github/workflows/weather_report.yml b/.github/workflows/weather_report.yml index c98a14f..e18682e 100644 --- a/.github/workflows/weather_report.yml +++ b/.github/workflows/weather_report.yml @@ -5,7 +5,7 @@ name: 天气预报推送 on: schedule: - # 设置启动时间,为 UTC 时间。 + # 设置启动时间,为 UTC 时间, UTC23点 对应北京时间早7点 - cron : '00 23 * * *' workflow_dispatch: @@ -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 }} diff --git a/weather_report.py b/weather_report.py index 165fb0a..06a2c6f 100644 --- a/weather_report.py +++ b/weather_report.py @@ -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") @@ -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 @@ -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(), @@ -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("淄博") \ No newline at end of file