最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

python讓微信好友自動(dòng)回復(fù)信息

2023-04-02 16:28 作者:努力學(xué)習(xí)天天賺錢123456  | 我要投稿

import requests
from wxauto import *
from urllib import request, parse
import time
import json


class autoReply():
? ?def __init__(self):
? ? ? ?# 獲取當(dāng)前微信客戶端
? ? ? ?self.wx = WeChat()
? ? ? ?# 天行數(shù)據(jù)接口格式
? ? ? ?self.headers = {
? ? ? ? ? ?'Content-type': 'application/x-www-form-urlencoded'
? ? ? ?}
? ? ? ?# 填寫你自己的密鑰
? ? ? ?self.data = {
? ? ? ? ? ?"key": "625d00ebfce080d9a6d4236baa0c0cc1",
? ? ? ?}

? ?def GetLast_Message(self, user):
? ? ? ?# 獲取user的最新一條消息
? ? ? ?i = -1
? ? ? ?messages = self.wx.GetAllMessage
? ? ? ?while True:
? ? ? ? ? ?if messages[i][0] == user:
? ? ? ? ? ? ? ?message = messages[i]
? ? ? ? ? ? ? ?return message
? ? ? ? ? ?i = i - 1

? ?# 定時(shí)發(fā)送早上每日一言,晚安!
? ?def send_time(self, time1, time2):
? ? ? ?t = time.strftime('%H:%M:%S', time.localtime())
? ? ? ?if t == time1:
? ? ? ? ? ?# 每日一言接口
? ? ? ? ? ?url2 = 'https://api.xygeng.cn/one'
? ? ? ? ? ?data = parse.urlencode(self.data)
? ? ? ? ? ?req = request.Request(url=url2, headers=self.headers, data=bytes(data, encoding="utf-8"))
? ? ? ? ? ?res = request.urlopen(req)
? ? ? ? ? ?json_data = json.load(res)
? ? ? ? ? ?print(json_data)
? ? ? ? ? ?if json_data["code"] == 200:
? ? ? ? ? ? ? ?message = json_data['data']['content']
? ? ? ? ? ? ? ?message = '每日一言:' + message
? ? ? ? ? ? ? ?self.wx.SendMsg(message)
? ? ? ? ? ?else:
? ? ? ? ? ? ? ?self.wx.SendMsg('每日一言')
? ? ? ?elif t == time2:
? ? ? ? ? ?# 天行數(shù)據(jù)的晚安心語(yǔ)接口
? ? ? ? ? ?url1 = "https://apis.tianapi.com/wanan/index"
? ? ? ? ? ?data = parse.urlencode(self.data)
? ? ? ? ? ?req = request.Request(url=url1, headers=self.headers, data=bytes(data, encoding="utf-8"))
? ? ? ? ? ?res = request.urlopen(req)
? ? ? ? ? ?json_data = json.load(res)
? ? ? ? ? ?if json_data["code"] == 200:
? ? ? ? ? ? ? ?message = json_data['result']['content']
? ? ? ? ? ? ? ?self.wx.SendMsg(message)
? ? ? ? ? ?else:
? ? ? ? ? ? ? ?self.wx.SendMsg('晚安')

? ?def reply_message(self, user):
? ? ? ?# 機(jī)器人接口
? ? ? ?url = 'https://v.api.aa1.cn/api/api-xiaoai/talk.php'
? ? ? ?# 打開user聊天框
? ? ? ?self.wx.ChatWith(user)
? ? ? ?# 獲取user的最后一條信息
? ? ? ?a = self.GetLast_Message(user)
? ? ? ?b = 0
? ? ? ?while True:
? ? ? ? ? ?# 定時(shí)發(fā)送
? ? ? ? ? ?time1 = '08:00:00' ?# 早上時(shí)間
? ? ? ? ? ?time2 = '22:00:00' ?# 晚上時(shí)間
? ? ? ? ? ?self.send_time(time1, time2)
? ? ? ? ? ?# 自動(dòng)回復(fù)
? ? ? ? ? ?message = self.GetLast_Message(user)
? ? ? ? ? ?# 修改自動(dòng)回復(fù)的第一句
? ? ? ? ? ?if message != a and b != 0:
? ? ? ? ? ? ? ?res = requests.get(url=url, params="msg=" + message[1])
? ? ? ? ? ? ? ?self.wx.SendMsg(res.text)
? ? ? ? ? ? ? ?a = message
? ? ? ? ? ?elif message != a and b == 0:
? ? ? ? ? ? ? ?self.wx.SendMsg("主人不在,有什么問題我可以為你解決哦!")
? ? ? ? ? ? ? ?b = b + 1


if __name__ == '__main__':
? ?x = autoReply()
? ?# 輸入你要自動(dòng)回復(fù)的朋友的名字
? ?x.reply_message('好友昵稱')




python讓微信好友自動(dòng)回復(fù)信息的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
唐河县| 宁城县| 湘阴县| 武威市| 柳州市| 灵寿县| 泰和县| 迁安市| 万州区| 英吉沙县| 广水市| 攀枝花市| 开江县| 水城县| 土默特左旗| 大宁县| 汾阳市| 探索| 阿坝| 泊头市| 法库县| 子洲县| 万年县| 石楼县| 商都县| 开化县| 侯马市| 泗阳县| 公安县| 南澳县| 秦安县| 海兴县| 平舆县| 南和县| 绵竹市| 磐石市| 淮阳县| 威海市| 辽阳县| 深圳市| 万全县|