Skip to content

Commit

Permalink
added /info(main) and /start, added support for assets
Browse files Browse the repository at this point in the history
- add /info (without subcommand)
  - add about pic
  - add morny about links
- add MornyAssets to manager & use assets
- add TelegramImages to manager images that in use
  - with a AssetsFileImage
  - with IMG_ABOUT
- add MornyAbout
  - changed MornyHello to MornyAbout
  - add about links (used in /info)
- remove HelloOnStart
  • Loading branch information
Eyre-S committed Aug 27, 2023
1 parent 7589e86 commit 213798d
Show file tree
Hide file tree
Showing 13 changed files with 324 additions and 91 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ if (project.hasProperty("publishMvnRepoUrl")) {

group proj_group
version proj_version_full
setArchivesBaseName proj_archive_name

repositories {
mavenCentral()
Expand All @@ -75,7 +74,8 @@ dependencies {

compileOnlyApi "com.github.spotbugs:spotbugs-annotations:${lib_spotbugs_v}"

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

implementation "com.github.pengrad:java-telegram-bot-api:${lib_javatelegramapi_v}"
implementation "com.squareup.okhttp3:okhttp:${lib_okhttp_v}"
Expand Down Expand Up @@ -139,6 +139,7 @@ buildConfig {

shadowJar {

archiveBaseName.set proj_archive_name
archiveClassifier.set "fat"

if (project.hasProperty("dockerBuild")) {
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MORNY_ARCHIVE_NAME = morny-coeur
MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono
MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s

VERSION = 1.0.0-RC3.9
VERSION = 1.0.0-RC4

USE_DELTA = false
VERSION_DELTA =
Expand All @@ -17,6 +17,7 @@ CODENAME = beiping
lib_spotbugs_v = 4.7.3

lib_messiva_v = 0.1.1
lib_resourcetools_v = 0.2.2

lib_javatelegramapi_v = 6.2.0

Expand Down
31 changes: 31 additions & 0 deletions src/main/java/cc/sukazyo/cono/morny/MornyAbout.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cc.sukazyo.cono.morny;

import java.io.IOException;

/**
* Some of the static information of Morny.
*/
public class MornyAbout {

/**
* ASCII art of Morny Featured Image.
* <p>
* used for Coeur starting welcome screen.
* <p>
* stored at <i><u>/assets_morny/texts/server-hello.txt</u></i>
*/
public static final String MORNY_PREVIEW_IMAGE_ASCII;
static {
try {
MORNY_PREVIEW_IMAGE_ASCII = MornyAssets.pack.getResource("texts/server-hello.txt").readAsString();
} catch (IOException e) {
throw new RuntimeException("Cannot read MORNY_PREVIEW_IMAGE_ASCII from assets pack", e);
}
}

public static final String MORNY_SOURCECODE_LINK = "https://github.com/Eyre-S/Coeur-Morny-Cono";
public static final String MORNY_SOURCECODE_SELF_HOSTED_MIRROR_LINK = "https://storage.sukazyo.cc/Eyre_S/Coeur-Morny-Cono";
public static final String MORNY_ISSUE_TRACKER_LINK = "https://github.com/Eyre-S/Coeur-Morny-Cono/issues";
public static final String MORNY_USER_GUIDE_LINK = "https://book.sukazyo.cc/morny";

}
19 changes: 19 additions & 0 deletions src/main/java/cc/sukazyo/cono/morny/MornyAssets.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cc.sukazyo.cono.morny;

import cc.sukazyo.restools.ResourcesPackage;

/**
* Morny assets manager.
*
* @see #pack
* @since 1.0.0-RC4
*/
public class MornyAssets {

/**
* Instance mirror of the Morny assets, the assets root is <i><u>/src/main/resources/assets_morny/</u></i>.
* @since 1.0.0-RC4
*/
public static final ResourcesPackage pack = new ResourcesPackage(MornyAssets.class, "assets_morny");

}
70 changes: 0 additions & 70 deletions src/main/java/cc/sukazyo/cono/morny/MornyHello.java

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/java/cc/sukazyo/cono/morny/ServerMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ServerMain {
* {@code --version} 只输出版本信息,不运行主程序。此参数会导致其它所有参数失效(优先级最高)
* </li>
* <li>
* {@code --only-hello} 只输出欢迎字符画({@link MornyHello}),不运行主程序。
* {@code --only-hello} 只输出欢迎字符画({@link MornyAbout#MORNY_PREVIEW_IMAGE_ASCII}),不运行主程序。
* 不要同时使用 {@code --no-hello},原因见下。
* </li>
* <li>
Expand Down Expand Up @@ -222,7 +222,7 @@ public static void main (@Nonnull String[] args) {
//# 启动相关参数的检查和处理
//#

if (showWelcome) logger.info(MornyHello.MORNY_PREVIEW_IMAGE_ASCII);
if (showWelcome) logger.info(MornyAbout.MORNY_PREVIEW_IMAGE_ASCII);
if (welcomeEchoMode) return;

unknownArgs.forEach(arg -> logger.warn("Can't understand arg to some meaning :\n " + arg));
Expand Down
Loading

0 comments on commit 213798d

Please sign in to comment.