wechat api
0.0.3
wechat-api is the Java version API of WeChat personal accounts, which allows personal accounts to have more capabilities and provides convenient interface calls.
Online documentation
For local development students, please install the lombok plug-in first and make sure your JDK environment is 1.7+
Introduce maven
dependencies
< dependency >
< groupId >io.github.biezhi</ groupId >
< artifactId >wechat-api</ artifactId >
< version >1.0.6</ version >
</ dependency >
Build your own little robot
public class HelloBot extends WeChatBot {
public HelloBot ( Config config ) {
super ( config );
}
@ Bind ( msgType = MsgType . TEXT )
public void handleText ( WeChatMessage message ) {
if ( StringUtils . isNotEmpty ( message . getName ())) {
log . info ( "接收到 [{}] 的消息: {}" , message . getName (), message . getText ());
this . sendMsg ( message . getFromUserName (), "自动回复: " + message . getText ());
}
}
public static void main ( String [] args ) {
new HelloBot ( Config . me (). autoLogin ( true ). showTerminal ( true )). start ();
}
}
/**
* 给文件助手发送消息
*
* @param msg 消息内容
* @return 发送是否成功
*/
boolean sendMsgToFileHelper ( String msg );
/**
* 给某个用户发送消息
*
* @param name 用户UserName
* @param msg 消息内容
* @return 发送是否成功
*/
boolean sendMsg ( String name , String msg );
/**
* 根据名称发送消息
*
* @param name 备注或昵称,精确匹配
* @param msg 消息内容
* @return 发送是否成功
*/
boolean sendMsgByName ( String name , String msg );
/**
* 给某个用户发送图片消息
*
* @param name 用户UserName
* @param imgPath 图片路径
* @return 发送是否成功
*/
boolean sendImg ( String name , String imgPath );
/**
* 根据名称发送图片消息
*
* @param name 备注或昵称,精确匹配
* @param imgPath 图片路径
* @return 发送是否成功
*/
boolean sendImgName ( String name , String imgPath );
/**
* 给用户发送文件
*
* @param name 用户UserName
* @param filePath 文件路径
* @return 发送是否成功
*/
boolean sendFile ( String name , String filePath );
/**
* 根据名称发送文件消息
*
* @param name 备注或昵称,精确匹配
* @param filePath 文件路径
* @return 发送是否成功
*/
boolean sendFileName ( String name , String filePath );
See the documentation for more APIs
MIT