update
This commit is contained in:
parent
ed692199be
commit
3bce5d7fd9
@ -104,10 +104,12 @@ public class BangumiTools {
|
||||
* @param id 番剧id
|
||||
* @return 详细内容
|
||||
*/
|
||||
public static String reportBangumiInfo(int id) {
|
||||
public static List<String> reportBangumiInfo(int id) {
|
||||
List<String> bangumiList=new ArrayList<>();
|
||||
JSONObject json = getBangumiInfo(id);
|
||||
if(json.containsKey("code")){
|
||||
return json.getString("error");
|
||||
bangumiList.add("error = "+json.toJSONString());
|
||||
return bangumiList;
|
||||
}
|
||||
JSONArray eps = json.getJSONArray("eps");
|
||||
JSONArray crts = json.getJSONArray("crt");
|
||||
@ -181,7 +183,8 @@ public class BangumiTools {
|
||||
builder.append("\n");
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
bangumiList.add(builder.toString());
|
||||
return bangumiList;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -275,7 +278,8 @@ public class BangumiTools {
|
||||
* @param key 关键词
|
||||
* @return 详细内容
|
||||
*/
|
||||
public static String reportSearchBangumi(String key) {
|
||||
public static List<String> reportSearchBangumi(String key) {
|
||||
List<String> bangumiList=new ArrayList<>();
|
||||
JSONObject main = search(key);
|
||||
if (main.getInteger("results") > 0) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@ -283,6 +287,7 @@ public class BangumiTools {
|
||||
Collections.reverse(list);
|
||||
for (Object items : list) {
|
||||
JSONObject item = (JSONObject) items;
|
||||
builder=new StringBuilder();
|
||||
builder.append("标题:").append(item.getString("name_cn")).append("\n");
|
||||
builder.append("日文标题:").append(item.getString("name")).append("\n");
|
||||
String type;
|
||||
@ -315,10 +320,12 @@ public class BangumiTools {
|
||||
builder.append("Bangumi地址:").append(item.getString("url")).append("\n");
|
||||
builder.append("介绍:").append(item.getString("summary")).append("\n");
|
||||
builder.append("\n").append("\n");
|
||||
bangumiList.add(builder.toString());
|
||||
}
|
||||
return builder.toString();
|
||||
return bangumiList;
|
||||
} else {
|
||||
return "搜索不到任何内容:" + key;
|
||||
bangumiList.add("搜索不到任何内容:" + key);
|
||||
return bangumiList;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -272,22 +272,25 @@ public class QQBotManager {
|
||||
if (msg.startsWith(QQCommands.QQ_CMD)) {
|
||||
RedisTools.Consumer.system("cmd", msg.replace(QQCommands.QQ_CMD, ""));
|
||||
} else if (msg.startsWith(QQCommands.QQ_BANGUMI_SUB)) {
|
||||
String info = null;
|
||||
List<String> infos = null;
|
||||
try {
|
||||
int id = Integer.parseInt(msg.replace(QQCommands.QQ_BANGUMI_SUB, "").trim());
|
||||
info = BangumiTools.reportBangumiInfo(id);
|
||||
infos = BangumiTools.reportBangumiInfo(id);
|
||||
} catch (Exception e) {
|
||||
String key = msg.replace(QQCommands.QQ_BANGUMI_SUB, "").trim();
|
||||
info = BangumiTools.reportSearchBangumi(key);
|
||||
infos = BangumiTools.reportSearchBangumi(key);
|
||||
}
|
||||
List<String> imgs = new ArrayList<>();
|
||||
if (info.contains("<img") && info.contains(" /img>")) {
|
||||
imgs = getImages(info);
|
||||
for (String img : imgs) {
|
||||
info = info.replace("<img " + img + " /img>", "");
|
||||
for (String info : infos) {
|
||||
List<String> imgs = new ArrayList<>();
|
||||
if (info.contains("<img") && info.contains(" /img>")) {
|
||||
imgs = getImages(info);
|
||||
for (String img : imgs) {
|
||||
info = info.replace("<img " + img + " /img>", "");
|
||||
}
|
||||
}
|
||||
sendImagesMsg(imgs, info);
|
||||
}
|
||||
sendImagesMsg(imgs, info);
|
||||
|
||||
} else if (msg.startsWith(QQCommands.QQ_AUDIO)) {
|
||||
QQAudio.playText(msg.replace(QQCommands.QQ_AUDIO, ""));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user