修改部分QQ发送消息的代码

This commit is contained in:
2022-01-16 12:51:26 +08:00
parent 11534b04f7
commit 6d9ba12cf1
7 changed files with 48 additions and 312 deletions

View File

@@ -15,7 +15,10 @@ import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
public class BTDownloadManager implements ApplicationContextAware {
@@ -97,8 +100,7 @@ public class BTDownloadManager implements ApplicationContextAware {
array.add(item.getString("title"));
RedisTools.set(bangumiItem.getTitle(), array.toJSONString());
if (item.containsKey("thumbnail")) {
File file = HttpTools.syncDownload(item.getString("thumbnail"), bangumiItem.getTitle() + ".jpg");
onSend(file, item);
onSend(item.getString("thumbnail"), item);
} else {
onSend(null, item);
}
@@ -114,13 +116,13 @@ public class BTDownloadManager implements ApplicationContextAware {
}
}
private void onSend(File file, JSONObject item) {
private void onSend(String fileUrl, JSONObject item) {
String text = "启动下载器\n已提交到下载:" + item.getString("title");
Log.i(text);
if (file == null) {
if (fileUrl == null) {
QQBotManager.getInstance().sendMessage(text);
} else {
QQBotManager.getInstance().sendMessage(file, text);
QQBotManager.getInstance().sendMessage(fileUrl, text);
}
}
@@ -163,15 +165,7 @@ public class BTDownloadManager implements ApplicationContextAware {
}
public static void main(String[] args) {
AnimationData data = new AnimationData();
BangumiItem item = new BangumiItem();
item.setAuthor(data.nameToValue("lleeopen", true) + "");
item.setCategories(data.nameToValue("動畫", false) + "");
item.setTitle("無職轉生~到了異世界就拿出真本事~");
item.setTitlekey("无职转生");
String url = new BTDownloadManager().getRSSUrl(item);
com.yutou.nas.utils.Log.i(url);
}
@Override