from wxauto import WeChat from datetime import date import sys import os import subprocess import json from config import CONFIG import time def send_daily_message(): """发送每日消息的主函数""" today = date.today() formatted_date = today.strftime('%Y-%m-%d') file_name = formatted_date + ".png" file_path = CONFIG['file_path'] + file_name try: wx = WeChat() except: subprocess.run([sys.executable, 'send_openmsg.py']) return False msg = 'hello, wxauto!' who = CONFIG['messages_reciever'] if os.path.isfile(file_path): print("找到了指定文件!") wx.SendFiles(filepath=file_path, who="File Transfer") wx.SendMsg(msg=msg, who=who) return True else: print("没找到指定文件") subprocess.run([sys.executable, 'send_filemsg.py']) return False # 如果直接运行此脚本,执行发送消息功能 if __name__ == "__main__": send_daily_message()