-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from simple-robot/dev/support-meta-event
增加对Meta事件的组件事件类型实现;部分类型增加toString实现
- Loading branch information
Showing
9 changed files
with
161 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...ain/kotlin/love/forte/simbot/component/onebot/v11/core/event/internal/OneBotEventImpls.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2024. ForteScarlet. | ||
* | ||
* This file is part of simbot-component-onebot. | ||
* | ||
* simbot-component-onebot is free software: you can redistribute it and/or modify it under the terms | ||
* of the GNU Lesser General Public License as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* simbot-component-onebot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License along with simbot-component-onebot. | ||
* If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package love.forte.simbot.component.onebot.v11.core.event.internal | ||
|
||
import love.forte.simbot.component.onebot.v11.core.event.OneBotEvent | ||
|
||
internal fun OneBotEvent.eventToString( | ||
eventName: String | ||
): String = | ||
"$eventName(source=$sourceEvent, raw='$sourceEventRaw')" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...in/love/forte/simbot/component/onebot/v11/core/event/internal/meta/OneBotMetaEventImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) 2024. ForteScarlet. | ||
* | ||
* This file is part of simbot-component-onebot. | ||
* | ||
* simbot-component-onebot is free software: you can redistribute it and/or modify it under the terms | ||
* of the GNU Lesser General Public License as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* simbot-component-onebot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License along with simbot-component-onebot. | ||
* If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package love.forte.simbot.component.onebot.v11.core.event.internal.meta | ||
|
||
import love.forte.simbot.common.id.ID | ||
import love.forte.simbot.common.id.UUID | ||
import love.forte.simbot.common.time.Timestamp | ||
import love.forte.simbot.component.onebot.v11.core.bot.OneBotBot | ||
import love.forte.simbot.component.onebot.v11.core.event.internal.eventToString | ||
import love.forte.simbot.component.onebot.v11.core.event.meta.OneBotHeartbeatEvent | ||
import love.forte.simbot.component.onebot.v11.core.event.meta.OneBotLifecycleEvent | ||
import love.forte.simbot.component.onebot.v11.core.event.meta.OneBotMetaEvent | ||
import love.forte.simbot.component.onebot.v11.core.utils.timestamp | ||
import love.forte.simbot.component.onebot.v11.event.meta.HeartbeatEvent | ||
import love.forte.simbot.component.onebot.v11.event.meta.LifecycleEvent | ||
import love.forte.simbot.component.onebot.v11.event.meta.MetaEvent | ||
|
||
/** | ||
* OneBot中的元事件类型。 | ||
* @author ForteScarlet | ||
*/ | ||
internal abstract class OneBotMetaEventImpl : OneBotMetaEvent { | ||
override val id: ID = UUID.random() | ||
|
||
override val time: Timestamp | ||
get() = sourceEvent.timestamp() | ||
} | ||
|
||
internal class OneBotHeartbeatEventImpl( | ||
override val sourceEventRaw: String?, | ||
override val sourceEvent: HeartbeatEvent, | ||
override val bot: OneBotBot, | ||
) : OneBotHeartbeatEvent, OneBotMetaEventImpl() { | ||
override fun toString(): String = | ||
eventToString("OneBotHeartbeatEvent") | ||
} | ||
|
||
internal class OneBotLifecycleEventImpl( | ||
override val sourceEventRaw: String?, | ||
override val sourceEvent: LifecycleEvent, | ||
override val bot: OneBotBot, | ||
) : OneBotLifecycleEvent, OneBotMetaEventImpl() { | ||
override fun toString(): String = | ||
eventToString("OneBotLifecycleEvent") | ||
} | ||
|
||
internal class OneBotDefaultMetaEventImpl( | ||
override val sourceEventRaw: String?, | ||
override val sourceEvent: MetaEvent, | ||
override val bot: OneBotBot, | ||
) : OneBotMetaEventImpl() { | ||
override fun toString(): String = | ||
eventToString("OneBotDefaultMetaEvent") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters