diff --git a/venv/Include/wechat/autoSendMessage.py b/venv/Include/wechat/autoSendMessage.py index c7dd095..db48421 100644 --- a/venv/Include/wechat/autoSendMessage.py +++ b/venv/Include/wechat/autoSendMessage.py @@ -30,7 +30,7 @@ def getFriend(self, name): userName = friends[0]['UserName'] return userName - def getFriends(self): + def getFriends(self): friends = itchat.get_friends(update=True)[0:] return friends @@ -69,7 +69,10 @@ def ratio(self, friends): def signature(self, friends): tList = [] for i in friends: + nickName = i["NickName"] + remarkName = i["RemarkName"] signature = i["Signature"].replace(" ", "").replace("span", "").replace("class", "").replace("emoji", "") + print("昵称:" + nickName + " ;备注名:" + remarkName + " ;签名:" + signature) rep = re.compile("1f\d.+") signature = rep.sub("", signature) tList.append(signature) @@ -98,7 +101,10 @@ def sendMessage(self, message, name): def readStory(self): print('readStory do') # stroy = dataUtil.getBookInfo('./从你的全世界路过.txt') - stroy = dataUtil.getBookInfo('./送你一颗子弹.txt') + # stroy = dataUtil.getBookInfo('./送你一颗子弹.txt') + # stroy = dataUtil.getBookInfo('./人间草木.txt') + # stroy = dataUtil.getBookInfo('./一只特立独行的猪.txt') + stroy = dataUtil.getBookInfo('./生活,是很好玩的.txt') dataUtil.getBingPhoto('0') yfei = wechat.getFriend('乐多') @@ -116,7 +122,8 @@ def readStory(self): # 推送每日早报 def dailyInfo(self): print('dailyInfo do') - jiujiang = dataUtil.getWeatherData('九江') + jiujiang = dataUtil.getWeatherData('都昌') + # hangzhou = dataUtil.getWeatherData('杭州') # wechat.sendMessage(jiujiang, 'filehelper') yfei = wechat.getFriend('乐多') wechat.sendMessage(jiujiang, yfei) @@ -125,6 +132,14 @@ def dailyInfo(self): # group1 = wechat.getRoom('阿里A3研发部') # wechat.sendMessage(hangz, group1) + # 提示 + def test(self): + yfei = wechat.getFriend('乐多') + wechat.sendMessage('记得拿外套,记得拿外套', yfei) + wechat.sendMessage('记得拿外套,记得拿外套', yfei) + wechat.sendMessage('记得拿外套,记得拿外套', yfei) + wechat.sendMessage('记得拿外套,记得拿外套', yfei) + wechat.sendMessage('记得拿外套,记得拿外套', yfei) # qinghua def qinghua(self): print('qinghua do') @@ -190,23 +205,24 @@ def get_response(msg): wechat = WeChat() #这里是封装的 itchat # 开启微信登录线程,需要单独占个线程 _thread.start_new_thread(wechat.login, ( )) - + # 配置定时任务 # 开启早间天气预报 定时任务 -schedule.every().day.at("7:00").do(wechat.dailyInfo) +schedule.every().day.at("8:00").do(wechat.dailyInfo) # 开启每日一句 定时任务 -schedule.every().day.at("20:00").do(wechat.qinghua) +schedule.every().day.at("19:30").do(wechat.qinghua) # 开启睡前故事 定时任务 -schedule.every().day.at("21:30").do(wechat.readStory) +schedule.every().day.at("20:00").do(wechat.readStory) while True: schedule.run_pending() time.sleep(1) # if __name__ == "__main__": # wechat = WeChat() -# wechat.login(); -# group = wechat.getRooms() -# print("") +# # wechat.login(); +# itchat.auto_login() +# # group = wechat.getRooms() +# # print("") # friends = wechat.getFriends() # wechat.signature(friends) # wechat.ratio(friends) diff --git a/venv/Include/wechat/chatUseData.py b/venv/Include/wechat/chatUseData.py index 10e4384..faa5fe6 100644 --- a/venv/Include/wechat/chatUseData.py +++ b/venv/Include/wechat/chatUseData.py @@ -16,12 +16,12 @@ key = 'cc186c9881b94b42b886a6d634c63002' key_jh = '777d35900bffe58af88f56069b12785c' # 提取故事的第一天 -readBookStartDay = datetime.datetime(2019, 3, 30) +readBookStartDay = datetime.datetime(2020, 2, 4) # 提取情话的第一天 qinghuaStartDay = datetime.datetime(2019, 3, 19) # 天气计算开始时间 -weatherStartDay = datetime.datetime(2019, 4, 14) -cityList = [ '九江', '九江', '九江','九江', '九江', '九江', '九江','九江', '九江', '九江', '九江', '九江','九江', '九江', '九江', '九江','九江', '九江', '九江']; +weatherStartDay = datetime.datetime(2019, 4, 30) +cityList = [ '九江&杭州', '九江&杭州', '九江&杭州','九江&杭州', '九江&杭州', '九江&杭州', '九江','九江', '九江', '九江', '九江', '九江','九江', '九江', '九江', '九江','九江', '九江', '九江']; class DataUtil(): # 获取天气信息 @@ -29,14 +29,17 @@ def getWeatherData(self, cityname): today = datetime.datetime.now() dayCount = (today - weatherStartDay).days # cityname = cityList[dayCount] - # 阿凡达数据 - url = ' http://api.avatardata.cn/Weather/Query?key=' + key + '&cityname=' + cityname - # 聚合数据 - url_jh = 'http://v.juhe.cn/weather/index?key=' + key_jh + '&cityname=' + cityname - results = common.get(url) - text = self.parseInfo_afd(results) - print(text) - return text + textContent = '' + citys = cityname.split('&') + for city in citys: + # 阿凡达数据 + url = ' http://api.avatardata.cn/Weather/Query?key=' + key + '&cityname=' + city + # 聚合数据 + url_jh = 'http://v.juhe.cn/weather/index?key=' + key_jh + '&cityname=' + city + results = common.get(url) + textContent += self.parseInfo_afd(results) + print(textContent) + return textContent # 简单的数据封装 def parseInfo_afd(self, jsons): @@ -59,7 +62,7 @@ def parseInfo_afd(self, jsons): textInfo = textInfo + '运动指数:' + jsonData['result']['life']['info']['yundong'][0] + ' - ' + jsonData['result']['life']['info']['yundong'][1] + '\n\n' textInfo = textInfo + '感冒指数:' + jsonData['result']['life']['info']['ganmao'][0] + ' - ' + jsonData['result']['life']['info']['ganmao'][1] + '\n\n' textInfo = textInfo + '紫外线指数:' + jsonData['result']['life']['info']['ziwaixian'][0] + ' - ' + jsonData['result']['life']['info']['ziwaixian'][1] + '\n\n' - textInfo = textInfo + 'by:小可爱的贴心秘书' + '\n' + textInfo = textInfo + 'by:小可爱的贴心秘书' + '\n\n' return textInfo def parseInfo_jh(self, jsons): @@ -85,7 +88,7 @@ def parseInfo_jh(self, jsons): # 睡前故事 def getBookInfo(self, filePath): radioList = [] #微信每次最多只能发送的字符是有限制的,我每25行发送一次信息 - tempInfo = '睡前故事:刘瑜 - 《送你一颗子弹》.\n\n' + tempInfo = '睡前故事:汪曾祺 - 《生活,是很好玩的》.\n\n' readFlag = False #是否读取 today = datetime.datetime.now() dayCount = (today - readBookStartDay).days + 1 @@ -98,11 +101,11 @@ def getBookInfo(self, filePath): if readFlag: # 预计文本长度 微信每次最多只能发送的字符是有限制的 length = len(tempInfo) + len(line) - if length > 1500: + if length > 1200: radioList.append(tempInfo) tempInfo = '' tempInfo += line - tempInfo += '\n晚安\n' + 'by:小可爱的贴心秘书' + '\n' + tempInfo += '\n\n晚安\n' + 'by:小可爱的贴心秘书' + '\n' radioList.append(tempInfo) # common.txtToMp3(radioList) #文字生成语音 发送语音 print(radioList) @@ -111,17 +114,17 @@ def getBookInfo(self, filePath): # 每日一句 def getDaily(self): nowDay = datetime.datetime.now().strftime('%Y-%m-%d'); - tempInfo = '早安:\n' + tempInfo = '晚上好鸭:\n' url = "http://open.iciba.com/dsapi/" # 官方提供的API results = common.get(url) resultsData = json.loads(results) content = resultsData['content'] note = resultsData['note'] translation = resultsData['translation'] - translation = translation.replace("小编的话", "多说一句") + translation = translation.replace("小编的话", "我想说") tempInfo += content + '\n' tempInfo += note + '\n\n' - tempInfo += translation + '\n' + # tempInfo += translation + '\n' tempInfo += '\n爱你!\n' print(tempInfo) return tempInfo @@ -182,13 +185,28 @@ def getBingPhoto(self, index): dataUtil = DataUtil() dataUtil.getDaily() - # dataUtil.getBingPhoto('3') - # stroy = dataUtil.getBookInfo('./送你一颗子弹.txt') + # print(dataUtil.getWeatherData('')) + # dataUtil.getBingPhoto('0') + stroy = dataUtil.getBookInfo('./生活,是很好玩的.txt') # qinghua = dataUtil.getQinghua('./qinghua.txt') - # for line in open('送你一颗子弹.txt', encoding='utf-8'): - # print(line) - # b = line != ' \n' + + + + # size = 0 + # for line in open('间客.txt', encoding='utf-8'): + # if len(line) > 120: + # print(" " + line[0:120]) + # print(" " + line[120:len(line)], end="") + # else: + # print(" " + line, end="") + # size = size + 1 + # if size > 1500 : break + + + + + # b = line != ' \n' # for txt in stroy: # print(txt) # msg_information['001'] = '001' @@ -205,10 +223,25 @@ def getBingPhoto(self, index): # msg_information['001'] = '001' # print(msg_information) - - # with open('./送你1颗子弹.txt',encoding='utf-8',mode = 'w') as f: - # for line in open('./送你一颗子弹.txt', encoding='utf-8'): - # if line != ' \n': + # lineIndex = 0 + # + # with open('./生活,是很好玩的.txt',encoding='utf-8',mode = 'w') as f: + # for line in open('./一只特立独行的猪1.txt', encoding='utf-8'): + # if line != '\n': # f.writelines(line) + # f.writelines(line) + # if lineIndex%11 == 0: + # f.writelines("night." + str(nightIndex) + "\n") + # nightIndex = nightIndex + 1 + # if line.startswith(' '): + # print(line) + # f.writelines(line) + # else: + # print(line) + # lineIndex = lineIndex + 1 + # f.writelines("night." + str(lineIndex) + "\n") + # f.writelines(line) + + diff --git a/venv/Include/wechat/wechat_cloud.png b/venv/Include/wechat/wechat_cloud.png index 2383f01..ef52775 100644 Binary files a/venv/Include/wechat/wechat_cloud.png and b/venv/Include/wechat/wechat_cloud.png differ diff --git "a/venv/Include/wechat/\351\200\201\344\275\240\344\270\200\351\242\227\345\255\220\345\274\271.txt" "b/venv/Include/wechat/\351\200\201\344\275\240\344\270\200\351\242\227\345\255\220\345\274\271.txt" index 61878fb..2321dc1 100644 --- "a/venv/Include/wechat/\351\200\201\344\275\240\344\270\200\351\242\227\345\255\220\345\274\271.txt" +++ "b/venv/Include/wechat/\351\200\201\344\275\240\344\270\200\351\242\227\345\255\220\345\274\271.txt" @@ -474,7 +474,7 @@ night.27 “如果我疯了”这句歌词真带劲,真适合两个有志青年在大街上边骑快车边大声歌唱。对于有志青年来说,发疯是多么灿烂的事情,简直是义不容辞。 2002年的时候,崔健来纽约演出一次,我去听了。音乐一响起,我就泪流满面。好像多年没见的亲戚在生离死别后重逢似的。我的整个青春仿佛麦田一样随他的歌声摇摆起来,金灿灿的。当时我就想,老崔啊老崔,你都四十了,我也直奔三十了,但是,这么多年过去了,你还在我心里,还那么温暖,谢谢你。 其实我现在都不怎么听崔健了,虽然他的cd、磁带都收藏着。长大的我,音乐的口味终于开始变得宽容,终于知道正如在小虎队之外还有崔健,在崔健之外也还有别人。但是回望自己的青春时,崔健是多么重要啊,堪称独树一帜。一个只有一国两制的含义和解析几何的青春会是多么缺乏诗意。是他,这个摇滚青年中年老年,在20世纪80年代末90年代初的中国,大声摇滚,离经叛道地摇滚,让一个在高考荒原上跋涉的女中学生,在一口很深的井底,猛然抬起了头来。 -night28 +night.28 开头 王小雨在邮箱里看到一封陌生人的来信,点开却一个字也没有,只有一个图片附件,再点开,是一张照片。她自己,刚才,半个小时前,在卫生间洗脸。照片上,她正在往脸上抹洗面奶。没错,她自己。王小雨尖叫一声,好像鼠标烫手似的,把它给砸了出去。 别奇怪,这是我编的一个小说的开头,恐怖小说。