-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #29 from simple-robot/dev/support-internal-events
Support `TelegramBotRegisteredEvent` and `TelegramBotStartedEvent`
- Loading branch information
Showing
5 changed files
with
130 additions
and
29 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
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
42 changes: 42 additions & 0 deletions
42
...ommonMain/kotlin/love/forte/simbot/component/telegram/core/event/TelegramInternalEvent.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,42 @@ | ||
/* | ||
* Copyright (c) 2024. ForteScarlet. | ||
* | ||
* This file is part of simbot-component-telegram. | ||
* | ||
* simbot-component-telegram 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-telegram 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-telegram. | ||
* If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package love.forte.simbot.component.telegram.core.event | ||
|
||
import love.forte.simbot.component.telegram.core.bot.TelegramBot | ||
import love.forte.simbot.event.BotRegisteredEvent | ||
|
||
|
||
/** | ||
* An event that indicating a [TelegramBot] has been registered. | ||
* | ||
* This is an event used as a notification | ||
* that the bot may not have been started yet. | ||
*/ | ||
public interface TelegramBotRegisteredEvent : BotRegisteredEvent, TelegramBotEvent { | ||
override val bot: TelegramBot | ||
} | ||
|
||
/** | ||
* An event that indicating a [TelegramBot] has been started at the first time. | ||
* | ||
* This is an event used as a notification. | ||
* At this point, [bot.isStarted][TelegramBot.isStarted] is already `true`. | ||
*/ | ||
public interface TelegramBotStartedEvent : BotRegisteredEvent, TelegramBotEvent { | ||
override val bot: TelegramBot | ||
} |
40 changes: 40 additions & 0 deletions
40
...in/love/forte/simbot/component/telegram/core/event/internal/TelegramInternalEventImpls.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,40 @@ | ||
/* | ||
* Copyright (c) 2024. ForteScarlet. | ||
* | ||
* This file is part of simbot-component-telegram. | ||
* | ||
* simbot-component-telegram 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-telegram 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-telegram. | ||
* If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package love.forte.simbot.component.telegram.core.event.internal | ||
|
||
import love.forte.simbot.annotations.ExperimentalSimbotAPI | ||
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.telegram.core.bot.TelegramBot | ||
import love.forte.simbot.component.telegram.core.event.TelegramBotRegisteredEvent | ||
import love.forte.simbot.component.telegram.core.event.TelegramBotStartedEvent | ||
|
||
internal class TelegramBotRegisteredEventImpl(override val bot: TelegramBot) : TelegramBotRegisteredEvent { | ||
override val id: ID = UUID.random() | ||
|
||
@OptIn(ExperimentalSimbotAPI::class) | ||
override val time: Timestamp = Timestamp.now() | ||
} | ||
|
||
internal class TelegramBotStartedEventImpl(override val bot: TelegramBot) : TelegramBotStartedEvent { | ||
override val id: ID = UUID.random() | ||
|
||
@OptIn(ExperimentalSimbotAPI::class) | ||
override val time: Timestamp = Timestamp.now() | ||
} |