2
0
mirror of https://gitee.com/hotlcc/wechat4j.git synced 2025-06-27 20:52:45 +08:00
Merge pull request !4 from Allen/feature/20180914
This commit is contained in:
Allen 2018-09-14 10:54:08 +08:00
commit 5995be80ba
2 changed files with 34 additions and 1 deletions

View File

@ -6,7 +6,7 @@
<groupId>com.hotlcc</groupId>
<artifactId>wechat4j</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
<name>wechat4j</name>
<description>Wechat client for Java.</description>

View File

@ -1178,6 +1178,39 @@ public class Wechat {
return sendText(content, userName);
}
/**
* 发送文本消息根据多种名称
*
* @param content
* @param userName
* @param nickName
* @param remarkName
* @return
*/
public JSONObject sendText(String content, String userName, String nickName, String remarkName) {
UserInfo userInfo = null;
if (StringUtil.isNotEmpty(userName)) {
return sendText(content, userName);
} else if (StringUtil.isNotEmpty(nickName)) {
userInfo = getContactByNickName(false, nickName);
} else if (StringUtil.isNotEmpty(remarkName)) {
userInfo = getContactByRemarkName(false, remarkName);
} else {
String loginUserName = getLoginUserName(false);
return sendText(content, loginUserName);
}
if (userInfo == null) {
return null;
}
userName = userInfo.getUserName();
if (StringUtil.isEmpty(userName)) {
return null;
}
return sendText(content, userName);
}
//TODO 待完成
@Deprecated
public JSONObject sendImage(File image, String userName) {