Merge branch 'master' into 1.3.0

This commit is contained in:
A.C.Sukazyo Eyre 2023-11-08 18:33:42 +08:00
commit 89c414e853
Signed by: Eyre_S
GPG Key ID: C17CE40291207874
5 changed files with 25 additions and 16 deletions

View File

@ -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.3.0-feat/scheduler VERSION = 1.3.0-dev1
USE_DELTA = false USE_DELTA = false
VERSION_DELTA = VERSION_DELTA =

View File

@ -16,11 +16,11 @@ class InputCommand private (
object InputCommand { object InputCommand {
def apply (input: Array[String]): InputCommand = { def apply (input: Array[String]): InputCommand = {
val _ex = input(0) split ("@", 2) val _ex = if input.nonEmpty then input(0) split ("@", 2) else Array.empty[String]
val _args = input drop 1 val _args = input drop 1
new InputCommand( new InputCommand(
if _ex.length == 1 then null else _ex(1), if _ex.length > 1 then _ex(1) else null,
_ex(0), if _ex.nonEmpty then _ex(0) else "",
_args _args
) )
} }

View File

@ -9,7 +9,7 @@ import scala.util.matching.Regex
object TelegramUserInformation { object TelegramUserInformation {
private val DC_QUERY_PROCESSOR_REGEX: Regex = "(cdn[1-9]).tele(sco.pe|gram-cdn.org)"r private val DC_QUERY_PROCESSOR_REGEX: Regex = "(cdn[1-9]).(telesco\\.pe|telegram-cdn\\.org|cdn-telegram\\.org)"r
private val httpClient = OkHttpSyncBackend() private val httpClient = OkHttpSyncBackend()

View File

@ -88,7 +88,6 @@ class UniversalCommandTest extends MornyTests with Matchers with TableDrivenProp
Lmd("something error!\\") shouldEqual Array("something", "error!\\") Lmd("something error!\\") shouldEqual Array("something", "error!\\")
} }
"with multi-line input" - { "with multi-line input" - {
whileStrict("should throws IllegalArgumentException") in: whileStrict("should throws IllegalArgumentException") in:
an [IllegalArgumentException] should be thrownBy Cmd("something will\nhave a new line") an [IllegalArgumentException] should be thrownBy Cmd("something will\nhave a new line")
@ -96,6 +95,10 @@ class UniversalCommandTest extends MornyTests with Matchers with TableDrivenProp
Lmd("something will\nhave a new line") shouldEqual Array("something", "will\nhave", "a", "new", "line") Lmd("something will\nhave a new line") shouldEqual Array("something", "will\nhave", "a", "new", "line")
} }
"empty string input should return empty array" in {
Cmd("") shouldEqual Array.empty[String]
Lmd("") shouldEqual Array.empty[String]
}
val example_special_character = Table( val example_special_character = Table(
"char", "char",

View File

@ -16,35 +16,41 @@ class InputCommandTest extends MornyTests with TableDrivenPropertyChecks {
"args" "args"
), ),
( (
"/exit@sukazyo_deving_bot", "exit@sukazyo_deving_bot",
"/exit", "exit",
"sukazyo_deving_bot", "sukazyo_deving_bot",
Array.empty[String] Array.empty[String]
), ),
( (
"/test@a@b", "test@a@b",
"/test", "test",
"a@b", "a@b",
Array.empty[String] Array.empty[String]
), ),
( (
"/test-data@random#user", "test-data@random#user",
"/test-data", "test-data",
"random#user", "random#user",
Array.empty[String] Array.empty[String]
), ),
( (
"/info@sukazyo_deving_bot stickers.ID_403", "info@sukazyo_deving_bot stickers.ID_403",
"/info", "info",
"sukazyo_deving_bot", "sukazyo_deving_bot",
Array("stickers.ID_403") Array("stickers.ID_403")
), ),
( (
"/info some extra info", "info some extra info",
"/info", "info",
null, null,
Array("some", "extra", "info") Array("some", "extra", "info")
), ),
(
"",
"",
null,
Array.empty[String]
)
) )
examples forEvery { (source, command, target, args) => examples forEvery { (source, command, target, args) =>