diff --git a/bungee/src/main/resources/messages.properties b/bungee/src/main/resources/messages.properties index 8a0236f..5dcd2f9 100644 --- a/bungee/src/main/resources/messages.properties +++ b/bungee/src/main/resources/messages.properties @@ -6,8 +6,9 @@ commandHelp=&7&o/phenyl help&3 - Show help message. commandHelpPlayer=&7&o/phenyl bind &7[YOUR_QQ_ID]&3 - Request to bind your Minecraft id to QQ account.\n\ &7&o/phenyl verify &7[VERIFICATION_CODE]&3 - Verify the binding request from QQ.\n\ &7&o/phenyl say &7[MESSAGE]&3 - Send message to QQ if Phenyl is on command mode.\n\ - &7&o/phenyl nomessage &3 - Whether to stop message forwarding to your client. -commandHelpAdmin=&7&o/phenyl mute &7[MINECRAFT_ID]&3 - Mute someone so that their messages will not be forwarded to QQ.\n\ + &7&o/phenyl nomessage &3 - Whether to stop message forwarding to your client.\n\ + &7&o/phenyl at &7[USERNAME]&3 - @ the specified player in QQ group. +commandHelpAdmin=&7&o/phenyl mute &7[USERNAME]&3 - Mute someone so that their messages will not be forwarded to QQ.\n\ &7&o/phenyl slider &7[ticket]&3 - Submit ticket for slider captcha.\n\ &7&o/phenyl reload&3 - Reload Phenyl.\n\ &7&o/phenyl login&3 - Login to QQ.\n\ @@ -47,6 +48,7 @@ invalidQQID=&4Invalid QQ ID. notBoundYet=You haven't bound your username boundPlayerNotFound=Player record not found atSent=&3Successfully sent &7&o@{1} &3in &7&o{0} +playerNotFoundInGroup=&4Player &7&o@{1} &4not found in &7&o{0}&3 completeBindInGame=Perform following command in game to confirm completeBindInGroup=&3Send following command in QQ group to confirm clickToCopy=Click to copy diff --git a/bungee/src/main/resources/messages_en.properties b/bungee/src/main/resources/messages_en.properties index 8a0236f..5dcd2f9 100644 --- a/bungee/src/main/resources/messages_en.properties +++ b/bungee/src/main/resources/messages_en.properties @@ -6,8 +6,9 @@ commandHelp=&7&o/phenyl help&3 - Show help message. commandHelpPlayer=&7&o/phenyl bind &7[YOUR_QQ_ID]&3 - Request to bind your Minecraft id to QQ account.\n\ &7&o/phenyl verify &7[VERIFICATION_CODE]&3 - Verify the binding request from QQ.\n\ &7&o/phenyl say &7[MESSAGE]&3 - Send message to QQ if Phenyl is on command mode.\n\ - &7&o/phenyl nomessage &3 - Whether to stop message forwarding to your client. -commandHelpAdmin=&7&o/phenyl mute &7[MINECRAFT_ID]&3 - Mute someone so that their messages will not be forwarded to QQ.\n\ + &7&o/phenyl nomessage &3 - Whether to stop message forwarding to your client.\n\ + &7&o/phenyl at &7[USERNAME]&3 - @ the specified player in QQ group. +commandHelpAdmin=&7&o/phenyl mute &7[USERNAME]&3 - Mute someone so that their messages will not be forwarded to QQ.\n\ &7&o/phenyl slider &7[ticket]&3 - Submit ticket for slider captcha.\n\ &7&o/phenyl reload&3 - Reload Phenyl.\n\ &7&o/phenyl login&3 - Login to QQ.\n\ @@ -47,6 +48,7 @@ invalidQQID=&4Invalid QQ ID. notBoundYet=You haven't bound your username boundPlayerNotFound=Player record not found atSent=&3Successfully sent &7&o@{1} &3in &7&o{0} +playerNotFoundInGroup=&4Player &7&o@{1} &4not found in &7&o{0}&3 completeBindInGame=Perform following command in game to confirm completeBindInGroup=&3Send following command in QQ group to confirm clickToCopy=Click to copy diff --git a/bungee/src/main/resources/messages_zh_CN.properties b/bungee/src/main/resources/messages_zh_CN.properties index 3493c9e..ddb5444 100644 --- a/bungee/src/main/resources/messages_zh_CN.properties +++ b/bungee/src/main/resources/messages_zh_CN.properties @@ -6,8 +6,9 @@ commandHelp=&7&o/phenyl help&3 - 显示帮助信息。 commandHelpPlayer=&7&o/phenyl bind &7&3 - 进行QQ绑定。\n\ &7&o/phenyl verify &7<验证码>&3 - 对从QQ发起的绑定请求进行验证。\n\ &7&o/phenyl say &7<消息>&3 - 如果Phenyl处于Command模式,你需要使用此指令来将消息发送到QQ。\n\ - &7&o/phenyl nomessage &3 - 是否启用消息转发。 -commandHelpAdmin=&7&o/phenyl mute &7&3 - 禁言某人,则他的游戏内消息不会被转发到QQ。\n\ + &7&o/phenyl nomessage &3 - 是否启用消息转发。\n\ + &7&o/phenyl at &7<用户名>&3 - 在QQ群中@指定的玩家。 +commandHelpAdmin=&7&o/phenyl mute &7<用户名>&3 - 禁言某人,则他的游戏内消息不会被转发到QQ。\n\ &7&o/phenyl slider &7&3 - 提交滑动验证Ticket。\n\ &7&o/phenyl reload&3 - 重新加载Phenyl。\n\ &7&o/phenyl login&3 - 登录QQ账号。\n\ @@ -47,6 +48,7 @@ invalidQQID=&4QQ号无效 notBoundYet=您尚未绑定 boundPlayerNotFound=未查询到玩家绑定信息 atSent=&3已在&7&o{0}&3中&7&o@{1} +playerNotFoundInGroup=&4群&7&o{0}&4中不存在玩家&7&o@{1} completeBindInGame=请在游戏内输入以下指令完成绑定 completeBindInGroup=&3请在QQ群输入以下指令完成绑定 clickToCopy=点击复制 diff --git a/common/src/main/java/live/turna/phenyl/common/command/ServerCommandExecutor.java b/common/src/main/java/live/turna/phenyl/common/command/ServerCommandExecutor.java index 57dd767..1b268ce 100644 --- a/common/src/main/java/live/turna/phenyl/common/command/ServerCommandExecutor.java +++ b/common/src/main/java/live/turna/phenyl/common/command/ServerCommandExecutor.java @@ -254,14 +254,22 @@ private void at() throws IllegalArgumentException { if (playerList.stream().noneMatch(player -> player.mcname().equals(args[1]))) throw new IllegalArgumentException(i18n("boundPlayerNotFound")); Player targetPlayer = playerList.stream().filter(player -> player.mcname().equals(args[1])).findFirst().get(); + String formatText = Config.server_to_qq_format.equals("image") ? "%username%:%message%" : Config.server_to_qq_format; // get the pattern before and after %message% - String[] format = Config.server_to_qq_format + String[] format = formatText .replace("%sub_server%", new MessageUtils(phenyl).getServerName(sender.getServerName())) .replace("%username%", sender.getUsername()) .split("%message%"); for (Long id : Config.enabled_groups) { + Group group; + try { + group = phenyl.getMirai().getBot().getGroupOrFail(id); + } catch (NoSuchElementException e) { + LOGGER.error(i18n("noSuchGroup", String.valueOf(id))); + if (Config.debug) e.printStackTrace(); + continue; + } try { - Group group = phenyl.getMirai().getBot().getGroupOrFail(id); Member target = group.getOrFail(targetPlayer.qqid()); MessageChain message = new MessageChainBuilder() .append(format[0]) @@ -270,7 +278,8 @@ private void at() throws IllegalArgumentException { .build(); phenyl.getMessenger().sendGroup(group, message); phenyl.getMessenger().sendPlayer(i18n("atSent", group.getName(), target.getNameCard().isEmpty() ? target.getNick() : target.getNameCard()), sender); - } catch (NoSuchElementException ignored) { + } catch (NoSuchElementException e) { + phenyl.getMessenger().sendPlayer(i18n("playerNotFoundInGroup", group.getName(), targetPlayer.mcname()), sender); } } }