新作关键词

This commit is contained in:
2022-04-17 01:20:40 +08:00
parent f6c9748f48
commit 2558545ffe
2 changed files with 17 additions and 9 deletions

View File

@@ -5,10 +5,13 @@ import com.yutou.qqbot.QQBotManager;
import com.yutou.qqbot.interfaces.DownloadInterface;
import com.yutou.qqbot.models.Model;
import com.yutou.qqbot.utlis.HttpTools;
import com.yutou.qqbot.utlis.StringUtils;
import net.mamoe.mirai.event.events.MessageEvent;
import net.mamoe.mirai.message.data.MessageChainBuilder;
import java.io.File;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
public class GetSeTu extends Model {
@Override
@@ -29,8 +32,13 @@ public class GetSeTu extends Model {
@Override
public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
super.onMessage(qq, event, isGroup);
if ("来点色图".equals(msg) || "来点涩".equals(msg)) {
String ret = HttpTools.get("https://api.lolicon.app/setu/v2?r18=2");
if (msg.startsWith("来点")&&(msg.endsWith("")||msg.endsWith("涩图"))) {
String key=msg.replace("来点","").replace("色图","").replace("涩图","");
String url="https://api.lolicon.app/setu/v2?r18=2";
if(!StringUtils.isEmpty(key)){
url="https://api.lolicon.app/setu/v2?tag="+ URLEncoder.encode(key, StandardCharsets.UTF_8)+"&r18=2";
}
String ret = HttpTools.get(url);
JSONObject json = JSONObject.parseObject(ret);
HttpTools.download(json.getJSONArray("data").getJSONObject(0).getJSONObject("urls").getString("original"),
System.currentTimeMillis()+"_setu.jpg",