Skip to content

Commit 74f9afb

Browse files
committed
优化: 语录插件支持自定义文本内容
Signed-off-by: hd <hdshare@vip.qq.com>
1 parent 0b8b803 commit 74f9afb

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

plugins/hd/msg-q/msg-q.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,20 @@ void onHandleMsg(Object msgInfoBean) {
7272
if (msgInfoBean.isSend() && msgInfoBean.isQuote()) {
7373
String talker = msgInfoBean.getTalker();
7474
String title = msgInfoBean.getQuoteMsg().getTitle();
75-
if (title.contains("/q")) {
75+
if (title.startsWith("/q")) {
7676
String quoteMsgSendTalker = msgInfoBean.getQuoteMsg().getSendTalker();
7777
String quoteMsgAvatarUrl = getAvatarUrl(quoteMsgSendTalker);
7878
String quoteMsgDisplayName = msgInfoBean.getQuoteMsg().getDisplayName();
79-
String quoteMsgType = msgInfoBean.getQuoteMsg().getType();
80-
String quoteMsgContent = quoteMsgType.equals("1") ? msgInfoBean.getQuoteMsg().getContent() : "暂不支持的引用类型";
79+
80+
String[] parts = title.split(" ", 2);
81+
String quoteMsgContent;
82+
if (parts.length > 1) {
83+
quoteMsgContent = parts[1];
84+
} else {
85+
String quoteMsgType = msgInfoBean.getQuoteMsg().getType();
86+
quoteMsgContent = quoteMsgType.equals("1") ? msgInfoBean.getQuoteMsg().getContent() : "暂不支持的引用类型";
87+
}
88+
8189
if (!quoteMsgAvatarUrl.equals("")) {
8290
String avatarTmpPath = pluginDir + "/avatar.png";
8391
String messageTmpPath = pluginDir + "/message.png";
@@ -88,7 +96,7 @@ public void onSuccess(File file) {
8896
new File(avatarTmpPath).delete();
8997
new File(messageTmpPath).delete();
9098
}
91-
99+
92100
public void onError(Exception e) {
93101
sendText(talker, "下载头像异常:" + e.getMessage());
94102
}

0 commit comments

Comments
 (0)