|
| 1 | +package me.regadpole.plumbot.listener |
| 2 | + |
| 3 | +import me.regadpole.plumbot.PlumBot |
| 4 | +import me.regadpole.plumbot.internal.WhitelistHelper |
| 5 | +import taboolib.common5.util.replace |
| 6 | + |
| 7 | +object GPlatformListener { |
| 8 | + fun onGroupMessage(message: String, groupId: String, senderId: String, senderName: String) { |
| 9 | + if (!PlumBot.getConfig().getConfig().groups.enableGroups.contains(groupId)) return |
| 10 | + if (message.startsWith(PlumBot.getConfig().getConfig().groups.prefix ?: "/")) { |
| 11 | + if (PlumBot.getConfig().getConfig().groups.forwarding.sdc) { |
| 12 | + PlumBot.getConfig().getCommands().adminCommand.forEach { |
| 13 | + if (it.key == message.substring(1) && PlumBot.getConfig().getConfig().groups.botAdmins. |
| 14 | + contains(senderId)) { |
| 15 | + // TODO: 执行配置文件内游戏命令并返回 |
| 16 | + } |
| 17 | + } |
| 18 | + PlumBot.getConfig().getCommands().userCommand.forEach { |
| 19 | + if (it.key == message.substring(1)) { |
| 20 | + // TODO: 执行配置文件内游戏命令并返回 |
| 21 | + } |
| 22 | + } |
| 23 | + } |
| 24 | + if (message.substring(1) == "help" || message.substring(1) == "帮助") { |
| 25 | + |
| 26 | + } |
| 27 | + if (PlumBot.getConfig().getConfig().groups.forwarding.tps && message.substring(1) == "tps") { |
| 28 | + // TODO: 获取服务器 TPS 并返回 |
| 29 | + } |
| 30 | + if (PlumBot.getConfig().getConfig().groups.forwarding.online && message.substring(1) == "在线人数") { |
| 31 | + // TODO: 看看这样写有没有问题(( |
| 32 | + PlumBot.getBot().sendGroupMsg(groupId, "在线玩家: ${PlumBot.playerList.joinToString(", ")}") |
| 33 | + } |
| 34 | + if (PlumBot.getConfig().getConfig().groups.botAdmins.contains(groupId) && message.substring(1) == "cmd") { |
| 35 | + // TODO: 执行message内游戏命令并返回 |
| 36 | + } |
| 37 | + if (PlumBot.getConfig().getConfig().groups.forwarding.whitelist.enable && message.substring(1) == "申请白名单" && |
| 38 | + message.split(" ").size == 2) { |
| 39 | + val player = message.substring(6) |
| 40 | + if (!WhitelistHelper.checkCount(senderId)) { |
| 41 | + PlumBot.getBot().sendGroupMsg( |
| 42 | + groupId, PlumBot.getLangConfig().getLangConf().whitelist.user.fullBind!! |
| 43 | + .replace("%player_name%", player) |
| 44 | + .replace("%whitelist_name%", PlumBot.getDatabase().getBind(senderId).values.joinToString(", ")) |
| 45 | + .replace("%platform_id%", senderId) |
| 46 | + .replace("%max_limit%", PlumBot.getConfig().getConfig().groups.forwarding.whitelist.maxCount.toString())) |
| 47 | + } |
| 48 | + if (!WhitelistHelper.checkIDNotExist(player)) { |
| 49 | + PlumBot.getBot().sendGroupMsg( |
| 50 | + groupId, PlumBot.getLangConfig().getLangConf().whitelist.user.existsBind!! |
| 51 | + .replace("%player_name%", player)) |
| 52 | + } |
| 53 | + WhitelistHelper.addAndGet(senderId, player) |
| 54 | + PlumBot.getBot().sendGroupMsg( |
| 55 | + groupId, PlumBot.getLangConfig().getLangConf().whitelist.user.addBind!! |
| 56 | + .replace("%player_name%", player) |
| 57 | + .replace("%whitelist_name%", PlumBot.getDatabase().getBind(senderId).values.joinToString(", ")) |
| 58 | + .replace("%platform_id%", senderId)) |
| 59 | + } |
| 60 | + if (PlumBot.getConfig().getConfig().groups.forwarding.whitelist.enable && message.substring(1) == "移除白名单" && |
| 61 | + message.split(" ").size == 2) { |
| 62 | + val player = message.substring(6) |
| 63 | + if (WhitelistHelper.checkIDNotExist(player)) { |
| 64 | + PlumBot.getBot().sendGroupMsg( |
| 65 | + groupId, PlumBot.getLangConfig().getLangConf().whitelist.user.notExistsBind!! |
| 66 | + .replace("%player_name%", player)) |
| 67 | + } |
| 68 | + if (!WhitelistHelper.checkIDBelong(senderId, player)) { |
| 69 | + PlumBot.getBot().sendGroupMsg( |
| 70 | + groupId, PlumBot.getLangConfig().getLangConf().whitelist.user.notBelongToYou!! |
| 71 | + .replace("%player_name%", player)) |
| 72 | + } |
| 73 | + PlumBot.getDatabase().removeBindByName(player) |
| 74 | + PlumBot.getBot().sendGroupMsg( |
| 75 | + groupId, PlumBot.getLangConfig().getLangConf().whitelist.user.addBind!! |
| 76 | + .replace("%player_name%", player) |
| 77 | + .replace("%whitelist_name%", PlumBot.getDatabase().getBind(senderId).values.joinToString(", ")) |
| 78 | + .replace("%platform_id%", senderId)) |
| 79 | + } |
| 80 | + if (PlumBot.getConfig().getConfig().groups.forwarding.whitelist.enable && message.substring(1) == "查询白名单") { |
| 81 | + PlumBot.getBot().sendGroupMsg( |
| 82 | + groupId, PlumBot.getLangConfig().getLangConf().whitelist.user.queryBind!! |
| 83 | + .replace("%whitelist_name%", PlumBot.getDatabase().getBind(senderId).values.joinToString(", "))) |
| 84 | + } |
| 85 | + } |
| 86 | + if (PlumBot.getConfig().getConfig().groups.forwarding.sdr) { |
| 87 | + PlumBot.getConfig().getReturns().adminReturn.forEach { |
| 88 | + if (it.key == message && PlumBot.getConfig().getConfig().groups.botAdmins.contains(senderId)) { |
| 89 | + PlumBot.getBot().sendGroupMsg(groupId, it.value) |
| 90 | + } |
| 91 | + } |
| 92 | + PlumBot.getConfig().getReturns().userReturn.forEach { |
| 93 | + if (it.key == message) { |
| 94 | + PlumBot.getBot().sendGroupMsg(groupId, it.value) |
| 95 | + } |
| 96 | + } |
| 97 | + } |
| 98 | + if (PlumBot.getConfig().getConfig().groups.forwarding.message.mode == 0) { |
| 99 | + PlumBot.getBot().sendGroupMsg( |
| 100 | + groupId, PlumBot.getLangConfig().getLangConf().forwarding.toServer!! |
| 101 | + .replace("%group_name%", PlumBot.getBot().getGroupName(groupId)?: groupId) |
| 102 | + .replace("%message%", message) |
| 103 | + .replace("%platform_name%", senderName)) |
| 104 | + } else if (PlumBot.getConfig().getConfig().groups.forwarding.message.mode == 1 && |
| 105 | + message.startsWith(PlumBot.getConfig().getConfig().groups.forwarding.message.prefix!!)) { |
| 106 | + PlumBot.getBot().sendGroupMsg( |
| 107 | + groupId, PlumBot.getLangConfig().getLangConf().forwarding.toServer!! |
| 108 | + .replace("%group_name%", PlumBot.getBot().getGroupName(groupId)?: groupId) |
| 109 | + .replace("%message%", message.replace(PlumBot.getConfig().getConfig().groups.forwarding.message.prefix!!, "")) |
| 110 | + .replace("%platform_name%", senderName)) |
| 111 | + } |
| 112 | + } |
| 113 | +} |
0 commit comments