mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-22 11:14:55 +08:00
优化使 ip.186/whois 查询的返回值删除数据之后的注释行
This commit is contained in:
parent
ec83d1f3bc
commit
7ad7913a3c
@ -1,6 +1,6 @@
|
||||
## Core
|
||||
|
||||
VERSION = 0.5.0.4
|
||||
VERSION = 0.5.0.5
|
||||
|
||||
# dependencies
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -62,6 +62,20 @@ public class IP186QueryHandler {
|
||||
return commonQuery(requestUrl, QUERY_WHOIS_PARAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 {@link #queryWhois(String)} 的结果进行裁剪.
|
||||
* <br>
|
||||
* 将会删除返回内容中 {@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();
|
||||
|
Loading…
Reference in New Issue
Block a user