涩图模块:匹配正则
This commit is contained in:
parent
ccdca908cf
commit
1b593106ab
@ -13,6 +13,8 @@ import net.mamoe.mirai.message.data.MessageChainBuilder;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class GetSeTu extends Model {
|
public class GetSeTu extends Model {
|
||||||
@Override
|
@Override
|
||||||
@ -40,10 +42,16 @@ public class GetSeTu extends Model {
|
|||||||
} else if (msg.contains("来点") && msg.contains("涩图")) {
|
} else if (msg.contains("来点") && msg.contains("涩图")) {
|
||||||
isRun = true;
|
isRun = true;
|
||||||
isR18 = true;
|
isR18 = true;
|
||||||
|
msg = msg.replace("涩图", "色图");
|
||||||
}
|
}
|
||||||
if (isRun) {
|
if (isRun) {
|
||||||
Log.i(event.getSource().getFromId() + " > " + msg);
|
Log.i(event.getSource().getFromId() + " > " + msg);
|
||||||
String key = msg.replace("来点", "").replace("色图", "").replace("涩图", "");
|
Pattern pattern = Pattern.compile("来点(.*?)色图");
|
||||||
|
Matcher matcher=pattern.matcher(msg);
|
||||||
|
String key=null;
|
||||||
|
if(matcher.find()){
|
||||||
|
key=matcher.group(1);
|
||||||
|
}
|
||||||
String url = "https://api.lolicon.app/setu/v2?r18=0&size=regular";
|
String url = "https://api.lolicon.app/setu/v2?r18=0&size=regular";
|
||||||
if (isR18) {
|
if (isR18) {
|
||||||
url = "https://api.lolicon.app/setu/v2?r18=1&size=regular";
|
url = "https://api.lolicon.app/setu/v2?r18=1&size=regular";
|
||||||
@ -96,21 +104,6 @@ public class GetSeTu extends Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
QQBotManager.getInstance();
|
|
||||||
try {
|
|
||||||
Thread.sleep(5000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
String ret = HttpTools.get("https://api.ixiaowai.cn/api/api.php?return=json");
|
|
||||||
JSONObject json = JSONObject.parseObject(ret);
|
|
||||||
HttpTools.download(json.getString("imgurl"),
|
|
||||||
"setu.jpg", new DownloadInterface() {
|
|
||||||
@Override
|
|
||||||
public void onDownload(File file) {
|
|
||||||
super.onDownload(file);
|
|
||||||
QQBotManager.getInstance().sendMessage(file, 583819556L, "");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user