Skip to content

Commit

Permalink
feat: support audio
Browse files Browse the repository at this point in the history
  • Loading branch information
xslingcn committed May 10, 2022
1 parent 3817323 commit d22a198
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions bungee/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ invalidGroupID=Invalid QQ group number
invalidQQIDSetting=Invalid QQ ID
noSuchGroup=Group not found:{0}
clickToView=Click to view:
quoteReply=(Reply @{0}:{1}):
receiveMessage=&3Started to receive forwarding message
noMessage=&3Stopped receiving forwarding message
mutedPlayer=&3Muted {0}
Expand Down
1 change: 1 addition & 0 deletions bungee/src/main/resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ invalidGroupID=Invalid QQ group number
invalidQQIDSetting=Invalid QQ ID
noSuchGroup=Group not found:{0}
clickToView=Click to view:
quoteReply=(Reply @{0}:{1}):
receiveMessage=&3Started to receive forwarding message
noMessage=&3Stopped receiving forwarding message
mutedPlayer=&3Muted {0}
Expand Down
1 change: 1 addition & 0 deletions bungee/src/main/resources/messages_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ invalidGroupID=群号无效
invalidQQIDSetting=QQ号无效
noSuchGroup=目标群聊不存在:{0}
clickToView=点击查看:
quoteReply=(回复 @{0}:{1}):
receiveMessage=&3您已开始接收群消息
noMessage=&3您已停止接收群消息
mutedPlayer=&3已禁言{0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@ public Component get() {
return groupCardFallback();
}

if (message.size() == 2 && message.get(1) instanceof OnlineAudio audio)
return groupAudio(audio);

if (message.size() == 2 && message.get(1) instanceof FlashImage flashImage)
return groupFlashImage(flashImage);

// match messages with images
if (images != null && !images.isEmpty()) {
return groupImage();
}

// match links
Component linkFormat = groupLink();
if (linkFormat != null) return linkFormat;
Expand Down Expand Up @@ -182,6 +186,19 @@ Component groupMusicShare(MusicShare music) {
: ""));
}

Component groupAudio(OnlineAudio audio) {
String url = audio.getUrlForDownload();
return Component.text(altColor(format[0]))
.append(Component.text("[", NamedTextColor.GRAY))
.append(Component.text(messageString.substring(1, messageString.length() - 1), NamedTextColor.DARK_AQUA)
.clickEvent(ClickEvent.openUrl(url))
.hoverEvent(HoverEvent.showText(Component.text(i18n("clickToView") + url, NamedTextColor.YELLOW))))
.append(Component.text("]", NamedTextColor.GRAY))
.append(Component.text(format.length > 1
? altColor(color + format[1])
: ""));
}

Component groupImage() {
int matchCount = 0;
String pattern = "\\u56fe\\u7247|\\u52a8\\u753b\\u8868\\u60c5";
Expand Down

0 comments on commit d22a198

Please # to comment.