xuxiaoxiao-xxx / Chatapi Wechat
Licence: apache-2.0
Java版本微信聊天接口,使用网页微信API,让你能够开发自己的微信聊天机器人
Stars: ✭ 207
Programming Languages
java
68154 projects - #9 most used programming language
Projects that are alternatives of or similar to Chatapi Wechat
Wechat Go
go version wechat web api and message framework for building wechat robot
Stars: ✭ 1,381 (+567.15%)
Mutual labels: api, bot, robot, wechat
Itchat
A complete and graceful API for Wechat. 微信个人号接口、微信机器人及命令行微信,三十行即可自定义个人号机器人。
Stars: ✭ 21,935 (+10496.62%)
Mutual labels: api, robot, wechat
Mojo Weixin
使用Perl语言(不会没关系)编写的个人账号微信/weixin/wechat客户端框架(非GUI),可通过插件提供基于HTTP协议的api接口供其他语言或系统调用
Stars: ✭ 1,181 (+470.53%)
Mutual labels: api, bot, wechat
Csgofloat Inspect
Source Code that Powers the CSGOFloat Inspect Link API
Stars: ✭ 172 (-16.91%)
Mutual labels: api, bot
Slack Starterbot
Python-powered simple starter Slack bot.
Stars: ✭ 169 (-18.36%)
Mutual labels: api, bot
Whatsapp Web.js
A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
Stars: ✭ 4,103 (+1882.13%)
Mutual labels: api, bot
Wechatbotengine
基于微信网页版 HTTP 协议的机器人引擎(含一些机器人)。WeChat bot engine based on WeChat HTTP protocol of WeChat Web Edition, several bots included.
Stars: ✭ 145 (-29.95%)
Mutual labels: bot, wechat
Wechat Robot
✅ js微信聊天机器人(使用个人账号,非公众号) Wechat chat robot write by js.
Stars: ✭ 173 (-16.43%)
Mutual labels: robot, wechat
Node Fb Messenger
✉️ Facebook Messenger Platform Node.js API Wrapper
Stars: ✭ 206 (-0.48%)
Mutual labels: api, bot
Rest980
REST interface to control your iRobot Roomba 980 via local server on your lan.
Stars: ✭ 186 (-10.14%)
Mutual labels: api, robot
Jda
Java wrapper for the popular chat & VOIP service: Discord https://discord.com
Stars: ✭ 2,598 (+1155.07%)
Mutual labels: api, bot
Magento Chatbot
Magento Chatbot Integration with Telegram, Messenger, Whatsapp, WeChat, Skype and wit.ai.
Stars: ✭ 149 (-28.02%)
Mutual labels: bot, wechat
Mojo Webqq
【重要通知:WebQQ将在2019年1月1日停止服务,此项目目前已停止维护,感谢大家四年来的一路陪伴】使用Perl语言(不会没关系)编写的smartqq/webqq客户端框架(非GUI),可通过插件提供基于HTTP协议的api接口供其他语言或系统调用
Stars: ✭ 1,755 (+747.83%)
Mutual labels: api, bot
Mellow
Mellow can communicate with several APIs like Ombi, Sonarr, Radarr and Tautulli which are related to home streaming to use those services directly in your Discord client.
Stars: ✭ 193 (-6.76%)
Mutual labels: api, bot
Aegis.cpp
Discord C++ library for interfacing with the API. Join our server:
Stars: ✭ 198 (-4.35%)
Mutual labels: api, bot
ChatApi-WeChat
Java版本微信聊天接口,使用网页微信API,让你能够开发自己的微信聊天机器人。
这是什么?
- 这是一个模拟的微信聊天客户端
- 该客户端使用的接口来自于网页版微信
有何优点?
- 对接口、流程、实体类进行了封装,更加简单易用
- 暴露了一个监听器,可以自己实现监听器以开发自己的业务功能
- 全部功能的支持
- 监听文字、图像、动图、语音、视频、文件、系统提示等消息
- 发送文字、图像、动图、文件等消息
- 撤回发送的消息
- 同意好友申请(网页微信发送好友申请功能已被关闭)
- 修改好友备注
- 置顶/取消置顶联系人
- 设置群名称
- (网页微信创建群、添加群成员、移除群成员功能均已被关闭)
测试数据
- 最后测试可用时间:2019-05-28
- 最长在线时间:7天
- 近期平均在线时间:2天
如何使用
- maven依赖
<dependency>
<groupId>me.xuxiaoxiao</groupId>
<artifactId>chatapi-wechat</artifactId>
<version>1.3.0</version>
</dependency>
- gradle依赖
implementation 'me.xuxiaoxiao:chatapi-wechat:1.3.0'
- jar包
- 以下是一个学别人说话的小机器人,用到了该库提供的大部分功能
public class WeChatDemo {
public static final Gson GSON = new GsonBuilder().disableHtmlEscaping().create();
/**
* 新建一个微信监听器
*/
public static final WeChatClient.WeChatListener LISTENER = new WeChatClient.WeChatListener() {
@Override
public void onQRCode(@Nonnull WeChatClient client, @Nonnull String qrCode) {
System.out.println("onQRCode:" + qrCode);
}
@Override
public void onLogin(@Nonnull WeChatClient client) {
System.out.println(String.format("onLogin:您有%d名好友、活跃微信群%d个", client.userFriends().size(), client.userGroups().size()));
}
@Override
public void onMessage(@Nonnull WeChatClient client, @Nonnull WXMessage message) {
System.out.println("获取到消息:" + GSON.toJson(message));
if (message instanceof WXVerify) {
//是好友请求消息,自动同意好友申请
client.passVerify((WXVerify) message);
} else if (message instanceof WXLocation && message.fromUser != null && !message.fromUser.id.equals(client.userMe().id)) {
// 如果对方告诉我他的位置,发送消息的不是自己,则我也告诉他我的位置
if (message.fromGroup != null) {
// 群消息
// client.sendLocation(message.fromGroup, "120.14556", "30.23856", "我在这里", "西湖");
} else {
// 用户消息
client.sendLocation(message.fromUser, "120.14556", "30.23856", "我在这里", "西湖");
}
} else if (message instanceof WXText && message.fromUser != null && !message.fromUser.id.equals(client.userMe().id)) {
//是文字消息,并且发送消息的人不是自己,发送相同内容的消息
if (message.fromGroup != null) {
// 群消息
// client.sendText(message.fromGroup, message.content);
} else {
// 用户消息
client.sendText(message.fromUser, message.content);
}
}
}
@Override
public void onContact(@Nonnull WeChatClient client, @Nullable WXContact oldContact, @Nullable WXContact newContact) {
System.out.println(String.format("检测到联系人变更:旧联系人名称:%s:新联系人名称:%s", (oldContact == null ? "null" : oldContact.name), (newContact == null ? "null" : newContact.name)));
}
};
public static void main(String[] args) {
//新建一个模拟微信客户端
WeChatClient wechatClient = new WeChatClient();
//为模拟微信客户端设置监听器
wechatClient.setListener(LISTENER);
//启动模拟微信客户端
wechatClient.startup();
Scanner scanner = new Scanner(System.in);
while (true) {
try {
System.out.println("请输入指令");
switch (scanner.nextLine()) {
case "sendText": {
System.out.println("toContactId:");
String toContactId = scanner.nextLine();
System.out.println("textContent:");
String text = scanner.nextLine();
WXContact contact = wechatClient.userContact(toContactId);
if (contact != null) {
System.out.println("success:" + GSON.toJson(wechatClient.sendText(contact, text)));
} else {
System.out.println("联系人未找到");
}
}
break;
case "sendFile": {
System.out.println("toContactId:");
String toContactId = scanner.nextLine();
System.out.println("filePath:");
File file = new File(scanner.nextLine());
WXContact contact = wechatClient.userContact(toContactId);
if (contact != null) {
System.out.println("success:" + GSON.toJson(wechatClient.sendFile(contact, file)));
} else {
System.out.println("联系人未找到");
}
}
break;
case "sendLocation": {
System.out.println("toContactId:");
String toContactId = scanner.nextLine();
System.out.println("longitude:");
String longitude = scanner.nextLine();
System.out.println("latitude:");
String latitude = scanner.nextLine();
System.out.println("title:");
String title = scanner.nextLine();
System.out.println("lable:");
String lable = scanner.nextLine();
WXContact contact = wechatClient.userContact(toContactId);
if (contact != null) {
System.out.println("success:" + GSON.toJson(wechatClient.sendLocation(contact, longitude, latitude, title, lable)));
} else {
System.out.println("联系人未找到");
}
}
break;
case "revokeMsg": {
System.out.println("toContactId:");
String toContactId = scanner.nextLine();
System.out.println("clientMsgId:");
String clientMsgId = scanner.nextLine();
System.out.println("serverMsgId:");
String serverMsgId = scanner.nextLine();
WXUnknown wxUnknown = new WXUnknown();
wxUnknown.id = Long.valueOf(serverMsgId);
wxUnknown.idLocal = Long.valueOf(clientMsgId);
wxUnknown.toContact = wechatClient.userContact(toContactId);
wechatClient.revokeMsg(wxUnknown);
}
break;
case "passVerify": {
System.out.println("userId:");
String userId = scanner.nextLine();
System.out.println("verifyTicket:");
String verifyTicket = scanner.nextLine();
WXVerify wxVerify = new WXVerify();
wxVerify.userId = userId;
wxVerify.ticket = verifyTicket;
wechatClient.passVerify(wxVerify);
}
break;
case "editRemark": {
System.out.println("userId:");
String userId = scanner.nextLine();
System.out.println("remarkName:");
String remark = scanner.nextLine();
WXContact contact = wechatClient.userContact(userId);
if (contact instanceof WXUser) {
wechatClient.editRemark((WXUser) contact, remark);
} else {
System.out.println("好友未找到");
}
}
break;
case "topContact": {
System.out.println("contactId:");
String contactId = scanner.nextLine();
System.out.println("isTop:");
String isTop = scanner.nextLine();
WXContact contact = wechatClient.userContact(contactId);
if (contact != null) {
wechatClient.topContact(contact, Boolean.valueOf(isTop.toLowerCase()));
} else {
System.out.println("联系人未找到");
}
}
break;
case "setGroupName": {
System.out.println("groupId:");
String groupId = scanner.nextLine();
System.out.println("name:");
String name = scanner.nextLine();
WXGroup group = wechatClient.userGroup(groupId);
if (group != null) {
wechatClient.setGroupName(group, name);
} else {
System.out.println("群组未找到");
}
}
break;
case "quit": {
System.out.println("logging out");
wechatClient.shutdown();
}
return;
default: {
System.out.println("未知指令");
}
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].