feat: add some type
This commit is contained in:
parent
ad2d5a085e
commit
57177510d5
1
.idea/modules/MyBot.main.iml
generated
1
.idea/modules/MyBot.main.iml
generated
@ -3,6 +3,7 @@
|
|||||||
<component name="AdditionalModuleElements">
|
<component name="AdditionalModuleElements">
|
||||||
<content url="file://$MODULE_DIR$/../../build/generated/sources/annotationProcessor/java/main">
|
<content url="file://$MODULE_DIR$/../../build/generated/sources/annotationProcessor/java/main">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../build/generated/sources/annotationProcessor/java/main" isTestSource="false" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/../../build/generated/sources/annotationProcessor/java/main" isTestSource="false" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/../../build/generated/sources/annotationProcessor/java/main" isTestSource="false" generated="true" />
|
||||||
</content>
|
</content>
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
1
.idea/modules/mybot-api/MyBot.mybot-api.main.iml
generated
1
.idea/modules/mybot-api/MyBot.mybot-api.main.iml
generated
@ -3,6 +3,7 @@
|
|||||||
<component name="AdditionalModuleElements">
|
<component name="AdditionalModuleElements">
|
||||||
<content url="file://$MODULE_DIR$/../../../mybot-api/build/generated/sources/annotationProcessor/java/main">
|
<content url="file://$MODULE_DIR$/../../../mybot-api/build/generated/sources/annotationProcessor/java/main">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../../mybot-api/build/generated/sources/annotationProcessor/java/main" isTestSource="false" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/../../../mybot-api/build/generated/sources/annotationProcessor/java/main" isTestSource="false" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/../../../mybot-api/build/generated/sources/annotationProcessor/java/main" isTestSource="false" generated="true" />
|
||||||
</content>
|
</content>
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -6,8 +6,6 @@ import com.alibaba.fastjson2.annotation.JSONField;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 群成员信息
|
* 群成员信息
|
||||||
*
|
*
|
||||||
@ -63,19 +61,19 @@ public class GroupMemberInformation {
|
|||||||
*/
|
*/
|
||||||
private String area;
|
private String area;
|
||||||
/**
|
/**
|
||||||
* 加群时间
|
* 加群时间时间戳
|
||||||
*
|
*
|
||||||
* @since 2024/8/24 19:30 v0.0.6-dev
|
* @since 2024/8/24 19:30 v0.0.6-dev
|
||||||
*/
|
*/
|
||||||
@JSONField(name = "join_time")
|
@JSONField(name = "join_time")
|
||||||
private Date joinTime;
|
private Long joinTime;
|
||||||
/**
|
/**
|
||||||
* 最后发言时间
|
* 最后发言时间时间戳
|
||||||
*
|
*
|
||||||
* @since 2024/8/24 19:30 v0.0.6-dev
|
* @since 2024/8/24 19:30 v0.0.6-dev
|
||||||
*/
|
*/
|
||||||
@JSONField(name = "last_sent_time")
|
@JSONField(name = "last_sent_time")
|
||||||
private Date lastSentTime;
|
private Long lastSentTime;
|
||||||
/**
|
/**
|
||||||
* 成员等级
|
* 成员等级
|
||||||
*
|
*
|
||||||
@ -101,12 +99,12 @@ public class GroupMemberInformation {
|
|||||||
*/
|
*/
|
||||||
private String title;
|
private String title;
|
||||||
/**
|
/**
|
||||||
* 专属头衔过期时间
|
* 专属头衔过期时间时间戳
|
||||||
*
|
*
|
||||||
* @since 2024/8/24 19:30 v0.0.6-dev
|
* @since 2024/8/24 19:30 v0.0.6-dev
|
||||||
*/
|
*/
|
||||||
@JSONField(name = "title_expire_time")
|
@JSONField(name = "title_expire_time")
|
||||||
private Date titleExpireTime;
|
private Long titleExpireTime;
|
||||||
/**
|
/**
|
||||||
* 是否允许修改群名片
|
* 是否允许修改群名片
|
||||||
*
|
*
|
||||||
|
@ -140,7 +140,13 @@ public enum PartType {
|
|||||||
*
|
*
|
||||||
* @since 2024/8/25 15:20 v1.0.0
|
* @since 2024/8/25 15:20 v1.0.0
|
||||||
*/
|
*/
|
||||||
MARKDOWN(MarkdownMessage.class);
|
MARKDOWN(MarkdownMessage.class),
|
||||||
|
/**
|
||||||
|
* 未知消息类型
|
||||||
|
*
|
||||||
|
* @since 2024/11/17 17:23 v1.0.5
|
||||||
|
*/
|
||||||
|
UNKNOWN(UnknownPart.class);
|
||||||
public final Class<? extends JsonMessagePart> clazz;
|
public final Class<? extends JsonMessagePart> clazz;
|
||||||
|
|
||||||
PartType(Class<? extends JsonMessagePart> clazz) {
|
PartType(Class<? extends JsonMessagePart> clazz) {
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
package cn.wzpmc.message.json.parts;
|
||||||
|
|
||||||
|
import cn.wzpmc.message.json.JsonMessagePart;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 未知消息类型
|
||||||
|
*
|
||||||
|
* @author wzp
|
||||||
|
* @version 1.0.5
|
||||||
|
* @since 2024/11/17 17:22
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class UnknownPart implements JsonMessagePart {
|
||||||
|
/**
|
||||||
|
* 类型文本
|
||||||
|
*
|
||||||
|
* @since 2024/11/17 17:32 v1.0.5
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
/**
|
||||||
|
* 消息数据
|
||||||
|
*
|
||||||
|
* @since 2024/11/17 17:33 v1.0.5
|
||||||
|
*/
|
||||||
|
private JSONObject data;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartType getPartType() {
|
||||||
|
return PartType.UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getStringPartType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ package cn.wzpmc.utils;
|
|||||||
import cn.wzpmc.message.json.JsonMessagePart;
|
import cn.wzpmc.message.json.JsonMessagePart;
|
||||||
import cn.wzpmc.message.json.parts.At;
|
import cn.wzpmc.message.json.parts.At;
|
||||||
import cn.wzpmc.message.json.parts.PartType;
|
import cn.wzpmc.message.json.parts.PartType;
|
||||||
|
import cn.wzpmc.message.json.parts.UnknownPart;
|
||||||
import cn.wzpmc.message.json.parts.music.MusicType;
|
import cn.wzpmc.message.json.parts.music.MusicType;
|
||||||
import cn.wzpmc.message.json.parts.node.CustomNode;
|
import cn.wzpmc.message.json.parts.node.CustomNode;
|
||||||
import cn.wzpmc.message.json.parts.node.SingleNode;
|
import cn.wzpmc.message.json.parts.node.SingleNode;
|
||||||
@ -111,9 +112,18 @@ public class CqCodeUtils {
|
|||||||
* @since 2024/8/26 14:40 v1.0.0
|
* @since 2024/8/26 14:40 v1.0.0
|
||||||
*/
|
*/
|
||||||
public static JsonMessagePart parsePart(JSONObject jsonObject) throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException {
|
public static JsonMessagePart parsePart(JSONObject jsonObject) throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException {
|
||||||
PartType type = jsonObject.getObject("type", PartType.class);
|
PartType type = PartType.UNKNOWN;
|
||||||
|
PartType resolvedType = jsonObject.getObject("type", PartType.class);
|
||||||
|
if (resolvedType != null) {
|
||||||
|
type = resolvedType;
|
||||||
|
}
|
||||||
Class<? extends JsonMessagePart> clazz = type.clazz;
|
Class<? extends JsonMessagePart> clazz = type.clazz;
|
||||||
JSONObject dataObject = jsonObject.getJSONObject("data");
|
JSONObject dataObject = jsonObject.getJSONObject("data");
|
||||||
|
if (type.equals(PartType.UNKNOWN)) {
|
||||||
|
String stringType = jsonObject.getString("type");
|
||||||
|
log.warn("发现无法解析的json消息数据,数据类型:{},数据内容:{}", stringType, dataObject);
|
||||||
|
return new UnknownPart(stringType, dataObject);
|
||||||
|
}
|
||||||
if (type.equals(PartType.AT)) {
|
if (type.equals(PartType.AT)) {
|
||||||
String string = dataObject.getString("qq");
|
String string = dataObject.getString("qq");
|
||||||
if (string.equalsIgnoreCase("all")) {
|
if (string.equalsIgnoreCase("all")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user