新增图片支持File
调整涩图模块为先自己下载,无法下载再丢url给qq机器人 移除部分日志
This commit is contained in:
@@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.napcat.QQDatabase;
|
||||
import com.yutou.napcat.handle.BaseHandle;
|
||||
import com.yutou.napcat.handle.MessageHandleBuild;
|
||||
import com.yutou.napcat.handle.Reply;
|
||||
import com.yutou.napcat.handle.Text;
|
||||
import com.yutou.napcat.http.NapCatApi;
|
||||
import com.yutou.napcat.model.FriendBean;
|
||||
@@ -127,6 +128,11 @@ public class QQBotManager {
|
||||
if (item.getData() == null) {
|
||||
continue;
|
||||
}
|
||||
if (item instanceof Reply) {
|
||||
if (((Reply) item).getData().getId() == -1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
handleBuild.add(item);
|
||||
}
|
||||
Response<HttpBody<SendMessageResponse>> response;
|
||||
|
||||
@@ -219,14 +219,36 @@ public class GetSeTu extends Model {
|
||||
builder.append(tags).append("、");
|
||||
}
|
||||
builder.append("\n看不到图?点这里:").append(item.getJSONObject("urls").getString("regular"));
|
||||
QQBotManager.getInstance().sendMessage(false, qq,
|
||||
new Image(item.getJSONObject("urls").getString("regular")),
|
||||
new Reply(event.getMessageId())
|
||||
);
|
||||
QQBotManager.getInstance().sendMessage(false, qq,
|
||||
new Reply(event.getMessageId()),
|
||||
new Text(builder.toString())
|
||||
);
|
||||
HttpTools.download(item.getJSONObject("urls").getString("regular"),
|
||||
System.currentTimeMillis() + ".png",
|
||||
true,
|
||||
new DownloadInterface() {
|
||||
@Override
|
||||
public void onDownload(File file) {
|
||||
super.onDownload(file);
|
||||
Log.i("下载完成");
|
||||
QQBotManager.getInstance().sendMessage(false, qq,
|
||||
new Image(file),
|
||||
new Reply(event.getMessageId())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
super.onError(e);
|
||||
QQBotManager.getInstance().sendMessage(false, qq,
|
||||
new Image(item.getJSONObject("urls").getString("regular")),
|
||||
new Reply(event.getMessageId())
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -236,9 +258,12 @@ public class GetSeTu extends Model {
|
||||
Matcher matcher = pattern.matcher(msg);
|
||||
MessageEvent event = new MessageEvent();
|
||||
SourceFrom sourceFrom = new SourceFrom();
|
||||
sourceFrom.setUserId(583819556L);
|
||||
sourceFrom.setUserId(891655174L);
|
||||
event.setMessageType("private");
|
||||
event.setSource(sourceFrom);
|
||||
event.setGroupId(891655174L);
|
||||
event.setMessageId(-1);
|
||||
event.setRawMessage(msg);
|
||||
new GetSeTu().onMessage(583819556L, event, false);
|
||||
new GetSeTu().onMessage(891655174L, event, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,5 @@ public class Base64Tools {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
File file=new File("遥遥领先.mp3");
|
||||
|
||||
String base64 = encode(file);
|
||||
System.out.println(base64);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user