自动回复

自动回复

注: 这里说的自动回复是依赖第三方 API的

我这里用的API是 www.xiaohuangji.com
它的API(API我自己用chrome console 看的)有两种 POSTGET

POST

type : post
url: .php
参数: para

GET

Type : get
.php?para=1234

如果自己在写一些测试的时候发现 cross origin 类似的错误,可以把浏览器的跨域安全给关掉或者直接用一些专门发request 的工具(在线的也可以). 在Mac 下关掉 chrome 跨域安全是 open -a /Applications/Google\ Chrome.app --args --disable-web-security(其它的一些自己搜索 关掉chrome 跨哉)

我自己用这个API做了一个web QQ自动回复的,比较简陋,是用javascript 写的. 使用很简单,登陆好 WebQQ,把窗口拖小一点, 然后打一个好友聊天的对话框,QQ群也可以,但是计论组不可以. 然后打开 Chrome 控制台,运行所有的 javascript 代码就好.

xmlHttpReg = new XMLHttpRequest();
lastM = '';//获取最后一条消息
function getLastMessage(){chatContent = document.getElementsByClassName('buddy');last = chatContent[chatContent.length-1];lastAllChildren = last.children;lastMsg = lastAllChildren[lastAllChildren.length - 1];lastMsgContent = lastMsg.innerText;//lastM = lastMsgContent;console.log("getLastMessage success!! " + lastMsgContent);return lastMsgContent;}//发送消息
function sendContent(content) {document.getElementById('chat_textarea').value=content;document.getElementById('send_chat_btn').click();console.log("sendContent success!! " + content);
}//根据上面说的API去获取自动回复的消息然后发给好友
function getReplyMsg(sendMsg) {if (sendMsg != lastM) {console.log("begin send request !");var para = "para=" + sendMsg;xmlHttpReg.open('post','.php',true);xmlHttpReg.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");xmlHttpReg.onreadystatechange = doResult;xmlHttpReg.send(para);lastM = sendMsg;};
}function doResult() {        if (xmlHttpReg.readyState == 4) {//4代表执行完成if (xmlHttpReg.status == 200) {//200代表执行成功console.log("send success!! " + xmlHttpReg.responseText);sendContent(xmlHttpReg.responseText);}}
}function doReply() {getReplyMsg(getLastMessage());
}//每隔3秒执行一次~~
var timerID = window.setInterval("doReply()",3000);

详细请见~

发布者:admin,转转请注明出处:http://www.yc00.com/news/1691000127a483233.html

相关推荐

  • 自动回复

    2023-8-3
    1740
  • 使用ChatGPT搭建微信机器人实现自动回复

    在现在的手机数字时代,微信是中国最流行的社交软件,已经被广泛应用于各个领域。但是,对于很多人来说,怎么去做一个微信机器人仍然是个难题。别担心&#

    5月前
    120
  • 使用ChatGPT创建微信机器人自动回复和群发消息

    在现在的手机数字时代,微信是中国最流行的社交软件,已经被广泛应用于各个领域。但是,对于很多人来说,怎么去做一个微信机器人仍然是个难题。别担心,用ChatGPT,你可以轻松地做出一个微信机器人,提高工作效率,还能让聊天更有趣。 ChatGP

    2月前
    230

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信