def send_alarm_msg(): """ 发送定时提醒 """ print('\n启动定时自动提醒...') conf = get_yaml() for gf in conf.get('girlfriend_infos'): dictum = get_dictum_info(gf.get('dictum_channel')) weather = get_weather_info(gf.get('city_name')) diff_time = get_diff_time(gf.get('start_date')) sweet_words = gf.get('sweet_words') send_msg = '\n'.join(x for x in [weather, dictum, diff_time, sweet_words] if x) print(send_msg) if not send_msg or not is_online(): continue # 给微信好友发信息 wechat_name = gf.get('wechat_name') if wechat_name: if wechat_name.lower() in FILEHELPER_MARK: itchat.send(send_msg, toUserName=FILEHELPER) print('定时给『{}』发送的内容是:\n{}\n发送成功...\n\n'.format(wechat_name, send_msg)) else: wechat_users = itchat.search_friends(name=wechat_name) if not wechat_users: continue wechat_users[0].send(send_msg) print('定时给『{}』发送的内容是:\n{}\n发送成功...\n\n'.format(wechat_name, send_msg)) # 给群聊里发信息 group_name = gf.get('group_name') if group_name: group = get_group(group_name) if group: group.send(send_msg) print('定时给群聊『{}』发送的内容是:\n{}\n发送成功...\n\n'.format(group_name, send_msg)) print('自动提醒消息发送完成...\n')
def get_alarm_msg(): conf = get_yaml() for gf in conf['girlfriend_infos']: dictum = get_dictum_info() weather = get_weather_info(gf['city_name']) diff_time = get_diff_time(gf['start_date']) sweet_words = gf['sweet_words'] send_msg = '\n'.join( x for x in [dictum, weather, diff_time, sweet_words] if x) # print(send_msg) if send_msg and is_online(): authors = itchat.search_friends(nickName=gf['wechat_name']) if authors: authors[0].send(send_msg) print('\n定时给『{}』发送的内容是:\n{}\n发送成功...\n'.format( gf['wechat_name'], send_msg))
def get_alarm_msg(): """ 定时提醒内容 """ conf = get_yaml() for gf in conf.get('girlfriend_infos'): dictum = get_dictum_info(gf.get('dictum_channel')) weather = get_weather_info(gf.get('city_name')) diff_time = get_diff_time(gf.get('start_date')) sweet_words = gf.get('sweet_words') send_msg = '\n'.join(x for x in [dictum, weather, diff_time, sweet_words] if x) print(send_msg) if send_msg and is_online(): wechat_name = gf.get('wechat_name') authors = itchat.search_friends(nickName=wechat_name) if authors: authors[0].send(send_msg) print('\n定时给『{}』发送的内容是:\n{}\n发送成功...\n'.format(wechat_name, send_msg)) else: print('定时提醒发送失败,微信名 {} 失效。'.format(wechat_name))