可爱猫微信机器人

环境下载

进入可爱猫机器人官网下载运行环境

特点:需要桌面环境运行,同时需要登录PC版微信

接受消息回调API

添加接受消息接口

接口参数如下

参数 类型 描述
type int 事件类型[见下方事件类型表]
from_wxid String 1级来源id(比如发消息的人的id)
from_name String 1级来源昵称(比如发消息的人昵称)
final_from_wxid String 2级来源id(群消息事件下,1级来源为群id,2级来源为发消息的成员id,私聊事件下都一样)
final_nickname String 2级来源昵称
robot_wxid String 当前登录的账号(机器人)标识id
msg String 消息内容
parameters String 附加参数(暂未用到,请忽略)
time int 请求时间(时间戳10位版本)
[事件类型表]
事件类型type数值 描述
100 私聊消息
200 群聊消息
300 暂无
400 群成员增加
410 群成员减少
500 收到好友请求
600 二维码收款
700 收到转账
800 软件开始启动
900 新的账号登录完成
910 账号下线

发送指令API

URL: http://127.0.0.1:8073/send

发送文本消息

参数 描述
type 100
msg 发送内容
to_wxid 对方id
robot_wxid 账户id,用哪个账号去发送这条消息

发送群消息并艾特某人

参数 描述
type 102
robwxid 账户id,用哪个账号去发送这条消息
to_wxid 群id
at_wxid 艾特的id,群成员的id
at_name 艾特的昵称,群成员的昵称
msg 消息内容

发送图片消息

参数 描述
type 103
robwxid 登录账号id,用哪个账号去发送这条消息
to_wxid 对方的id,可以是群或者好友id
path 图片的绝对路径

发送视频消息

参数 描述
type 104
robwxid 账户id,用哪个账号去发送这条消息
to_wxid 对方的id,可以是群或者好友id
path 视频的绝对路径

发送文件消息

参数 描述
type 105
robwxid 账户id,用哪个账号去发送这条消息
to_wxid 对方的id,可以是群或者好友id
path 文件的绝对路径

发送动态表情

参数 描述
type 106
robwxid 账户id,用哪个账号去发送这条消息
to_wxid 对方的id,可以是群或者好友id
path 动态表情文件(通常是gif)的绝对路径

发送分享链接

参数 描述
type 107
robwxid 账户id,用哪个账号去发送这条消息
to_wxid 对方的id,可以是群或者好友id
msg {“title”:”链接标题”,”text”:”链接内容”,”url”:”跳转链接”,”pic”:”图片链接”}

发送音乐消息

参数 描述
type 108
robwxid 账户id,用哪个账号去发送这条消息
to_wxid 对方的id,可以是群或者好友id
name 歌曲名字

取指定登录账号的昵称

参数 描述
type 201
robwxid 账户id

取指定登录账号的头像

参数 描述
type 202
robwxid 账户id

取登录账号列表

参数 描述
type 203

取好友列表

参数 描述
type 204
robwxid 账户id
is_refresh 是否刷新

取群聊列表

参数 描述
type 205
robwxid 账户id
is_refresh 是否刷新

取群成员资料

参数 描述
type 206
robwxid 账户id
group_wxid 群id
is_refresh 是否刷新

取群成员列表

参数 描述
type 207
robwxid 账户id
group_wxid 群id
member_wxid 群成员id

接收好友转账

参数 描述
type 301
robwxid 账户id
friend_wxid 朋友id
json_string 转账事件原消息

同意群聊邀请

参数 描述
type 302
robwxid 账户id
json_string 同步消息事件中群聊邀请原消息

同意好友请求

参数 描述
type 303
robwxid 账户id
json_string 好友请求事件中原消息

修改好友备注

参数 描述
type 304
robwxid 账户id
friend_wxid 好友id
note 新备注(空字符串则是删除备注)

删除好友

参数 描述
type 305
robwxid 账户id
friend_wxid 好友id

踢出群成员

参数 描述
type 306
robwxid 账户id
group_wxid 群id
member_wxid 群成员id

修改群名称

参数 描述
type 307
robwxid 账户id
group_wxid 群id
group_name 新群名

修改群公告

参数 描述
type 308
robwxid 账户id
group_wxid 群id
notice 新公告

建立新群

参数 描述
type 309
robwxid 账户id
friends 三个人及以上的好友id数组,[‘wxid_1xxx’, ‘wxid_2xxx’, ‘wxid_3xxx’, ‘wxid_4xxx’]

退出群聊

参数 描述
type 310
robwxid 账户id
group_wxid 群id

邀请加入群聊

参数 描述
type 311
robwxid 账户id
group_wxid 群id
friend_wxid 好友id

java调用示例

*笔者使用的是htmlunit工具,maven引入如下

1
2
3
4
5
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.33</version>
</dependency>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import com.gargoylesoftware.htmlunit.HttpMethod;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebRequest;
import net.sf.json.JSONObject;
import java.net.URL;
import java.net.URLEncoder;

public class KeAImao {

public static JSONObject sendCatPOST(JSONObject body) throws Exception{
WebClient webClient = new WebClient();
WebRequest webRequest = new WebRequest(new URL("http://127.0.0.1:8073/send"), HttpMethod.POST);
webRequest.setRequestBody(body.toString());
Page page = webClient.getPage(webRequest);
JSONObject JSON = JSONObject.fromObject(page.getWebResponse().getContentAsString());
return JSON;
}

public static void main(String[] args) throws Exception{
String msg = URLEncoder.encode("abcABC\n测试","utf-8");
JSONObject jsonBody = new JSONObject();
jsonBody.put("type", "100");
jsonBody.put("msg", msg);
jsonBody.put("to_wxid", "wxid_*************");
jsonBody.put("robot_wxid", "wxid_*************");
KeAImao.sendCatPOST(jsonBody);
}
}
文章作者: 柯熠
文章链接: https://smallkserver.github.io/2019/12/27/keaimao/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Smallkserver
打赏
  • 微信
  • 支付宝

评论