mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-22 11:14:55 +08:00
add -t argument for test run
This commit is contained in:
parent
58cf4cc74b
commit
341d4cd851
@ -8,7 +8,7 @@ object MornyConfiguration {
|
|||||||
val MORNY_CODE_STORE = "https://github.com/Eyre-S/Coeur-Morny-Cono"
|
val MORNY_CODE_STORE = "https://github.com/Eyre-S/Coeur-Morny-Cono"
|
||||||
val MORNY_COMMIT_PATH = "https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s"
|
val MORNY_COMMIT_PATH = "https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s"
|
||||||
|
|
||||||
val VERSION = "2.0.0-alpha2"
|
val VERSION = "2.0.0-alpha3"
|
||||||
val VERSION_DELTA: Option[String] = None
|
val VERSION_DELTA: Option[String] = None
|
||||||
val CODENAME = "guanggu"
|
val CODENAME = "guanggu"
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package cc.sukazyo.cono.morny
|
|||||||
import cc.sukazyo.cono.morny.bot.command.MornyCommands
|
import cc.sukazyo.cono.morny.bot.command.MornyCommands
|
||||||
import cc.sukazyo.cono.morny.daemon.MornyDaemons
|
import cc.sukazyo.cono.morny.daemon.MornyDaemons
|
||||||
import cc.sukazyo.cono.morny.Log.{exceptionLog, logger}
|
import cc.sukazyo.cono.morny.Log.{exceptionLog, logger}
|
||||||
import cc.sukazyo.cono.morny.MornyCoeur.THREAD_SERVER_EXIT
|
import cc.sukazyo.cono.morny.MornyCoeur.{TestRun, THREAD_SERVER_EXIT}
|
||||||
import cc.sukazyo.cono.morny.bot.api.EventListenerManager
|
import cc.sukazyo.cono.morny.bot.api.EventListenerManager
|
||||||
import cc.sukazyo.cono.morny.bot.event.{MornyEventListeners, MornyOnInlineQuery, MornyOnTelegramCommand, MornyOnUpdateTimestampOffsetLock}
|
import cc.sukazyo.cono.morny.bot.event.{MornyEventListeners, MornyOnInlineQuery, MornyOnTelegramCommand, MornyOnUpdateTimestampOffsetLock}
|
||||||
import cc.sukazyo.cono.morny.bot.query.MornyQueries
|
import cc.sukazyo.cono.morny.bot.query.MornyQueries
|
||||||
@ -21,9 +21,11 @@ object MornyCoeur {
|
|||||||
|
|
||||||
val THREAD_SERVER_EXIT = "system-exit"
|
val THREAD_SERVER_EXIT = "system-exit"
|
||||||
|
|
||||||
|
object TestRun
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MornyCoeur (using val config: MornyConfig) {
|
class MornyCoeur (using val config: MornyConfig)(testRun: Boolean = false) {
|
||||||
|
|
||||||
given MornyCoeur = this
|
given MornyCoeur = this
|
||||||
|
|
||||||
@ -43,8 +45,6 @@ class MornyCoeur (using val config: MornyConfig) {
|
|||||||
System exit -1
|
System exit -1
|
||||||
throw RuntimeException()
|
throw RuntimeException()
|
||||||
|
|
||||||
configure_exitCleanup()
|
|
||||||
|
|
||||||
///<<< BLOCK END instance configure & startup stage 1
|
///<<< BLOCK END instance configure & startup stage 1
|
||||||
|
|
||||||
/** inner value: about why morny exit, used in [[daemon.MornyReport]]. */
|
/** inner value: about why morny exit, used in [[daemon.MornyReport]]. */
|
||||||
@ -94,6 +94,14 @@ class MornyCoeur (using val config: MornyConfig) {
|
|||||||
|
|
||||||
///>>> BLOCK START instance configure & startup stage 2
|
///>>> BLOCK START instance configure & startup stage 2
|
||||||
|
|
||||||
|
logger info "done initialize."
|
||||||
|
if testRun then
|
||||||
|
logger info "done test run, exiting."
|
||||||
|
this.exit(0, TestRun)
|
||||||
|
|
||||||
|
configure_exitCleanup()
|
||||||
|
// put things that need to cleanup when exit below
|
||||||
|
// so that it will be correctly cleanup when normal run and will not execute in testRun.
|
||||||
daemons.start()
|
daemons.start()
|
||||||
logger info "start telegram event listening"
|
logger info "start telegram event listening"
|
||||||
import com.pengrad.telegrambot.TelegramException
|
import com.pengrad.telegrambot.TelegramException
|
||||||
|
@ -21,6 +21,7 @@ object ServerMain {
|
|||||||
val config = new MornyConfig.Prototype()
|
val config = new MornyConfig.Prototype()
|
||||||
var mode_echoVersion = false
|
var mode_echoVersion = false
|
||||||
var mode_echoHello = false
|
var mode_echoHello = false
|
||||||
|
var mode_testRun = false
|
||||||
var showHello = true
|
var showHello = true
|
||||||
|
|
||||||
val unknownArgs = ArrayBuffer[String]()
|
val unknownArgs = ArrayBuffer[String]()
|
||||||
@ -31,6 +32,7 @@ object ServerMain {
|
|||||||
args(i) match {
|
args(i) match {
|
||||||
|
|
||||||
case "-d" | "--dbg" | "--debug" => Log.debug(true)
|
case "-d" | "--dbg" | "--debug" => Log.debug(true)
|
||||||
|
case "-t" | "--test" => mode_testRun = true
|
||||||
|
|
||||||
case "--no-hello" | "-hf" | "--quiet" | "-q" => showHello = false
|
case "--no-hello" | "-hf" | "--quiet" | "-q" => showHello = false
|
||||||
case "--only-hello" | "-ho" | "-o" | "-hi" => mode_echoHello = true
|
case "--only-hello" | "-ho" | "-o" | "-hi" => mode_echoHello = true
|
||||||
@ -156,7 +158,9 @@ object ServerMain {
|
|||||||
Thread.currentThread setName THREAD_MORNY_INIT
|
Thread.currentThread setName THREAD_MORNY_INIT
|
||||||
|
|
||||||
try
|
try
|
||||||
MornyCoeur(using config build)
|
MornyCoeur(using config build)(
|
||||||
|
testRun = mode_testRun
|
||||||
|
)
|
||||||
catch {
|
catch {
|
||||||
case _: CheckFailure.NullTelegramBotKey =>
|
case _: CheckFailure.NullTelegramBotKey =>
|
||||||
logger.info("Parameter required has no value:\n --token.")
|
logger.info("Parameter required has no value:\n --token.")
|
||||||
|
Loading…
Reference in New Issue
Block a user