Skip to content

Commit

Permalink
fix: SourceHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
cssxsh committed Jun 2, 2022
1 parent 67523d5 commit 20902ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/main/kotlin/xyz/cssxsh/mirai/admin/MiraiService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ internal fun ComparableService.Loader.render(): String = buildString {
}

@Deprecated("接口定义不明确", ReplaceWith("null"))
internal fun source(contact: Contact?, event: MessageEvent?): MessageSource? = null
internal fun source(contact: Contact?, event: MessageEvent?): MessageSource? {
logger.error { "xyz.cssxsh.mirai.admin.source 方法已废弃" }
return null
}

internal fun target(contact: Contact): MessageSource? {
for (handler in ComparableService<MessageSourceHandler>()) {
Expand Down
14 changes: 9 additions & 5 deletions src/main/kotlin/xyz/cssxsh/mirai/spi/MessageSourceHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ public interface MessageSourceHandler : ComparableService {

/**
* 根据指定参数 获取 最后的 [MessageSource]
* @param contact 指定的用户
* @param event 触发操作的事件,用于获取相关信息
* @see target
* @see from
* @see quote
*/
@Deprecated("接口定义不明确", ReplaceWith("null"))
public fun find(contact: Contact?, event: MessageEvent?): MessageSource? = null
Expand All @@ -21,17 +22,20 @@ public interface MessageSourceHandler : ComparableService {
* 根据 曾发送消息的目标 获取 最后的 [MessageSource]
* @param contact 机器人曾发送消息的目标
*/
public fun target(contact: Contact): MessageSource?
@Suppress("DEPRECATION")
public fun target(contact: Contact): MessageSource? = find(contact = contact, event = null)

/**
* 根据 曾发送消息的群员 获取 最后的 [MessageSource]
* @param member 曾发送消息的群员
*/
public fun from(member: Member): MessageSource?
@Suppress("DEPRECATION")
public fun from(member: Member): MessageSource? = find(contact = member, event = null)

/**
* 根据 消息事件 获取 最后的 [MessageSource]
* @param event 曾收到的的消息事件
*/
public fun quote(event: MessageEvent): MessageSource?
@Suppress("DEPRECATION")
public fun quote(event: MessageEvent): MessageSource? = find(contact = null, event = event)
}

0 comments on commit 20902ff

Please sign in to comment.