Skip to content

Commit

Permalink
feat: add interceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
RTAkland committed Nov 19, 2024
1 parent 2cc7e59 commit 46194e7
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package cn.rtast.rob.qqbot.entity.inbound

import cn.rtast.rob.annotations.ExcludeField
import cn.rtast.rob.entity.IPrivateMessage
import cn.rtast.rob.qqbot.actionable.C2CMessageActionable
import cn.rtast.rob.qqbot.entity.Keyboard
import cn.rtast.rob.qqbot.entity.Markdown
Expand All @@ -19,7 +20,7 @@ import com.google.gson.annotations.SerializedName
data class C2CMessageCreateEvent(
val id: String,
val d: MessageBody
) : C2CMessageActionable {
) : C2CMessageActionable, IPrivateMessage {
override suspend fun reply(message: String) {
d.action.sendPrivatePlainTextMessage(d.author.unionOpenId, message, id, d.id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package cn.rtast.rob.qqbot.entity.inbound

import cn.rtast.rob.annotations.ExcludeField
import cn.rtast.rob.entity.IGroupMessage
import cn.rtast.rob.qqbot.actionable.GroupMessageActionable
import cn.rtast.rob.qqbot.entity.Keyboard
import cn.rtast.rob.qqbot.entity.Markdown
Expand All @@ -17,7 +18,7 @@ import com.google.gson.annotations.SerializedName
data class GroupAtMessageCreateEvent(
val id: String,
val d: MessageBody
) : GroupMessageActionable {
) : GroupMessageActionable, IGroupMessage {
override suspend fun reply(message: String) {
d.action.sendGroupPlainTextMessage(d.groupOpenId, message, id, d.id)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright © 2024 RTAkland
* Author: RTAkland
* Date: 2024/11/19
*/

@file:Suppress("unused")

package cn.rtast.rob.qqbot.interceptor

import cn.rtast.rob.interceptor.IExecutionInterceptor
import cn.rtast.rob.qqbot.entity.inbound.C2CMessageCreateEvent
import cn.rtast.rob.qqbot.entity.inbound.GroupAtMessageCreateEvent
import cn.rtast.rob.qqbot.util.BaseCommand

abstract class ExecutionInterceptor :
IExecutionInterceptor<BaseCommand, GroupAtMessageCreateEvent, C2CMessageCreateEvent>

internal val defaultInterceptor = object : ExecutionInterceptor() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright © 2024 RTAkland
* Author: RTAkland
* Date: 2024/11/19
*/

@file:Suppress("unused")

package cn.rtast.rob.qqbot.util

import cn.rtast.rob.entity.IBaseCommand

/**
* 指令类
*/
abstract class BaseCommand : IBaseCommand {
}

0 comments on commit 46194e7

Please sign in to comment.