UnknownEvent

class UnknownEvent @InternalOneBotAPI constructor(val time: Long, val selfId: LongID, val postType: String, val raw: String, val rawJson: JsonObject, val reason: Throwable? = null) : RawEvent(source)

用于“兜底”的 RawEvent 类型实现。 当出现了尚未支持或某种未知的事件体,无法对应到任何现有的已定义结构时, 则应当将其解析并包装为 UnknownEvent。

UnknownEvent 要求事件体必须包括 time, selfId 和 postType。

如果 UnknownEvent 是由于某些异常而产生(例如原本事件进行序列化但是失败了), 那么失败的原因则会通过 reason 提供。

内部构造

UnknownEvent 应当始终由内部使用、构造, 不要在其他地方自行构造 UnknownEvent, 它的构造函数不保证任何源码或二进制兼容。

FragileAPI

这是一个具有特殊规则的事件类型。 随着版本地更新,UnknownEvent 中可能出现的事件类型会越来越少。 因此此类型只适用于“兜底”,不应过度依赖。

Author

ForteScarlet

Constructors

Link copied to clipboard
constructor(time: Long, selfId: LongID, postType: String, raw: String, rawJson: JsonObject, reason: Throwable? = null)

Properties

Link copied to clipboard
open override val postType: String

事件类型

Link copied to clipboard
val raw: String

原始的JSON字符串, 也是判断 UnknownEvent 之间是否相同的唯一依据。

Link copied to clipboard

raw 对应解析的 JsonObject 对象。

Link copied to clipboard

如果是由于异常而产生,则此处为异常的原因。 通常会是 SerializationException。

Link copied to clipboard
open override val selfId: LongID

收到事件的机器人 QQ 号

Link copied to clipboard
open override val time: Long

事件发生的时间戳

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String