feat: adding events
This commit is contained in:
parent
932f903455
commit
be18927b3c
15
src/main/java/cn/wzpmc/api/entities/BotStatus.java
Normal file
15
src/main/java/cn/wzpmc/api/entities/BotStatus.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package cn.wzpmc.api.entities;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bot运行状态
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午10:30
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BotStatus {
|
||||||
|
private boolean online;
|
||||||
|
private boolean good;
|
||||||
|
}
|
35
src/main/java/cn/wzpmc/api/events/Event.java
Normal file
35
src/main/java/cn/wzpmc/api/events/Event.java
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package cn.wzpmc.api.events;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事件基类
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午5:46
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Event {
|
||||||
|
/**
|
||||||
|
* 事件发生的时间戳
|
||||||
|
* @since 2024/8/1 下午5:52 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private Long time;
|
||||||
|
/**
|
||||||
|
* 收到事件的机器人的QQ号
|
||||||
|
* @since 2024/8/1 下午5:52 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "self_id")
|
||||||
|
private Long selfId;
|
||||||
|
/**
|
||||||
|
* 事件类型
|
||||||
|
* @since 2024/8/1 下午5:52 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "post_type")
|
||||||
|
private EventPostType postType;
|
||||||
|
}
|
30
src/main/java/cn/wzpmc/api/events/EventPostType.java
Normal file
30
src/main/java/cn/wzpmc/api/events/EventPostType.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package cn.wzpmc.api.events;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事件类型
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午5:47
|
||||||
|
*/
|
||||||
|
public enum EventPostType {
|
||||||
|
/**
|
||||||
|
* 消息事件
|
||||||
|
* @since 2024/8/1 下午5:48 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
MESSAGE,
|
||||||
|
/**
|
||||||
|
* 通知事件
|
||||||
|
* @since 2024/8/1 下午5:47 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
NOTICE,
|
||||||
|
/**
|
||||||
|
* 请求事件
|
||||||
|
* @since 2024/8/1 下午5:47 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
REQUEST,
|
||||||
|
/**
|
||||||
|
* 元事件
|
||||||
|
* @since 2024/8/1 下午5:47 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
META_EVENT,
|
||||||
|
}
|
67
src/main/java/cn/wzpmc/api/events/message/MessageEvent.java
Normal file
67
src/main/java/cn/wzpmc/api/events/message/MessageEvent.java
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
package cn.wzpmc.api.events.message;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.Event;
|
||||||
|
import cn.wzpmc.api.message.MessageComponent;
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午5:49
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class MessageEvent<E, U> extends Event {
|
||||||
|
/**
|
||||||
|
* 消息子类型
|
||||||
|
* @since 2024/8/1 下午11:11 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "sub_type")
|
||||||
|
private E subType;
|
||||||
|
/**
|
||||||
|
* 消息类型
|
||||||
|
* @since 2024/8/1 下午11:24 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "message_type")
|
||||||
|
private MessageType messageType;
|
||||||
|
/**
|
||||||
|
* 消息ID
|
||||||
|
* @since 2024/8/1 下午11:11 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "message_id")
|
||||||
|
private Integer messageId;
|
||||||
|
/**
|
||||||
|
* 发送者ID
|
||||||
|
* @since 2024/8/1 下午11:11 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "user_id")
|
||||||
|
private Integer userId;
|
||||||
|
/**
|
||||||
|
* 消息详细内容
|
||||||
|
* @since 2024/8/1 下午11:11 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private MessageComponent message;
|
||||||
|
/**
|
||||||
|
* 文本格式消息
|
||||||
|
* @since 2024/8/1 下午11:11 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "raw_message")
|
||||||
|
private String rawMessage;
|
||||||
|
/**
|
||||||
|
* 消息使用字体
|
||||||
|
* @since 2024/8/1 下午11:11 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private Integer font;
|
||||||
|
/**
|
||||||
|
* 发送者详细信息
|
||||||
|
* @since 2024/8/1 下午11:12 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private U sender;
|
||||||
|
}
|
27
src/main/java/cn/wzpmc/api/events/message/MessageType.java
Normal file
27
src/main/java/cn/wzpmc/api/events/message/MessageType.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package cn.wzpmc.api.events.message;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.message.group.GroupMessageEvent;
|
||||||
|
import cn.wzpmc.api.events.message.priv.PrivateMessageEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息类型
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午5:54
|
||||||
|
*/
|
||||||
|
public enum MessageType {
|
||||||
|
/**
|
||||||
|
* 私聊
|
||||||
|
* @since 2024/8/1 下午5:55 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
PRIVATE(PrivateMessageEvent.class),
|
||||||
|
/**
|
||||||
|
* 群
|
||||||
|
* @since 2024/8/1 下午5:55 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
GROUP(GroupMessageEvent.class);
|
||||||
|
public final Class<? extends MessageEvent<?, ?>> clazz;
|
||||||
|
MessageType(Class<? extends MessageEvent<?, ?>> clazz){
|
||||||
|
this.clazz = clazz;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package cn.wzpmc.api.events.message.group;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.message.MessageEvent;
|
||||||
|
import cn.wzpmc.api.user.group.GroupUser;
|
||||||
|
import cn.wzpmc.api.user.group.GroupUserAnonymousInfo;
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群消息事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午8:59
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class GroupMessageEvent extends MessageEvent<GroupMessageSubType, GroupUser> {
|
||||||
|
/**
|
||||||
|
* 群号
|
||||||
|
* @since 2024/8/1 下午11:11 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "group_id")
|
||||||
|
private Long groupId;
|
||||||
|
/**
|
||||||
|
* 匿名消息消息(当非匿名消息时为null)
|
||||||
|
* @since 2024/8/1 下午11:10 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private GroupUserAnonymousInfo anonymous;
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package cn.wzpmc.api.events.message.group;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群消息子类型
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午6:02
|
||||||
|
*/
|
||||||
|
public enum GroupMessageSubType {
|
||||||
|
/**
|
||||||
|
* 好友
|
||||||
|
* @since 2024/8/1 下午6:03 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
FRIEND,
|
||||||
|
/**
|
||||||
|
* 群临时会话
|
||||||
|
* @since 2024/8/1 下午6:03 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
GROUP,
|
||||||
|
/**
|
||||||
|
* 其他
|
||||||
|
* @since 2024/8/1 下午6:03 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
OTHER
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package cn.wzpmc.api.events.message.priv;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.message.MessageEvent;
|
||||||
|
import cn.wzpmc.api.user.Friend;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 饲料消息事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:02
|
||||||
|
*/
|
||||||
|
public class PrivateMessageEvent extends MessageEvent<PrivateMessageSubType, Friend> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package cn.wzpmc.api.events.message.priv;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 私聊消息子类型
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午6:04
|
||||||
|
*/
|
||||||
|
public enum PrivateMessageSubType {
|
||||||
|
/**
|
||||||
|
* 正常消息
|
||||||
|
* @since 2024/8/1 下午6:07 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
NORMAL,
|
||||||
|
/**
|
||||||
|
* 匿名消息
|
||||||
|
* @since 2024/8/1 下午6:06 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
ANONYMOUS,
|
||||||
|
/**
|
||||||
|
* 系统提示
|
||||||
|
* @since 2024/8/1 下午6:06 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
NOTICE
|
||||||
|
}
|
25
src/main/java/cn/wzpmc/api/events/meta/HeartBeatEvent.java
Normal file
25
src/main/java/cn/wzpmc/api/events/meta/HeartBeatEvent.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package cn.wzpmc.api.events.meta;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.entities.BotStatus;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午10:30
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class HeartBeatEvent extends MetaEvent{
|
||||||
|
/**
|
||||||
|
* 状态信息
|
||||||
|
* @since 2024/8/1 下午10:32 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private BotStatus status;
|
||||||
|
/**
|
||||||
|
* 到下次心跳的间隔(ms)
|
||||||
|
* @since 2024/8/1 下午10:32 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private Long interval;
|
||||||
|
}
|
23
src/main/java/cn/wzpmc/api/events/meta/MetaEvent.java
Normal file
23
src/main/java/cn/wzpmc/api/events/meta/MetaEvent.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package cn.wzpmc.api.events.meta;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.Event;
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 元事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午10:26
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class MetaEvent extends Event {
|
||||||
|
/**
|
||||||
|
* 元事件子类型
|
||||||
|
* @since 2024/8/1 下午11:12 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "meta_event_type")
|
||||||
|
private MetaEventType metaEventType;
|
||||||
|
}
|
17
src/main/java/cn/wzpmc/api/events/meta/MetaEventType.java
Normal file
17
src/main/java/cn/wzpmc/api/events/meta/MetaEventType.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package cn.wzpmc.api.events.meta;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.meta.lifecycle.LifecycleEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午10:26
|
||||||
|
*/
|
||||||
|
public enum MetaEventType {
|
||||||
|
LIFECYCLE(LifecycleEvent.class),
|
||||||
|
HEARTBEAT(HeartBeatEvent.class);
|
||||||
|
public final Class<? extends MetaEvent> clazz;
|
||||||
|
MetaEventType(Class<? extends MetaEvent> clazz){
|
||||||
|
this.clazz = clazz;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package cn.wzpmc.api.events.meta.lifecycle;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.meta.MetaEvent;
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午10:28
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class LifecycleEvent extends MetaEvent {
|
||||||
|
/**
|
||||||
|
* 生命周期事件子类型
|
||||||
|
* @since 2024/8/1 下午10:29 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "sub_type")
|
||||||
|
private LifecycleEventSubType subType;
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package cn.wzpmc.api.events.meta.lifecycle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期事件子类型
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午10:28
|
||||||
|
*/
|
||||||
|
public enum LifecycleEventSubType {
|
||||||
|
/**
|
||||||
|
* OneBot被启用
|
||||||
|
* @since 2024/8/1 下午10:29 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
ENABLE,
|
||||||
|
/**
|
||||||
|
* OneBot被禁用
|
||||||
|
* @since 2024/8/1 下午10:29 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
DISABLE,
|
||||||
|
/**
|
||||||
|
* WebSocket连接成功
|
||||||
|
* @since 2024/8/1 下午10:29 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
CONNECT
|
||||||
|
}
|
22
src/main/java/cn/wzpmc/api/events/notice/FriendAddEvent.java
Normal file
22
src/main/java/cn/wzpmc/api/events/notice/FriendAddEvent.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package cn.wzpmc.api.events.notice;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 好友添加事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:42
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class FriendAddEvent extends NoticeEvent {
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
* @since 2024/8/1 下午11:13 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "user_id")
|
||||||
|
private Long userId;
|
||||||
|
}
|
39
src/main/java/cn/wzpmc/api/events/notice/GroupBanEvent.java
Normal file
39
src/main/java/cn/wzpmc/api/events/notice/GroupBanEvent.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package cn.wzpmc.api.events.notice;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群成员禁言事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午10:19
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class GroupBanEvent extends NoticeEvent{
|
||||||
|
/**
|
||||||
|
* 群号
|
||||||
|
* @since 2024/8/1 下午10:21 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "group_id")
|
||||||
|
private Long groupId;
|
||||||
|
/**
|
||||||
|
* 操作者用户ID
|
||||||
|
* @since 2024/8/1 下午10:20 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "operator_id")
|
||||||
|
private Long operatorId;
|
||||||
|
/**
|
||||||
|
* 被禁言的用户ID
|
||||||
|
* @since 2024/8/1 下午10:20 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "user_id")
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 被禁言的时长(秒)
|
||||||
|
* @since 2024/8/1 下午10:20 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private Long duration;
|
||||||
|
}
|
23
src/main/java/cn/wzpmc/api/events/notice/NoticeEvent.java
Normal file
23
src/main/java/cn/wzpmc/api/events/notice/NoticeEvent.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package cn.wzpmc.api.events.notice;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.Event;
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知基事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:21
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class NoticeEvent extends Event {
|
||||||
|
/**
|
||||||
|
* 通知类型
|
||||||
|
* @since 2024/8/1 下午11:12 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "notice_type")
|
||||||
|
private NoticeType noticeType;
|
||||||
|
}
|
68
src/main/java/cn/wzpmc/api/events/notice/NoticeType.java
Normal file
68
src/main/java/cn/wzpmc/api/events/notice/NoticeType.java
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package cn.wzpmc.api.events.notice;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.notice.admin.GroupAdminChangeEvent;
|
||||||
|
import cn.wzpmc.api.events.notice.file.GroupFileUploadedEvent;
|
||||||
|
import cn.wzpmc.api.events.notice.notify.NotifyEvent;
|
||||||
|
import cn.wzpmc.api.events.notice.recall.GroupMessageRecallEvent;
|
||||||
|
import cn.wzpmc.api.events.notice.recall.MessageRecallEvent;
|
||||||
|
import cn.wzpmc.api.events.notice.user.decrease.GroupUserDecreaseEvent;
|
||||||
|
import cn.wzpmc.api.events.notice.user.increase.GroupUserIncreaseEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知类型
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:12
|
||||||
|
*/
|
||||||
|
public enum NoticeType {
|
||||||
|
/**
|
||||||
|
* 群文件上传事件
|
||||||
|
* @since 2024/8/1 下午10:24 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
GROUP_UPLOAD(GroupFileUploadedEvent.class),
|
||||||
|
/**
|
||||||
|
* 群管理变更事件
|
||||||
|
* @since 2024/8/1 下午10:24 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
GROUP_ADMIN(GroupAdminChangeEvent.class),
|
||||||
|
/**
|
||||||
|
* 用户退群事件
|
||||||
|
* @since 2024/8/1 下午10:24 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
GROUP_DECREASE(GroupUserDecreaseEvent.class),
|
||||||
|
/**
|
||||||
|
* 用户加群事件
|
||||||
|
* @since 2024/8/1 下午10:23 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
GROUP_INCREASE(GroupUserIncreaseEvent.class),
|
||||||
|
/**
|
||||||
|
* 群组禁言事件
|
||||||
|
* @since 2024/8/1 下午10:23 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
GROUP_BAN(GroupBanEvent.class),
|
||||||
|
/**
|
||||||
|
* 好友添加事件
|
||||||
|
* @since 2024/8/1 下午10:23 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
FRIEND_ADD(FriendAddEvent.class),
|
||||||
|
/**
|
||||||
|
* 群消息撤回事件
|
||||||
|
* @since 2024/8/1 下午10:23 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
GROUP_RECALL(GroupMessageRecallEvent.class),
|
||||||
|
/**
|
||||||
|
* 好友消息撤回事件
|
||||||
|
* @since 2024/8/1 下午10:23 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
FRIEND_RECALL(MessageRecallEvent.class),
|
||||||
|
/**
|
||||||
|
* 群提醒事件
|
||||||
|
* @since 2024/8/1 下午10:22 v0.0.2-dev
|
||||||
|
* @see cn.wzpmc.api.events.notice.notify.NotifyEvent
|
||||||
|
*/
|
||||||
|
NOTIFY(NotifyEvent.class);
|
||||||
|
public final Class<? extends NoticeEvent> clazz;
|
||||||
|
NoticeType(Class<? extends NoticeEvent> clazz){
|
||||||
|
this.clazz = clazz;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.admin;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.notice.NoticeEvent;
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群管理员更改事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:26
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class GroupAdminChangeEvent extends NoticeEvent {
|
||||||
|
/**
|
||||||
|
* 事件子类型
|
||||||
|
* @since 2024/8/1 下午9:28 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "sub_type")
|
||||||
|
private GroupAdminChangeSubType subType;
|
||||||
|
/**
|
||||||
|
* 群号
|
||||||
|
* @since 2024/8/1 下午9:29 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "group_id")
|
||||||
|
private Long groupId;
|
||||||
|
/**
|
||||||
|
* 被操作者QQ号
|
||||||
|
* @since 2024/8/1 下午9:29 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "user_id")
|
||||||
|
private Long userId;
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.admin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理员更改子类型
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:27
|
||||||
|
*/
|
||||||
|
public enum GroupAdminChangeSubType {
|
||||||
|
/**
|
||||||
|
* 设置管理员
|
||||||
|
* @since 2024/8/1 下午9:27 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
SET,
|
||||||
|
/**
|
||||||
|
* 取消管理员
|
||||||
|
* @since 2024/8/1 下午9:28 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
UNSET
|
||||||
|
}
|
32
src/main/java/cn/wzpmc/api/events/notice/file/GroupFile.java
Normal file
32
src/main/java/cn/wzpmc/api/events/notice/file/GroupFile.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.file;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class GroupFile {
|
||||||
|
/**
|
||||||
|
* 文件ID
|
||||||
|
* @since 2024/8/1 下午9:24 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
/**
|
||||||
|
* 文件名
|
||||||
|
* @since 2024/8/1 下午9:24 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 文件大小
|
||||||
|
* @since 2024/8/1 下午9:24 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private Long size;
|
||||||
|
/**
|
||||||
|
* BUSID(具体见<a href="https://github.com/botuniverse/onebot-11/blob/master/event/notice.md">OneBot文档</a>)
|
||||||
|
* @since 2024/8/1 下午9:24 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private Long busid;
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.file;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.notice.NoticeEvent;
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群文件上传事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:21
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class GroupFileUploadedEvent extends NoticeEvent {
|
||||||
|
/**
|
||||||
|
* 群组ID
|
||||||
|
* @since 2024/8/1 下午9:25 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "group_id")
|
||||||
|
private Long groupId;
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
* @since 2024/8/1 下午9:25 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "user_id")
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 文件详细消息
|
||||||
|
* @since 2024/8/1 下午9:25 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "group_file")
|
||||||
|
private GroupFile groupFile;
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.notify;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 红包幸运王事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午10:03
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class LuckyKingNotifyEvent extends NotifyEvent {
|
||||||
|
/**
|
||||||
|
* 运气王ID
|
||||||
|
* @since 2024/8/1 下午10:04 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "target_id")
|
||||||
|
private Long targetId;
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.notify;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.notice.NoticeEvent;
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群提醒事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:59
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class NotifyEvent extends NoticeEvent {
|
||||||
|
/**
|
||||||
|
* 群号
|
||||||
|
* @since 2024/8/1 下午10:01 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "group_id")
|
||||||
|
private Long groupId;
|
||||||
|
/**
|
||||||
|
* 相关用户ID
|
||||||
|
* @since 2024/8/1 下午10:00 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "user_id")
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 群提醒事件子类型
|
||||||
|
* @since 2024/8/1 下午11:26 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "sub_type")
|
||||||
|
private NotifySubType subType;
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.notify;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.notice.notify.honor.HonorNotifyEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群提醒事件子类型
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:58
|
||||||
|
*/
|
||||||
|
public enum NotifySubType {
|
||||||
|
/**
|
||||||
|
* 群内戳一戳事件
|
||||||
|
* @since 2024/8/1 下午10:16 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
POKE(PokeNotifyEvent.class),
|
||||||
|
/**
|
||||||
|
* 红包运气王事件
|
||||||
|
* @since 2024/8/1 下午10:16 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
LUCKY_KING(LuckyKingNotifyEvent.class),
|
||||||
|
/**
|
||||||
|
* 群内荣耀变更事件
|
||||||
|
* @since 2024/8/1 下午10:16 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
HONOR(HonorNotifyEvent.class);
|
||||||
|
public final Class<? extends NotifyEvent> clazz;
|
||||||
|
NotifySubType(Class<? extends NotifyEvent> clazz){
|
||||||
|
this.clazz = clazz;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.notify;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群内戳一戳事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午10:02
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class PokeNotifyEvent extends NotifyEvent {
|
||||||
|
/**
|
||||||
|
* 被戳者ID
|
||||||
|
* @since 2024/8/1 下午10:02 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "target_id")
|
||||||
|
private Long targetId;
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.notify.honor;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.notice.notify.NotifyEvent;
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群荣耀变更事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午10:04
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class HonorNotifyEvent extends NotifyEvent {
|
||||||
|
/**
|
||||||
|
* 荣耀类型
|
||||||
|
* @since 2024/8/1 下午10:06 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "honor_type")
|
||||||
|
private HonorType honorType;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.notify.honor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 荣耀类型
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午10:05
|
||||||
|
*/
|
||||||
|
public enum HonorType {
|
||||||
|
/**
|
||||||
|
* 龙王
|
||||||
|
* @since 2024/8/1 下午10:05 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
TALKACTIVE,
|
||||||
|
/**
|
||||||
|
* 群聊之火
|
||||||
|
* @since 2024/8/1 下午10:05 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
PERFORMER,
|
||||||
|
/**
|
||||||
|
* 快乐源泉
|
||||||
|
* @since 2024/8/1 下午10:05 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
EMOTION
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.recall;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群消息撤回事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:43
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class GroupMessageRecallEvent extends MessageRecallEvent {
|
||||||
|
/**
|
||||||
|
* 群号
|
||||||
|
* @since 2024/8/1 下午9:46 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "group_id")
|
||||||
|
private Long groupId;
|
||||||
|
/**
|
||||||
|
* 操作者ID
|
||||||
|
* @since 2024/8/1 下午9:45 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "operator_id")
|
||||||
|
private Long operatorId;
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.recall;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.notice.NoticeEvent;
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息撤回事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:48
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class MessageRecallEvent extends NoticeEvent {
|
||||||
|
/**
|
||||||
|
* 被撤回的用户ID
|
||||||
|
* @since 2024/8/1 下午9:49 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "user_id")
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 被撤回的消息ID
|
||||||
|
* @since 2024/8/1 下午9:49 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "message_id")
|
||||||
|
private Long messageId;
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.user;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.notice.NoticeEvent;
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群成员更改事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:30
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class GroupUserModifyEvent<S> extends NoticeEvent {
|
||||||
|
/**
|
||||||
|
* 消息子类型
|
||||||
|
* @since 2024/8/1 下午9:31 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "sub_type")
|
||||||
|
private S subType;
|
||||||
|
/***
|
||||||
|
* 群ID
|
||||||
|
* @since 2024/8/1 下午9:31 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "group_id")
|
||||||
|
private Long groupId;
|
||||||
|
/**
|
||||||
|
* 操作者
|
||||||
|
* @since 2024/8/1 下午9:32 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "operator_id")
|
||||||
|
private Long operatorId;
|
||||||
|
/**
|
||||||
|
* 加入/退出用户ID
|
||||||
|
* @since 2024/8/1 下午9:35 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "user_id")
|
||||||
|
private Long userId;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.user.decrease;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.notice.user.GroupUserModifyEvent;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群成员减少事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:29
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class GroupUserDecreaseEvent extends GroupUserModifyEvent<GroupUserDecreaseSubType> {
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.user.decrease;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:36
|
||||||
|
*/
|
||||||
|
public enum GroupUserDecreaseSubType {
|
||||||
|
/**
|
||||||
|
* 主动退群
|
||||||
|
* @since 2024/8/1 下午9:37 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
LEAVE,
|
||||||
|
/**
|
||||||
|
* 成员被踢出
|
||||||
|
* @since 2024/8/1 下午9:37 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
KICK,
|
||||||
|
/**
|
||||||
|
* 机器人被踢
|
||||||
|
* @since 2024/8/1 下午9:37 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
KICK_ME
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.user.increase;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.notice.user.GroupUserModifyEvent;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群成员增加事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:38
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class GroupUserIncreaseEvent extends GroupUserModifyEvent<GroupUserIncreaseSubType> {
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package cn.wzpmc.api.events.notice.user.increase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户增加事件子类型
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午9:39
|
||||||
|
*/
|
||||||
|
public enum GroupUserIncreaseSubType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群管理同意
|
||||||
|
* @since 2024/8/1 下午9:40 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
APPROVE,
|
||||||
|
/**
|
||||||
|
* 被群管理邀请加群
|
||||||
|
* @since 2024/8/1 下午9:40 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
INVITE
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package cn.wzpmc.api.events.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加好友事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午10:13
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class FriendAddRequestEvent extends RequestEvent {
|
||||||
|
}
|
39
src/main/java/cn/wzpmc/api/events/request/RequestEvent.java
Normal file
39
src/main/java/cn/wzpmc/api/events/request/RequestEvent.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package cn.wzpmc.api.events.request;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.Event;
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求基事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午10:08
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class RequestEvent extends Event {
|
||||||
|
/**
|
||||||
|
* 请求类型
|
||||||
|
* @since 2024/8/1 下午10:10 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "request_type")
|
||||||
|
private RequestEventType requestType;
|
||||||
|
/**
|
||||||
|
* 发送请求的用户ID
|
||||||
|
* @since 2024/8/1 下午10:10 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "user_id")
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 验证消息
|
||||||
|
* @since 2024/8/1 下午10:10 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private String comment;
|
||||||
|
/**
|
||||||
|
* 请求Flag
|
||||||
|
* @since 2024/8/1 下午10:10 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private String flag;
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package cn.wzpmc.api.events.request;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.request.group.GroupJoinRequestEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求事件子类型
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午10:09
|
||||||
|
*/
|
||||||
|
public enum RequestEventType {
|
||||||
|
/**
|
||||||
|
* 加好友事件
|
||||||
|
* @since 2024/8/1 下午10:15 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
FRIEND(FriendAddRequestEvent.class),
|
||||||
|
/**
|
||||||
|
* 申请加群事件
|
||||||
|
* @since 2024/8/1 下午10:15 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
GROUP(GroupJoinRequestEvent.class);
|
||||||
|
public final Class<? extends RequestEvent> clazz;
|
||||||
|
RequestEventType(Class<? extends RequestEvent> clazz) {
|
||||||
|
this.clazz = clazz;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package cn.wzpmc.api.events.request.group;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.request.RequestEvent;
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加群请求事件
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午10:11
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class GroupJoinRequestEvent extends RequestEvent {
|
||||||
|
/**
|
||||||
|
* 加群子类型
|
||||||
|
* @since 2024/8/1 下午11:17 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "sub_type")
|
||||||
|
private GroupJoinRequestEventSubType subType;
|
||||||
|
/**
|
||||||
|
* 群ID
|
||||||
|
* @since 2024/8/1 下午11:17 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
@JSONField(name = "group_id")
|
||||||
|
private Long groupId;
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package cn.wzpmc.api.events.request.group;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求加群事件请求子类型
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午10:12
|
||||||
|
*/
|
||||||
|
public enum GroupJoinRequestEventSubType {
|
||||||
|
/**
|
||||||
|
* 加群请求
|
||||||
|
* @since 2024/8/1 下午10:12 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
ADD,
|
||||||
|
/**
|
||||||
|
* 邀请Bot加群
|
||||||
|
* @since 2024/8/1 下午10:12 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
INVITE
|
||||||
|
}
|
@ -2,6 +2,9 @@ package cn.wzpmc.api.user;
|
|||||||
|
|
||||||
import cn.wzpmc.api.message.MessageComponent;
|
import cn.wzpmc.api.message.MessageComponent;
|
||||||
import cn.wzpmc.api.user.permission.Permissions;
|
import cn.wzpmc.api.user.permission.Permissions;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息发送者
|
* 消息发送者
|
||||||
@ -9,37 +12,32 @@ import cn.wzpmc.api.user.permission.Permissions;
|
|||||||
* @version 0.0.1-dev
|
* @version 0.0.1-dev
|
||||||
* @since 2024/7/31 上午2:32
|
* @since 2024/7/31 上午2:32
|
||||||
*/
|
*/
|
||||||
public interface CommandSender {
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public abstract class CommandSender {
|
||||||
/**
|
/**
|
||||||
* 获取用户ID
|
* 用户ID
|
||||||
* @author wzp
|
|
||||||
* @since 2024/7/30 下午11:48 v0.0.1-dev
|
* @since 2024/7/30 下午11:48 v0.0.1-dev
|
||||||
* @return 用户ID
|
|
||||||
*/
|
*/
|
||||||
Long getId();
|
protected Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户名
|
* 用户名
|
||||||
* @author wzp
|
|
||||||
* @since 2024/7/30 下午11:48 v0.0.1-dev
|
* @since 2024/7/30 下午11:48 v0.0.1-dev
|
||||||
* @return 用户名
|
|
||||||
*/
|
*/
|
||||||
Long getName();
|
protected String name;
|
||||||
|
/**
|
||||||
|
* 权限
|
||||||
|
* @since 2024/8/1 下午8:24 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
protected Permissions permissions;
|
||||||
/**
|
/**
|
||||||
* 发送消息
|
* 发送消息
|
||||||
* @author wzp
|
* @author wzp
|
||||||
* @since 2024/7/31 上午2:42 v0.0.1-dev
|
* @since 2024/7/31 上午2:42 v0.0.1-dev
|
||||||
* @param messageComponent 消息组件
|
* @param messageComponent 消息组件
|
||||||
*/
|
*/
|
||||||
void sendMessage(MessageComponent messageComponent);
|
public abstract void sendMessage(MessageComponent messageComponent);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指令发送者的权限
|
|
||||||
* @author wzp
|
|
||||||
* @since 2024/8/1 下午4:50 v0.0.2-dev
|
|
||||||
* @return 权限
|
|
||||||
*/
|
|
||||||
Permissions getPermission();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 指令发送者是否为管理员
|
* 指令发送者是否为管理员
|
||||||
@ -47,7 +45,7 @@ public interface CommandSender {
|
|||||||
* @since 2024/8/1 下午4:50 v0.0.2-dev
|
* @since 2024/8/1 下午4:50 v0.0.2-dev
|
||||||
* @return 是否为管理员
|
* @return 是否为管理员
|
||||||
*/
|
*/
|
||||||
default boolean isAdmin(){
|
public boolean isAdmin(){
|
||||||
return Permissions.ADMIN.equals(this.getPermission());
|
return Permissions.ADMIN.equals(this.permissions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
26
src/main/java/cn/wzpmc/api/user/Friend.java
Normal file
26
src/main/java/cn/wzpmc/api/user/Friend.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package cn.wzpmc.api.user;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.message.MessageComponent;
|
||||||
|
import cn.wzpmc.api.user.permission.Permissions;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 好友
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午8:41
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Friend extends IUser{
|
||||||
|
public Friend(Long id, String name, Permissions permissions, String nickname, Sex sex, Integer age) {
|
||||||
|
super(id, name, permissions, nickname, sex, age);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void sendMessage(MessageComponent messageComponent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -9,14 +9,14 @@ import cn.wzpmc.api.plugins.configuration.IConfiguration;
|
|||||||
* @version 0.0.1-dev
|
* @version 0.0.1-dev
|
||||||
* @since 2024/7/31 上午2:31
|
* @since 2024/7/31 上午2:31
|
||||||
*/
|
*/
|
||||||
public interface IBot extends CommandSender {
|
public abstract class IBot extends CommandSender {
|
||||||
/**
|
/**
|
||||||
* 获取配置文件
|
* 获取配置文件
|
||||||
* @author wzp
|
* @author wzp
|
||||||
* @since 2024/7/31 上午2:55 v0.0.1-dev
|
* @since 2024/7/31 上午2:55 v0.0.1-dev
|
||||||
* @return 配置文件
|
* @return 配置文件
|
||||||
*/
|
*/
|
||||||
IConfiguration getConfiguration();
|
public abstract IConfiguration getConfiguration();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指令管理器
|
* 获取指令管理器
|
||||||
@ -24,12 +24,12 @@ public interface IBot extends CommandSender {
|
|||||||
* @since 2024/7/31 上午3:42 v0.0.1-dev
|
* @since 2024/7/31 上午3:42 v0.0.1-dev
|
||||||
* @return 指令管理器
|
* @return 指令管理器
|
||||||
*/
|
*/
|
||||||
ICommandManager getCommandManager();
|
public abstract ICommandManager getCommandManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 停止Bot运行
|
* 停止Bot运行
|
||||||
* @author wzp
|
* @author wzp
|
||||||
* @since 2024/8/1 下午4:57 v0.0.2-dev
|
* @since 2024/8/1 下午4:57 v0.0.2-dev
|
||||||
*/
|
*/
|
||||||
void stop();
|
public abstract void stop();
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,50 @@
|
|||||||
package cn.wzpmc.api.user;
|
package cn.wzpmc.api.user;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.user.permission.Permissions;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户接口
|
* 用户接口
|
||||||
* @author wzp
|
* @author wzp
|
||||||
* @version 0.0.1-dev
|
* @version 0.0.1-dev
|
||||||
* @since 2024/7/30 下午11:42
|
* @since 2024/7/30 下午11:42
|
||||||
*/
|
*/
|
||||||
public interface IUser extends CommandSender {
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public abstract class IUser extends CommandSender {
|
||||||
|
/**
|
||||||
|
* 玩家昵称
|
||||||
|
* @since 2024/8/1 下午8:34 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
protected String nickname;
|
||||||
|
/**
|
||||||
|
* 用户性别
|
||||||
|
* @since 2024/8/1 下午8:25 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
protected Sex sex;
|
||||||
|
/**
|
||||||
|
* 用户年龄
|
||||||
|
* @since 2024/8/1 下午8:25 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
protected Integer age;
|
||||||
|
protected IUser(Long id, String name, Permissions permissions, String nickname, Sex sex, Integer age) {
|
||||||
|
super(id, name, permissions);
|
||||||
|
this.nickname = nickname;
|
||||||
|
this.sex = sex;
|
||||||
|
this.age = age;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getName(){
|
||||||
|
return this.nickname;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void setName(String name){
|
||||||
|
this.nickname = name;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
25
src/main/java/cn/wzpmc/api/user/Sex.java
Normal file
25
src/main/java/cn/wzpmc/api/user/Sex.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package cn.wzpmc.api.user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户性别
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午8:17
|
||||||
|
*/
|
||||||
|
public enum Sex {
|
||||||
|
/**
|
||||||
|
* 男性
|
||||||
|
* @since 2024/8/1 下午8:17 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
MALE,
|
||||||
|
/**
|
||||||
|
* 女性
|
||||||
|
* @since 2024/8/1 下午8:18 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
FEMALE,
|
||||||
|
/**
|
||||||
|
* 未知
|
||||||
|
* @since 2024/8/1 下午8:18 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
UNKNOWN
|
||||||
|
}
|
50
src/main/java/cn/wzpmc/api/user/group/GroupUser.java
Normal file
50
src/main/java/cn/wzpmc/api/user/group/GroupUser.java
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
package cn.wzpmc.api.user.group;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.message.MessageComponent;
|
||||||
|
import cn.wzpmc.api.user.IUser;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群内用户
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午8:19
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class GroupUser extends IUser {
|
||||||
|
/**
|
||||||
|
* 群名片/备注
|
||||||
|
* @since 2024/8/1 下午8:54 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private String card;
|
||||||
|
/**
|
||||||
|
* 地区
|
||||||
|
* @since 2024/8/1 下午8:54 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private String area;
|
||||||
|
/**
|
||||||
|
* 成员等级
|
||||||
|
* @since 2024/8/1 下午8:53 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private String level;
|
||||||
|
/**
|
||||||
|
* 群角色
|
||||||
|
* @since 2024/8/1 下午8:53 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private GroupUserRole role;
|
||||||
|
/**
|
||||||
|
* 专属头衔
|
||||||
|
* @since 2024/8/1 下午8:53 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
@Override
|
||||||
|
public void sendMessage(MessageComponent messageComponent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package cn.wzpmc.api.user.group;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 匿名成员消息
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午8:57
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class GroupUserAnonymousInfo {
|
||||||
|
/**
|
||||||
|
* 匿名ID
|
||||||
|
* @since 2024/8/1 下午8:58 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 匿名名称
|
||||||
|
* @since 2024/8/1 下午8:58 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 匿名成员flag
|
||||||
|
* @since 2024/8/1 下午8:58 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
private String flag;
|
||||||
|
}
|
25
src/main/java/cn/wzpmc/api/user/group/GroupUserRole.java
Normal file
25
src/main/java/cn/wzpmc/api/user/group/GroupUserRole.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package cn.wzpmc.api.user.group;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成员角色
|
||||||
|
* @author wzp
|
||||||
|
* @version 0.0.2-dev
|
||||||
|
* @since 2024/8/1 下午8:52
|
||||||
|
*/
|
||||||
|
public enum GroupUserRole {
|
||||||
|
/**
|
||||||
|
* 群主
|
||||||
|
* @since 2024/8/1 下午8:52 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
OWNER,
|
||||||
|
/**
|
||||||
|
* 群管理
|
||||||
|
* @since 2024/8/1 下午8:52 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
ADMIN,
|
||||||
|
/**
|
||||||
|
* 群成员
|
||||||
|
* @since 2024/8/1 下午8:52 v0.0.2-dev
|
||||||
|
*/
|
||||||
|
MEMBER
|
||||||
|
}
|
@ -9,7 +9,6 @@ import cn.wzpmc.configuration.Configuration;
|
|||||||
import cn.wzpmc.console.MyBotConsole;
|
import cn.wzpmc.console.MyBotConsole;
|
||||||
import cn.wzpmc.plugins.CommandManager;
|
import cn.wzpmc.plugins.CommandManager;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
|
||||||
@ -20,17 +19,20 @@ import lombok.extern.log4j.Log4j2;
|
|||||||
* @version 0.0.1-dev
|
* @version 0.0.1-dev
|
||||||
*/
|
*/
|
||||||
@Log4j2
|
@Log4j2
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Getter
|
@Getter
|
||||||
public class MyBot implements IBot {
|
public class MyBot extends IBot {
|
||||||
private final Configuration configuration;
|
private final Configuration configuration;
|
||||||
@Setter
|
@Setter
|
||||||
private Long id;
|
private Long id;
|
||||||
@Setter
|
@Setter
|
||||||
private Long name;
|
private String name;
|
||||||
private final CommandManager commandManager = new CommandManager(this);
|
private final CommandManager commandManager = new CommandManager(this);
|
||||||
@Setter
|
@Setter
|
||||||
private MyBotConsole console = null;
|
private MyBotConsole console = null;
|
||||||
|
public MyBot(Configuration configuration){
|
||||||
|
this.configuration = configuration;
|
||||||
|
this.permissions = Permissions.ADMIN;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(MessageComponent messageComponent) {
|
public void sendMessage(MessageComponent messageComponent) {
|
||||||
@ -42,11 +44,6 @@ public class MyBot implements IBot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Permissions getPermission() {
|
|
||||||
return Permissions.ADMIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
if (this.console != null) {
|
if (this.console != null) {
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
package cn.wzpmc.network;
|
package cn.wzpmc.network;
|
||||||
|
|
||||||
|
import cn.wzpmc.api.events.Event;
|
||||||
|
import cn.wzpmc.api.events.message.MessageEvent;
|
||||||
|
import cn.wzpmc.api.events.meta.MetaEvent;
|
||||||
|
import cn.wzpmc.api.events.notice.NoticeEvent;
|
||||||
|
import cn.wzpmc.api.events.notice.NoticeType;
|
||||||
|
import cn.wzpmc.api.events.notice.notify.NotifyEvent;
|
||||||
|
import cn.wzpmc.api.events.request.RequestEvent;
|
||||||
|
import cn.wzpmc.api.events.request.RequestEventType;
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.SimpleChannelInboundHandler;
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
||||||
@ -16,6 +25,38 @@ public class PacketHandler extends SimpleChannelInboundHandler<TextWebSocketFram
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void channelRead0(ChannelHandlerContext channelHandlerContext, TextWebSocketFrame webSocketFrame) {
|
protected void channelRead0(ChannelHandlerContext channelHandlerContext, TextWebSocketFrame webSocketFrame) {
|
||||||
log.info(webSocketFrame.text());
|
String text = webSocketFrame.text();
|
||||||
|
if (!JSON.isValidObject(text)){
|
||||||
|
log.warn("收到了无法处理的WebSocket数据包:{}", text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
System.out.println(text);
|
||||||
|
Event event = JSON.parseObject(text, Event.class);
|
||||||
|
Class<? extends Event> eventClass = switch (event.getPostType()) {
|
||||||
|
case NOTICE -> {
|
||||||
|
NoticeEvent noticeEvent = JSON.parseObject(text, NoticeEvent.class);
|
||||||
|
NoticeType noticeType = noticeEvent.getNoticeType();
|
||||||
|
if (NoticeType.NOTIFY.equals(noticeType)) {
|
||||||
|
NotifyEvent notifyEvent = JSON.parseObject(text, NotifyEvent.class);
|
||||||
|
yield notifyEvent.getSubType().clazz;
|
||||||
|
}
|
||||||
|
yield noticeType.clazz;
|
||||||
|
}
|
||||||
|
case MESSAGE -> {
|
||||||
|
MessageEvent<?, ?> messageEvent = JSON.parseObject(text, MessageEvent.class);
|
||||||
|
yield messageEvent.getMessageType().clazz;
|
||||||
|
}
|
||||||
|
case REQUEST -> {
|
||||||
|
RequestEvent requestEvent = JSON.parseObject(text, RequestEvent.class);
|
||||||
|
RequestEventType requestType = requestEvent.getRequestType();
|
||||||
|
yield requestType.clazz;
|
||||||
|
}
|
||||||
|
case META_EVENT -> {
|
||||||
|
MetaEvent metaEvent = JSON.parseObject(text, MetaEvent.class);
|
||||||
|
yield metaEvent.getMetaEventType().clazz;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Event event1 = JSON.parseObject(text, eventClass);
|
||||||
|
System.out.println(event1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user