Skip to content

Commit

Permalink
替换图片寻找方式
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg886 authored and SwaggyMacro committed Sep 17, 2022
1 parent 8199be2 commit 9000fe7
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/main/java/com/julym/bot/BotRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,8 @@ public void receiveMessage(GroupMessageEvent event){
if (chain.contentToString().equals("SwaggyMacro")){
SendMessage(event, "嘿嘿, 你是怎么认识可爱的卖扣肉的呀?");
}
String msg = event.getSource().getOriginalMessage().toString();
String pattern = "\\[mirai:(image|flash):(.*?)\\.(.*?)\\]";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(msg);
while(m.find()) {
Image image = Image.fromId(m.group(2) + '.' + m.group(3));
event.getMessage().stream().filter(Image.class::isInstance).forEach((t) -> {
Image image = (Image) t;
try {
String imgPath = ImageUtil.saveImage(image, this.pluginPath);
BufferedImage bufferedImage = ImageIO.read(new FileInputStream(imgPath));
Expand All @@ -400,21 +396,21 @@ public void receiveMessage(GroupMessageEvent event){

if (TopClass.equals("porn") || TopClass.equals("sexy") || TopClass.equals("hentai")) {
if (Float.parseFloat(TopProbability) < this.nsfwConfig._porn.getThreshold()){
break;
return;
}
if (TopClass.equals("porn")){
if (Float.parseFloat(TopProbability) < this.nsfwConfig._porn.getThreshold()){
break;
return;
}
}
if (TopClass.equals("sexy")){
if (Float.parseFloat(TopProbability) < this.nsfwConfig._sexy.getThreshold()){
break;
return;
}
}
if (TopClass.equals("hentai")){
if (Float.parseFloat(TopProbability) < this.nsfwConfig._hentai.getThreshold()){
break;
return;
}
}
if (event.getSource().getSender().getPermission() == MemberPermission.ADMINISTRATOR){
Expand All @@ -441,12 +437,11 @@ public void receiveMessage(GroupMessageEvent event){
}
}
event.getSubject().sendMessage(messages);
break;
}
} catch (IOException e) {
e.printStackTrace();
}
}
});

}

Expand Down

0 comments on commit 9000fe7

Please sign in to comment.