[Add] MiraiMessageSender 增加对默认表情的支持;

This commit is contained in:
LamGC 2020-05-12 15:25:29 +08:00
parent 60e91987d1
commit d993e9d719

View File

@ -11,10 +11,7 @@ import net.lamgc.cgj.bot.message.MessageSender;
import net.lamgc.cgj.bot.message.MessageSource; import net.lamgc.cgj.bot.message.MessageSource;
import net.mamoe.mirai.Bot; import net.mamoe.mirai.Bot;
import net.mamoe.mirai.contact.Contact; import net.mamoe.mirai.contact.Contact;
import net.mamoe.mirai.message.data.Image; import net.mamoe.mirai.message.data.*;
import net.mamoe.mirai.message.data.Message;
import net.mamoe.mirai.message.data.MessageChain;
import net.mamoe.mirai.message.data.MessageUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -117,6 +114,15 @@ public class MiraiMessageSender implements MessageSender {
} else { } else {
return img; return img;
} }
case "face":
if(!code.containsParameter("id")) {
return MessageUtils.newChain("(无效的表情Id)");
}
int faceId = Integer.parseInt(code.getParameter("id"));
if(faceId <= 0) {
return MessageUtils.newChain("(无效的表情Id)");
}
return new Face(faceId);
default: default:
log.warn("解析到不支持的BotCode: {}", code); log.warn("解析到不支持的BotCode: {}", code);
return MessageUtils.newChain("(不支持的BotCode)"); return MessageUtils.newChain("(不支持的BotCode)");