mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-07-04 06:17:26 +00:00
[Change] 更改部分组件所使用的的工具类;
This commit is contained in:
@ -5,11 +5,11 @@ import net.lamgc.cgj.bot.cache.exception.HttpRequestException;
|
||||
import net.lamgc.cgj.pixiv.PixivURL;
|
||||
import net.lamgc.cgj.util.URLs;
|
||||
import net.lamgc.utils.event.EventHandler;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.tomcat.util.http.fileupload.util.Streams;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -69,7 +69,7 @@ public class ImageCacheHandler implements EventHandler {
|
||||
log.debug("正在下载...(Content-Length: {}KB)", response.getEntity().getContentLength() / 1024);
|
||||
ByteArrayOutputStream bufferOutputStream = new ByteArrayOutputStream();
|
||||
try(FileOutputStream fileOutputStream = new FileOutputStream(storeFile)) {
|
||||
IOUtils.copy(response.getEntity().getContent(), bufferOutputStream);
|
||||
Streams.copy(response.getEntity().getContent(), bufferOutputStream, false);
|
||||
ByteArrayInputStream bufferInputStream = new ByteArrayInputStream(bufferOutputStream.toByteArray());
|
||||
CacheStoreCentral.ImageChecksum imageChecksum = CacheStoreCentral.ImageChecksum
|
||||
.buildImageChecksumFromStream(
|
||||
@ -79,7 +79,7 @@ public class ImageCacheHandler implements EventHandler {
|
||||
bufferInputStream
|
||||
);
|
||||
bufferInputStream.reset();
|
||||
IOUtils.copy(bufferInputStream, fileOutputStream);
|
||||
Streams.copy(bufferInputStream, fileOutputStream, false);
|
||||
CacheStoreCentral.setImageChecksum(imageChecksum);
|
||||
} catch (IOException e) {
|
||||
log.error("下载图片时发生异常", e);
|
||||
|
@ -17,11 +17,11 @@ import net.mamoe.mirai.message.MessageEvent;
|
||||
import net.mamoe.mirai.message.TempMessageEvent;
|
||||
import net.mamoe.mirai.utils.BotConfiguration;
|
||||
import net.mamoe.mirai.utils.Utils;
|
||||
import org.apache.commons.net.util.Base64;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Base64;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MiraiMain implements Closeable {
|
||||
@ -52,7 +52,8 @@ public class MiraiMain implements Closeable {
|
||||
Utils.setDefaultLogger(MiraiToSlf4jLoggerAdapter::new);
|
||||
BotConfiguration configuration = new BotConfiguration();
|
||||
configuration.setProtocol(BotConfiguration.MiraiProtocol.ANDROID_PAD);
|
||||
bot = BotFactoryJvm.newBot(Long.parseLong(botProperties.getProperty("bot.qq", "0")), Base64.decodeBase64(botProperties.getProperty("bot.password", "")), configuration);
|
||||
bot = BotFactoryJvm.newBot(Long.parseLong(botProperties.getProperty("bot.qq", "0")),
|
||||
Base64.getDecoder().decode(botProperties.getProperty("bot.password", "")), configuration);
|
||||
Events.subscribeAlways(GroupMessageEvent.class, this::executeMessageEvent);
|
||||
Events.subscribeAlways(FriendMessageEvent.class, this::executeMessageEvent);
|
||||
Events.subscribeAlways(TempMessageEvent.class, this::executeMessageEvent);
|
||||
|
Reference in New Issue
Block a user