mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2025-04-29 09:32:04 +08:00
OnQuestionMarkReply will not work when got an expired event
This commit is contained in:
parent
1b95b0a917
commit
2b2b93ddaa
@ -5,7 +5,7 @@ MORNY_ARCHIVE_NAME = morny-coeur
|
|||||||
MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono
|
MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono
|
||||||
MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s
|
MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s
|
||||||
|
|
||||||
VERSION = 1.5.0-alpha.2
|
VERSION = 1.5.0-alpha.3
|
||||||
|
|
||||||
USE_DELTA = false
|
USE_DELTA = false
|
||||||
VERSION_DELTA =
|
VERSION_DELTA =
|
||||||
|
@ -2,10 +2,12 @@ package cc.sukazyo.cono.morny.bot.event
|
|||||||
|
|
||||||
import cc.sukazyo.cono.morny.bot.api.{EventEnv, EventListener}
|
import cc.sukazyo.cono.morny.bot.api.{EventEnv, EventListener}
|
||||||
import cc.sukazyo.cono.morny.MornyCoeur
|
import cc.sukazyo.cono.morny.MornyCoeur
|
||||||
|
import cc.sukazyo.cono.morny.bot.event.MornyOnUpdateTimestampOffsetLock.ExpiredEvent
|
||||||
|
|
||||||
class MornyOnUpdateTimestampOffsetLock (using coeur: MornyCoeur) extends EventListener {
|
class MornyOnUpdateTimestampOffsetLock (using coeur: MornyCoeur) extends EventListener {
|
||||||
|
|
||||||
private def checkOutdated (timestamp: Int)(using event: EventEnv): Unit =
|
private def checkOutdated (timestamp: Int)(using event: EventEnv): Unit =
|
||||||
|
event.provide(ExpiredEvent)
|
||||||
if coeur.config.eventIgnoreOutdated && (timestamp < (coeur.coeurStartTimestamp/1000)) then
|
if coeur.config.eventIgnoreOutdated && (timestamp < (coeur.coeurStartTimestamp/1000)) then
|
||||||
event.setEventCanceled
|
event.setEventCanceled
|
||||||
|
|
||||||
@ -15,3 +17,7 @@ class MornyOnUpdateTimestampOffsetLock (using coeur: MornyCoeur) extends EventLi
|
|||||||
override def onEditedChannelPost (using event: EventEnv): Unit = checkOutdated(event.update.editedChannelPost.date)
|
override def onEditedChannelPost (using event: EventEnv): Unit = checkOutdated(event.update.editedChannelPost.date)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object MornyOnUpdateTimestampOffsetLock {
|
||||||
|
object ExpiredEvent
|
||||||
|
}
|
||||||
|
@ -5,6 +5,7 @@ import cc.sukazyo.cono.morny.MornyCoeur
|
|||||||
import cc.sukazyo.cono.morny.util.tgapi.InputCommand
|
import cc.sukazyo.cono.morny.util.tgapi.InputCommand
|
||||||
import com.pengrad.telegrambot.model.Chat
|
import com.pengrad.telegrambot.model.Chat
|
||||||
|
|
||||||
|
// fixme: not tested yet
|
||||||
class OnOnAlias (using coeur: MornyCoeur) extends EventListener {
|
class OnOnAlias (using coeur: MornyCoeur) extends EventListener {
|
||||||
|
|
||||||
override def onMessage (using event: EventEnv): Unit = {
|
override def onMessage (using event: EventEnv): Unit = {
|
||||||
|
@ -4,6 +4,7 @@ import cc.sukazyo.cono.morny.bot.api.{EventEnv, EventListener}
|
|||||||
import cc.sukazyo.cono.morny.MornyCoeur
|
import cc.sukazyo.cono.morny.MornyCoeur
|
||||||
import cc.sukazyo.cono.morny.bot.event.OnQuestionMarkReply.isAllMessageMark
|
import cc.sukazyo.cono.morny.bot.event.OnQuestionMarkReply.isAllMessageMark
|
||||||
import cc.sukazyo.cono.morny.util.tgapi.TelegramExtensions.Bot.exec
|
import cc.sukazyo.cono.morny.util.tgapi.TelegramExtensions.Bot.exec
|
||||||
|
import cc.sukazyo.cono.morny.Log.logger
|
||||||
import com.pengrad.telegrambot.request.{ForwardMessage, SendMessage}
|
import com.pengrad.telegrambot.request.{ForwardMessage, SendMessage}
|
||||||
|
|
||||||
import scala.language.postfixOps
|
import scala.language.postfixOps
|
||||||
@ -14,6 +15,19 @@ class OnQuestionMarkReply (using coeur: MornyCoeur) extends EventListener {
|
|||||||
override def onMessage (using event: EventEnv): Unit = {
|
override def onMessage (using event: EventEnv): Unit = {
|
||||||
import event.update
|
import event.update
|
||||||
|
|
||||||
|
// FIXME: not tested yet, due to cannot connect to test bot
|
||||||
|
if boundary[Boolean] {
|
||||||
|
event.consume[MornyOnUpdateTimestampOffsetLock.ExpiredEvent.type] { _ =>
|
||||||
|
boundary.break(true)
|
||||||
|
}
|
||||||
|
false
|
||||||
|
} then {
|
||||||
|
logger.debug("OnQuestionMarkReply: expired event, skipped")
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
logger.debug("OnQuestionMarkReply: event continue")
|
||||||
|
}
|
||||||
|
|
||||||
if update.message.text eq null then return
|
if update.message.text eq null then return
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.util.UseMath.over
|
import cc.sukazyo.cono.morny.util.UseMath.over
|
||||||
|
Loading…
Reference in New Issue
Block a user