diff --git a/gradle.properties b/gradle.properties index c5986dd..c50def2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ ## Core -VERSION = 0.5.0.4 +VERSION = 0.5.0.5 # dependencies diff --git a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java index 7686e07..08e9636 100644 --- a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java +++ b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java @@ -4,6 +4,6 @@ package cc.sukazyo.cono.morny; * the final field that will be updated by gradle automatically. */ public class GradleProjectConfigures { - public static final String VERSION = "0.5.0.4"; - public static final long COMPILE_TIMESTAMP = 1643885546609L; + public static final String VERSION = "0.5.0.5"; + public static final long COMPILE_TIMESTAMP = 1644309862037L; } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/command/Ip186Query.java b/src/main/java/cc/sukazyo/cono/morny/bot/command/Ip186Query.java index b66c6ae..7a47390 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/command/Ip186Query.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/command/Ip186Query.java @@ -63,7 +63,7 @@ public class Ip186Query { try { IP186QueryResponse response = switch (command.getCommand()) { case "/ip" -> IP186QueryHandler.queryIp(arg); - case "/whois" -> IP186QueryHandler.queryWhois(arg); + case "/whois" -> IP186QueryHandler.queryWhoisPretty(arg); default -> throw new IllegalArgumentException("Unknown 186-IP query method " + command.getCommand()); }; MornyCoeur.extra().exec(new SendMessage( diff --git a/src/main/java/cc/sukazyo/cono/morny/data/ip186/IP186QueryHandler.java b/src/main/java/cc/sukazyo/cono/morny/data/ip186/IP186QueryHandler.java index c29d0b9..0f60d81 100644 --- a/src/main/java/cc/sukazyo/cono/morny/data/ip186/IP186QueryHandler.java +++ b/src/main/java/cc/sukazyo/cono/morny/data/ip186/IP186QueryHandler.java @@ -62,6 +62,20 @@ public class IP186QueryHandler { return commonQuery(requestUrl, QUERY_WHOIS_PARAM); } + /** + * 将 {@link #queryWhois(String)} 的结果进行裁剪. + *
+ * 将会删除返回内容中 {@code >>> XXX <<<} 行以后的注释串, + * 以达到只保留重要信息的目的。 + * + * @see #queryWhois(String) + */ + @Nonnull + public static IP186QueryResponse queryWhoisPretty (String domain) throws IOException { + final IP186QueryResponse raw = queryWhois(domain); + return new IP186QueryResponse(raw.url(), raw.body().substring(0, raw.body().indexOf("<<<")+3)); + } + @Nonnull private static IP186QueryResponse commonQuery (String requestUrl, String queryIpParam) throws IOException { Request request = new Request.Builder().url(requestUrl + "?" + queryIpParam).build();