Skip to content

Commit

Permalink
[[[release 1.0.0*beiping]]]
Browse files Browse the repository at this point in the history
## 📇 Function & Mechanisms

- new /info command
  - root /info command with new introduction page design
  - /start command with new design like new /info
  - /version and /runtime merged to /info
    - old command still available though been hidden
- new "/x?" in random tools
- new function: reply ? for a ?

## 🔌 for Trusted/Admin

- new MornyReport report exceptions or startup/exit events to telegram chat
- cha *msg supported body-less send check

## 🔩 for self-hosted/developer

- Project port to Scala
- add Dockerfile & docker-compose.yml
- add param for Medication Timer
  - param: --medication-notify-chat / -medc
  - param:--medication-notify-timezone / -medtz
  - param: --medication-notify-times / -medt
- cha unset default params (--master ect. is -1 as default)
  - add ID_501 as Morny function return while not supported by provided master

## 🧯 Bug Fix

- fix unclosed quote will cause exceptions while parsing command.
- fix some hidden command cannot execute due to no support to non-ascii command name. (also changed its behavor while I won't tell too much here)
- fix error while converting millisecond to nanosecond in Medication Timer
- inline query ShareBilibiliVideo now will not receive illegal av/BV id which can cause exceptions.
- /nbnhhsh will now send 404 when there's no input text.
- fix --trusted-chat -1 will caused MornyTrusted throws exception, now it will judge(ignore) the value as design.
- fixed --report-to -1 not process normally
- added missing --dinner-chat startup param.
- Some minor fixes while porting coeur to scala is not listed.
  • Loading branch information
Eyre-S committed Oct 9, 2023
2 parents 3661cb1 + 45a85e1 commit 49bbc03
Show file tree
Hide file tree
Showing 181 changed files with 5,991 additions and 4,984 deletions.
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

# IDE
.idea/
.vscode/
.gradle/
.settings/

#build
/build/
/bin/
.metals/
.bloop/
.project
lcoal.properties

# debug dir
/run/
928 changes: 920 additions & 8 deletions .editorconfig

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
.vscode/
.gradle/
.settings/
/src/test/java/test/*
/src/test/resources/test/*

#build
/build/
/bin/
/out/
.metals/
.bloop/
.project
lcoal.properties

# debug dir
/run/
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM eclipse-temurin:20-jdk as build
LABEL authors="A.C.Sukazyo Eyre"

COPY . /app/source/
WORKDIR /app

RUN cd ./source \
&& ./gradlew shadowJar -PdockerBuild \
&& cd .. \
&& cp ./source/build/libs/morny-coeur-docker-build.jar ./morny-coeur.jar
#&& rm -r ./source \
#&& rm -r /root/.gradle \


FROM eclipse-temurin:20-jre

COPY --from=build /app/morny-coeur.jar /app/morny-coeur.jar
WORKDIR /app

ENTRYPOINT ["java", "-jar", "morny-coeur.jar"]
CMD ["-q", "-v"]
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
[todo]: https://github.com/users/Eyre-S/projects/1
[artifact]: https://mvn.sukazyo.cc/#/releases/cc/sukazyo/morny-coeur

[tg4j]: https://github.com/pengrad/java-telegram-bot-api
[scala]: https://www.scala-lang.org/
[spotbugs]: https://spotbugs.github.io/
[junit5]: https://junit.org/junit5/
[tg4j]: https://github.com/pengrad/java-telegram-bot-api
[okhttp]: https://square.github.io/okhttp/
[gson]: https://github.com/google/gson
[scalatest]: https://scalatest.org/

<div align=center>

# ~~给所有喜欢morny的大家的~~ Morny Coeur 源代码

~~"你们又有意见又不发issue这样子我很为难的啊"~~
~~"and nobody cares."~~

![social preview card]([email protected])

一个 telegram 上的服侍 A.C.Sukazyo Eyre 和它的花宫成员的 bot 的内核源
一个 telegram 上的服侍 A.C.Sukazyo Eyre 和它的花宫成员的 bot 内核

[Task Listing][todo] | [~~BBS~~][issues] | [Published][artifact]

Expand All @@ -32,6 +35,9 @@

[Java Telegram Bot API][tg4j]

[SpotBugs Annotations][spotbugs] | [JUnit 5][junit5]

[okhttp] | [Gson][gson]

[Scala][scala] | [SpotBugs Annotations][spotbugs] | [ScalaTest][scalatest]

</div>
1 change: 0 additions & 1 deletion _book
Submodule _book deleted from 3072bc
216 changes: 164 additions & 52 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,72 @@
plugins {
id 'java'
id 'scala'
id 'java-library'
id 'maven-publish'
id 'application'
id 'com.github.johnrengelman.shadow' version '7.1.0'
id 'maven-publish'
id "io.github.ysohda.scalatest" version "0.32.1"
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.github.gmazzo.buildconfig' version '4.1.2'
id 'org.ajoberstar.grgit' version '5.2.0'
}

group 'cc.sukazyo'
version VERSION
project.ext.archiveBaseName = 'Coeur_Morny_Cono'
project.ext.artifactId = 'morny-coeur'
mainClassName = 'cc.sukazyo.cono.morny.ServerMain'
import org.ajoberstar.grgit.Status

import java.nio.charset.Charset
import java.nio.charset.StandardCharsets

final boolean proj_git = grgit!=null
final String proj_store = MORNY_CODE_STORE
final String proj_commit = proj_git ? grgit.head().id : null
final String proj_commit_path = MORNY_COMMIT_PATH
final boolean proj_clean = isCleanBuild()
if (!proj_git)
println "[MornyBuild] git repository not available for current working space! git version tag will be disabled."
else if (isCleanBuild()) {
println "git: clean build at ${grgit.head().id}"
} else {
final Status status = grgit.status()
println "git: non-clean-build"
if (!status.unstaged.allChanges.empty) {
println "git: unstaged changes"
listChanges(status.unstaged)
}
if (!status.staged.allChanges.empty) {
println "git: staged changes"
listChanges(status.staged)
}
}

final String proj_group = 'cc.sukazyo'
final String proj_package = "${proj_group}.cono.morny"
final String proj_archive_name = MORNY_ARCHIVE_NAME
final String proj_application_main = "${proj_package}.ServerMain"

final String proj_version_base = VERSION
final String proj_version_delta = VERSION_DELTA
final boolean proj_version_use_delta = Boolean.parseBoolean(USE_DELTA)
final String proj_version = proj_version_base + (proj_version_use_delta ? "${proj_version_delta}" : "")
final String proj_version_full = proj_version + (proj_git ? "+git.${proj_commit.substring(0, 8)}" + (proj_clean?"":"") : "")
final String proj_version_codename = CODENAME
final long proj_code_time = proj_clean ? grgit.head().dateTime.toInstant().toEpochMilli() : System.currentTimeMillis()

final JavaVersion proj_java = JavaVersion.VERSION_17
final Charset proj_file_encoding = StandardCharsets.UTF_8
final proj_scala_api = 3
//final proj_scala_lib = proj_scala_api+'.4.0-RC1-bin-20230901-89e8dba-NIGHTLY'
final proj_scala_lib = proj_scala_api+'.3.1'
String publish_local_url = null
String publish_remote_url = null
String publish_remote_username = null
String publish_remote_password = null
if (project.hasProperty("publishLocalArchiveRepoUrl")) publish_local_url = publishLocalArchiveRepoUrl
if (project.hasProperty("publishMvnRepoUrl")) {
publish_remote_url = publishMvnRepoUrl
publish_remote_username = publishMvnRepoUsername
publish_remote_password = publishMvnRepoPassword
}

group proj_group
version proj_version_full

repositories {
mavenCentral()
Expand All @@ -19,86 +75,142 @@ repositories {

dependencies {

compileOnlyApi "com.github.spotbugs:spotbugs-annotations:${libSpotbugsVersion}"
api "org.scala-lang:scala3-library_3:${proj_scala_lib}"
compileOnlyApi "com.github.spotbugs:spotbugs-annotations:${lib_spotbugs_v}"

api "cc.sukazyo:messiva:${libMessivaVersion}"
implementation "cc.sukazyo:messiva:${lib_messiva_v}"
implementation "cc.sukazyo:resource-tools:${lib_resourcetools_v}"

implementation "com.github.pengrad:java-telegram-bot-api:${libJavaTelegramBotApiVersion}"
implementation "com.github.pengrad:java-telegram-bot-api:${lib_javatelegramapi_v}"
implementation "com.squareup.okhttp3:okhttp:${lib_okhttp_v}"
implementation "com.google.code.gson:gson:${lib_gson_v}"

testImplementation "org.junit.jupiter:junit-jupiter-api:${libJunitVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${libJunitVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${libJunitVersion}"
testImplementation "org.scalatest:scalatest_$proj_scala_api:${lib_scalatest_v}"
testImplementation "org.scalatest:scalatest-freespec_$proj_scala_api:${lib_scalatest_v}"
testRuntimeOnly "org.scala-lang.modules:scala-xml_$proj_scala_api:${lib_scalamodule_xml_v}"
testRuntimeOnly 'com.vladsch.flexmark:flexmark-all:0.64.6' // for generating HTML report // required by gradle-scalatest plugin

}

task updateVersionCode {
ant.replaceregexp(match:'VERSION = ["a-zA-Z0-9.\\-_+@]+;', replace:"VERSION = \"$project.version\";", flags:'g', byline:true) {
fileset(dir: 'src/main/java/cc/sukazyo/cono/morny', includes: 'GradleProjectConfigures.java')
}
ant.replaceregexp(match:'CODENAME = ["a-zA-Z0-9]+;', replace:"CODENAME = \"${CODENAME}\";", flags:'g', byline:true) {
fileset(dir: 'src/main/java/cc/sukazyo/cono/morny', includes: 'GradleProjectConfigures.java')
}
ant.replaceregexp(match:'COMPILE_TIMESTAMP = [0-9]+L;', replace:"COMPILE_TIMESTAMP = ${System.currentTimeMillis()}L;", flags:'g', byline:true) {
fileset(dir: 'src/main/java/cc/sukazyo/cono/morny', includes: 'GradleProjectConfigures.java')
}
java {
withSourcesJar()
}

compileJava.dependsOn updateVersionCode
tasks.withType(JavaCompile).configureEach {

sourceCompatibility proj_java.getMajorVersion()
targetCompatibility proj_java.getMajorVersion()

options.encoding = proj_file_encoding.name()

}

tasks.withType(ScalaCompile).configureEach {

sourceCompatibility proj_java.getMajorVersion()
targetCompatibility proj_java.getMajorVersion()

options.encoding = proj_file_encoding.name()
scalaCompileOptions.encoding = proj_file_encoding.name()

scalaCompileOptions.additionalParameters.add "-language:postfixOps"

}

tasks.withType(Javadoc).configureEach {
options.encoding = proj_file_encoding.name()
}

//tasks.withType(ScalaDoc).configureEach {
//}

test {
useJUnitPlatform()
}

java {
application {
mainClass = proj_application_main
}

buildConfig {

sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
packageName(proj_package)

withSourcesJar()
buildConfigField('String', 'VERSION', "\"${proj_version}\"")
buildConfigField('String', 'VERSION_FULL', "\"${proj_version_full}\"")
buildConfigField('String', 'VERSION_BASE', "\"${proj_version_base}\"")
buildConfigField('String', 'VERSION_DELTA', proj_version_use_delta ? "\"${proj_version_delta}\"" : "null")
buildConfigField('String', 'CODENAME', "\"${proj_version_codename}\"")
buildConfigField('long', 'CODE_TIMESTAMP', "${proj_code_time}L")
buildConfigField('String', 'COMMIT', proj_git ? "\"${proj_commit}\"" : "null")
buildConfigField('boolean', 'CLEAN_BUILD', "${proj_clean}")
buildConfigField('String', 'CODE_STORE', proj_store==""?"null":"\"${proj_store}\"")
buildConfigField('String', 'COMMIT_PATH', proj_commit_path==""?"null":"\"${proj_commit_path}\"")

}

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
tasks.withType(Jar).configureEach {
archiveBaseName.set proj_archive_name
}

tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
options.docEncoding = 'UTF-8'
options.charSet = 'UTF-8'
shadowJar {

archiveClassifier.set "fat"

if (project.hasProperty("dockerBuild")) {
println "shadow-jar: using docker build name"
archiveVersion.set ""
archiveClassifier.set "docker-build"
}

}

tasks.test {
useJUnitPlatform()
@SuppressWarnings('GrMethodMayBeStatic')
boolean isCleanBuild () {
if (grgit == null) return false
Set<String> changes = grgit.status().unstaged.allChanges + grgit.status().staged.allChanges
for (String file in changes) {
if (file.startsWith("src/")) return false
if (file == "build.gradle") return false
if (file == "gradle.properties") return false
}
return true
}

shadowJar {
archiveBaseName.set("${project.ext.archiveBaseName}")
archiveVersion.set("${project.version}")
archiveClassifier.set("fat")
void listChanges (Status.Changes listing) {
for (String file in listing.added)
println " add: ${file}"
for (String file in listing.modified)
println " mod: ${file}"
for (String file in listing.removed)
println " del: ${file}"
}

publishing {
repositories{
maven {
name 'builds'
url publishLocalArchiveRepoUrl
if (publish_local_url != null) maven {
name 'archives'
url publish_local_url
}
maven {
if (publish_remote_url != null) maven {
name '-ws-'
url publishMvnRepoUrl
url publish_remote_url
credentials {
username publishMvnRepoUsername
password publishMvnRepoPassword
username publish_remote_username
password publish_remote_password
}
}
}
publications {
//noinspection GroovyAssignabilityCheck
main (MavenPublication) {
//noinspection GroovyAssignabilityCheck
from components.java
groupId = project.group
artifactId = project.ext.artifactId
version = project.version
//noinspection GroovyAssignabilityCheck
groupId = proj_group
//noinspection GroovyAssignabilityCheck
artifactId = proj_archive_name
//noinspection GroovyAssignabilityCheck
version = proj_version
}
}
}
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
coeur-app:
build: .
command: -v
Loading

0 comments on commit 49bbc03

Please sign in to comment.