add PaoPaoSleepWaring
This commit is contained in:
parent
5ac0b45540
commit
ab1facc747
@ -71,12 +71,7 @@ public class AppController {
|
||||
if (json.containsKey("image")) {
|
||||
image = HttpTools.syncDownload(json.getString("image"), System.currentTimeMillis() + ".png",true);
|
||||
}
|
||||
if (image != null) {
|
||||
ret = QQBotManager.getInstance().sendMessage(image, json.getLong("qq"), json.getString("message"));
|
||||
|
||||
} else {
|
||||
ret = QQBotManager.getInstance().sendMessage(json.getLong("qq"), json.getString("message"));
|
||||
}
|
||||
ret = QQBotManager.getInstance().sendMessage(image, json.getLong("qq"), json.getString("message"));
|
||||
return ret==null?"message send fail":"message send success";
|
||||
}
|
||||
|
||||
|
@ -9,10 +9,7 @@ import net.mamoe.mirai.BotFactory;
|
||||
import net.mamoe.mirai.contact.Group;
|
||||
import net.mamoe.mirai.event.GlobalEventChannel;
|
||||
import net.mamoe.mirai.message.MessageReceipt;
|
||||
import net.mamoe.mirai.message.data.Image;
|
||||
import net.mamoe.mirai.message.data.MessageChain;
|
||||
import net.mamoe.mirai.message.data.MessageChainBuilder;
|
||||
import net.mamoe.mirai.message.data.QuoteReply;
|
||||
import net.mamoe.mirai.message.data.*;
|
||||
import net.mamoe.mirai.utils.BotConfiguration;
|
||||
import net.mamoe.mirai.utils.ExternalResource;
|
||||
|
||||
@ -95,6 +92,9 @@ public class QQBotManager {
|
||||
}
|
||||
|
||||
private Image getImage(File file, Long qq) {
|
||||
if(file==null){
|
||||
return null;
|
||||
}
|
||||
if (bot != null) {
|
||||
ExternalResource resource = ExternalResource.create(file);
|
||||
Image image;
|
||||
@ -170,6 +170,15 @@ public class QQBotManager {
|
||||
if (image != null) {
|
||||
builder.append(image);
|
||||
}
|
||||
List<String> list=PatternTools.getQQ(text);
|
||||
if (!list.isEmpty()) {
|
||||
for (String _qq : list) {
|
||||
String[] tmp = text.split(_qq);
|
||||
builder.append(tmp[0]);
|
||||
builder.append(new At(Long.parseLong(_qq.replace("@", ""))));
|
||||
text = text.replace(tmp[0] + _qq, "");
|
||||
}
|
||||
}
|
||||
builder.append(text);
|
||||
if (QQNumberManager.getManager().isGroup(qq)) {
|
||||
return Objects.requireNonNull(bot.getGroup(qq)).sendMessage(builder.asMessageChain());
|
||||
|
@ -0,0 +1,40 @@
|
||||
package com.yutou.qqbot.models.Commands;
|
||||
|
||||
import com.yutou.qqbot.Annotations.UseModel;
|
||||
import com.yutou.qqbot.QQBotManager;
|
||||
import com.yutou.qqbot.models.Model;
|
||||
import com.yutou.qqbot.utlis.AppTools;
|
||||
import net.mamoe.mirai.event.events.MessageEvent;
|
||||
import net.mamoe.mirai.message.data.MessageChainBuilder;
|
||||
import net.mamoe.mirai.message.data.QuoteReply;
|
||||
|
||||
import static com.yutou.qqbot.models.Model.QQGroupCommands.QQ_TIMEOUT;
|
||||
|
||||
@UseModel
|
||||
public class PaoPaoSleepWaring extends Model {
|
||||
@Override
|
||||
public boolean isUserPublic() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getUsePowers() {
|
||||
return new String[]{QQ_TIMEOUT};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelName() {
|
||||
return "paopao";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
|
||||
super.onMessage(qq, event, isGroup);
|
||||
if(Integer.parseInt(AppTools.getHours())>22 && event.getSource().getFromId() == 914520754){
|
||||
MessageChainBuilder builder=new MessageChainBuilder();
|
||||
builder.append(new QuoteReply(event.getMessage()));
|
||||
builder.append("别水了,该睡了~");
|
||||
QQBotManager.getInstance().sendMessage(qq,builder);
|
||||
}
|
||||
}
|
||||
}
|
@ -39,6 +39,7 @@ public abstract class Model implements ModelInterface {
|
||||
public final static String BILI_LIVE_DANMU_DEL="!b站签到删除";
|
||||
|
||||
public final static String QQ_WOODEN="!电子木鱼";
|
||||
public final static String QQ_TIMEOUT="!timer";
|
||||
|
||||
}
|
||||
|
||||
|
25
src/main/java/com/yutou/qqbot/utlis/PatternTools.java
Normal file
25
src/main/java/com/yutou/qqbot/utlis/PatternTools.java
Normal file
@ -0,0 +1,25 @@
|
||||
package com.yutou.qqbot.utlis;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class PatternTools {
|
||||
private static List<String> exec(String regex, String input){
|
||||
List<String> list=new ArrayList<>();
|
||||
Pattern pattern=Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
while(matcher.find()){
|
||||
list.add(matcher.group());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public static List<String> pattern(String text,String start,String end){
|
||||
return exec(String.format(".(?<=%s).*(?=%s)", start,end), text);
|
||||
}
|
||||
public static List<String> getQQ(String text){
|
||||
return exec("(@[0-9]\\d*)",text);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user