diff --git a/build.sbt b/build.sbt index 2146b44..c33f138 100644 --- a/build.sbt +++ b/build.sbt @@ -55,6 +55,7 @@ lazy val root = (project in file(".")) "-source", "17", "-target", "17" ), + autoAPIMappings := true, assemblyMergeStrategy := { case module if module endsWith "module-info.class" => MergeStrategy.concat diff --git a/project/MornyConfiguration.scala b/project/MornyConfiguration.scala index 392e91a..bdfd34d 100644 --- a/project/MornyConfiguration.scala +++ b/project/MornyConfiguration.scala @@ -8,7 +8,7 @@ object MornyConfiguration { 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 VERSION = "2.0.0-alpha1.1" + val VERSION = "2.0.0-alpha2" val VERSION_DELTA: Option[String] = None val CODENAME = "guanggu" @@ -42,6 +42,9 @@ object MornyConfiguration { "org.scalatest" %% "scalatest" % "3.2.17" % Test, "org.scalatest" %% "scalatest-freespec" % "3.2.17" % Test, + // for test report + "com.vladsch.flexmark" % "flexmark" % "0.64.0" % Test, + "com.vladsch.flexmark" % "flexmark-profile-pegdown" % "0.64.0" % Test ) diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/DirectMsgClear.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/DirectMsgClear.scala index 032482b..cb49df2 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/DirectMsgClear.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/DirectMsgClear.scala @@ -13,7 +13,7 @@ import scala.language.postfixOps class DirectMsgClear (using coeur: MornyCoeur) extends ISimpleCommand { override val name: String = "r" - override val aliases: Array[ICommandAlias] | Null = null + override val aliases: List[ICommandAlias] = Nil override def execute (using command: InputCommand, event: Update): Unit = { diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/Encryptor.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/Encryptor.scala index 080466e..243f62c 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/Encryptor.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/Encryptor.scala @@ -22,7 +22,7 @@ import scala.language.postfixOps class Encryptor (using coeur: MornyCoeur) extends ITelegramCommand { override val name: String = "encrypt" - override val aliases: Array[ICommandAlias] | Null = Array(ListedAlias("enc")) + override val aliases: List[ICommandAlias] = ListedAlias("enc") :: Nil override val paramRule: String = "[algorithm|(l)] [(uppercase)]" override val description: String = "通过指定算法加密回复的内容 (目前只支持文本)" diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/EventHack.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/EventHack.scala index 03211e8..0cc63fc 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/EventHack.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/EventHack.scala @@ -11,7 +11,7 @@ import scala.language.postfixOps class EventHack (using coeur: MornyCoeur) extends ITelegramCommand { override val name: String = "event_hack" - override val aliases: Array[ICommandAlias] | Null = null + override val aliases: List[ICommandAlias] = Nil override val paramRule: String = "[(user|group|any)]" override val description: String = "输出 bot 下一个获取到的事件序列化数据" diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/GetSocial.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/GetSocial.scala index f8bfc58..b69c49d 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/GetSocial.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/GetSocial.scala @@ -10,7 +10,7 @@ import com.pengrad.telegrambot.request.SendSticker class GetSocial (using coeur: MornyCoeur) extends ITelegramCommand { override val name: String = "get" - override val aliases: Array[ICommandAlias] | Null = null + override val aliases: List[ICommandAlias] = Nil override val paramRule: String = "" override val description: String = "从社交媒体分享链接获取其内容" diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/GetUsernameAndId.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/GetUsernameAndId.scala index a960c07..4e2c435 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/GetUsernameAndId.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/GetUsernameAndId.scala @@ -13,7 +13,7 @@ import scala.language.postfixOps class GetUsernameAndId (using coeur: MornyCoeur) extends ITelegramCommand { override val name: String = "user" - override val aliases: Array[ICommandAlias] | Null = null + override val aliases: List[ICommandAlias] = Nil override val paramRule: String = "[userid]" override val description: String = "获取指定或回复的用户相关信息" diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/IP186Query.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/IP186Query.scala index 2b5795d..47a3fe7 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/IP186Query.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/IP186Query.scala @@ -18,13 +18,13 @@ class IP186Query (using coeur: MornyCoeur) { object IP extends ITelegramCommand: override val name: String = "ip" - override val aliases: Array[ICommandAlias]|Null = null + override val aliases: List[ICommandAlias] = Nil override val paramRule: String = "[ip]" override val description: String = "通过 https://ip.186526.xyz 查询 ip 资料" override def execute (using command: InputCommand, event: Update): Unit = query object Whois extends ITelegramCommand: override val name: String = "whois" - override val aliases: Array[ICommandAlias]|Null = null + override val aliases: List[ICommandAlias] = Nil override val paramRule: String = "[domain]" override val description: String = "通过 https://ip.186526.xyz 查询域名资料" override def execute (using command: InputCommand, event: Update): Unit = query diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/ISimpleCommand.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/ISimpleCommand.scala index 24c624f..dcd5d91 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/ISimpleCommand.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/ISimpleCommand.scala @@ -25,9 +25,9 @@ trait ISimpleCommand { * the unique identifier, it uses the same namespace with [[name]], means * it also cannot be duplicate with other [[name]] or [[aliases]]. * - * It can be [[Null]], means no aliases. + * It should not be [[Null]], using [[Nil]] instead for no aliases. */ - val aliases: Array[ICommandAlias]|Null + val aliases: List[ICommandAlias] /** The work code of this command. * diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyCommands.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyCommands.scala index d46b48a..3f44ff2 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyCommands.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyCommands.scala @@ -19,7 +19,7 @@ class MornyCommands (using coeur: MornyCoeur) { val stash = mutable.SeqMap.empty[String, ISimpleCommand] for (i <- commands) stash += (i.name -> i) - if (i.aliases ne null) for (alias <- i.aliases) + for (alias <- i.aliases) stash += (alias.name -> i) stash @@ -122,7 +122,7 @@ class MornyCommands (using coeur: MornyCoeur) { BotCommand(name, if paramRule isBlank then intro else s"$paramRule - $intro") val list = mutable.ArrayBuffer[BotCommand]( buildOne(command.name, command.paramRule, command.description)) - if (command.aliases ne null) for (alias <- command.aliases) + for (alias <- command.aliases) if (alias.listed) list += buildOne(alias.name, "", "↑") list toArray diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyHellos.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyHellos.scala index 34d8943..ebf5518 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyHellos.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyHellos.scala @@ -14,7 +14,7 @@ class MornyHellos (using coeur: MornyCoeur) { object On extends ITelegramCommand { override val name: String = "on" - override val aliases: Array[ICommandAlias] | Null = null + override val aliases: List[ICommandAlias] = Nil override val paramRule: String = "" override val description: String = "检查是否在线" @@ -29,7 +29,7 @@ class MornyHellos (using coeur: MornyCoeur) { object Hello extends ITelegramCommand { override val name: String = "hello" - override val aliases: Array[ICommandAlias] | Null = Array(ListedAlias("hi")) + override val aliases: List[ICommandAlias] = ListedAlias("hi") :: Nil override val paramRule: String = "" override val description: String = "打招呼" diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyInfoOnStart.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyInfoOnStart.scala index db0bd7e..c9f55e2 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyInfoOnStart.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyInfoOnStart.scala @@ -13,7 +13,7 @@ import scala.language.postfixOps class MornyInfoOnStart (using coeur: MornyCoeur) extends ISimpleCommand { override val name: String = "start" - override val aliases: Array[ICommandAlias] | Null = null + override val aliases: List[ICommandAlias] = Nil override def execute (using command: InputCommand, event: Update): Unit = { diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyInformation.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyInformation.scala index c331c1c..fb683ad 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyInformation.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyInformation.scala @@ -27,7 +27,7 @@ class MornyInformation (using coeur: MornyCoeur) extends ITelegramCommand { } override val name: String = "info" - override val aliases: Array[ICommandAlias]|Null = null + override val aliases: List[ICommandAlias] = Nil override val paramRule: String = "[(version|runtime|stickers[.IDs]|tasks|event)]" override val description: String = "输出当前 Morny 的各种信息" diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyInformationOlds.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyInformationOlds.scala index 60f94ec..3521b6e 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyInformationOlds.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyInformationOlds.scala @@ -7,12 +7,12 @@ class MornyInformationOlds (using base: MornyInformation) { object Version extends ISimpleCommand: override val name: String = "version" - override val aliases: Array[ICommandAlias] | Null = null + override val aliases: List[ICommandAlias] = Nil override def execute (using command: InputCommand, event: Update): Unit = base.echoVersion object Runtime extends ISimpleCommand: override val name: String = "runtime" - override val aliases: Array[ICommandAlias] | Null = null + override val aliases: List[ICommandAlias] = Nil override def execute (using command: InputCommand, event: Update): Unit = base.echoRuntime } diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyManagers.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyManagers.scala index aea4127..2dc8f60 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyManagers.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyManagers.scala @@ -17,7 +17,7 @@ class MornyManagers (using coeur: MornyCoeur) { object Exit extends ITelegramCommand { override val name: String = "exit" - override val aliases: Array[ICommandAlias] | Null = Array(HiddenAlias("stop"), HiddenAlias("quit")) + override val aliases: List[ICommandAlias] = HiddenAlias("stop") :: HiddenAlias("quit") :: Nil override val paramRule: String = "exit" override val description: String = "关闭 Bot (仅可信成员)" @@ -52,7 +52,7 @@ class MornyManagers (using coeur: MornyCoeur) { object SaveData extends ITelegramCommand { override val name: String = "save" - override val aliases: Array[ICommandAlias] | Null = null + override val aliases: List[ICommandAlias] = Nil override val paramRule: String = "" override val description: String = "保存缓存数据到文件(仅可信成员)" diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyOldJrrp.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyOldJrrp.scala index 2d44bff..7e09ef4 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyOldJrrp.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/MornyOldJrrp.scala @@ -11,7 +11,7 @@ import com.pengrad.telegrambot.request.SendMessage class MornyOldJrrp (using coeur: MornyCoeur) extends ITelegramCommand { override val name: String = "jrrp" - override val aliases: Array[ICommandAlias] | Null = null + override val aliases: List[ICommandAlias] = Nil override val paramRule: String = "" override val description: String = "获取 (假的) jrrp" diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/Nbnhhsh.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/Nbnhhsh.scala index c05714b..f988b6a 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/Nbnhhsh.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/Nbnhhsh.scala @@ -21,7 +21,7 @@ class Nbnhhsh (using coeur: MornyCoeur) extends ITelegramCommand { "## Result of nbnhhsh query :" override val name: String = "nbnhhsh" - override val aliases: Array[ICommandAlias]|Null = null + override val aliases: List[ICommandAlias] = Nil override val paramRule: String = "[text]" override val description: String = "检索文本内 nbnhhsh 词条" diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/Testing.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/Testing.scala index 949fa83..1ea3b6a 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/Testing.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/Testing.scala @@ -12,7 +12,7 @@ import scala.language.postfixOps class Testing (using coeur: MornyCoeur) extends ISimpleCommand { override val name: String = "test" - override val aliases: Array[ICommandAlias] | Null = null + override val aliases: List[ICommandAlias] = Nil override def execute (using command: InputCommand, event: Update): Unit = { diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/创.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/创.scala index f2a523e..d32c87a 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/创.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/创.scala @@ -1,11 +1,10 @@ package cc.sukazyo.cono.morny.bot.command import cc.sukazyo.cono.morny.MornyCoeur -import cc.sukazyo.cono.morny.data.TelegramStickers import cc.sukazyo.cono.morny.util.tgapi.InputCommand import cc.sukazyo.cono.morny.util.tgapi.TelegramExtensions.Bot.* import com.pengrad.telegrambot.model.{MessageEntity, Update} -import com.pengrad.telegrambot.request.{SendMessage, SendSticker} +import com.pengrad.telegrambot.request.SendMessage //noinspection NonAsciiCharacters class 创 (using coeur: MornyCoeur) { @@ -13,7 +12,7 @@ class 创 (using coeur: MornyCoeur) { object Chuang extends ISimpleCommand { override val name: String = "chuang" - override val aliases: Array[ICommandAlias] | Null = null + override val aliases: List[ICommandAlias] = Nil override def execute (using command: InputCommand, event: Update): Unit = { diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/喵呜.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/喵呜.scala index 996ab79..9c877f7 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/喵呜.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/喵呜.scala @@ -17,35 +17,35 @@ class 喵呜 (using coeur: MornyCoeur) { object 抱抱 extends ISimpleCommand { override val name: String = "抱抱" - override val aliases: Array[ICommandAlias]|Null = null + override val aliases: List[ICommandAlias] = Nil override def execute (using command: InputCommand, event: Update): Unit = replyingSet("贴贴", "贴贴") } object 揉揉 extends ISimpleCommand { override val name: String = "揉揉" - override val aliases: Array[ICommandAlias]|Null = null + override val aliases: List[ICommandAlias] = Nil override def execute (using command: InputCommand, event: Update): Unit = replyingSet("蹭蹭", "摸摸") } object 蹭蹭 extends ISimpleCommand { override val name: String = "蹭蹭" - override val aliases: Array[ICommandAlias]|Null = null + override val aliases: List[ICommandAlias] = Nil override def execute (using command: InputCommand, event: Update): Unit = replyingSet("揉揉", "蹭蹭") } object 贴贴 extends ISimpleCommand { override val name: String = "贴贴" - override val aliases: Array[ICommandAlias]|Null = null + override val aliases: List[ICommandAlias] = Nil override def execute (using command: InputCommand, event: Update): Unit = replyingSet("贴贴", "贴贴") } object Progynova extends ITelegramCommand { override val name: String = "install" - override val aliases: Array[ICommandAlias]|Null = null + override val aliases: List[ICommandAlias] = Nil override val paramRule: String = "" override val description: String = "抽取一个神秘盒子" override def execute (using command: InputCommand, event: Update): Unit = { diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/command/私わね.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/command/私わね.scala index 0980f68..52cd803 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/bot/command/私わね.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/bot/command/私わね.scala @@ -12,7 +12,7 @@ import com.pengrad.telegrambot.request.SendMessage class 私わね (using coeur: MornyCoeur) extends ISimpleCommand { override val name: String = "me" - override val aliases: Array[ICommandAlias] | Null = null + override val aliases: List[ICommandAlias] = Nil override def execute (using command: InputCommand, event: Update): Unit = {