mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-22 19:24:53 +08:00
Merge tag '0.3.0@mvn' into release
This commit is contained in:
commit
f6b64493b2
58
build.gradle
58
build.gradle
@ -1,18 +1,15 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.github.jengelman.gradle.plugins:shadow:5.0.0'
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'maven-publish'
|
||||
id 'application'
|
||||
id 'com.github.johnrengelman.shadow' version '7.1.0'
|
||||
}
|
||||
|
||||
group 'cc.sukazyo'
|
||||
version '0.2.0'
|
||||
version '0.3.0'
|
||||
project.ext.archiveBaseName = 'Coeur_Morny_Cono'
|
||||
project.ext.artifactId = 'morny-coeur'
|
||||
mainClassName = 'cc.sukazyo.cono.morny.MornyCoeur'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -31,6 +28,10 @@ test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
@ -49,7 +50,38 @@ apply plugin: 'com.github.johnrengelman.shadow'
|
||||
apply plugin: 'application'
|
||||
|
||||
shadowJar {
|
||||
mainClassName = 'cc.sukazyo.cono.morny.MornyCoeur'
|
||||
archiveBaseName.set("Morny_Coeur")
|
||||
archiveVersion.set(version)
|
||||
archiveBaseName.set("${project.ext.archiveBaseName}")
|
||||
archiveVersion.set("${project.version}")
|
||||
archiveClassifier.set("fat")
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveBaseName.set("${project.ext.archiveBaseName}")
|
||||
archiveVersion.set("${project.version}")
|
||||
archiveClassifier.set("fat")
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories{
|
||||
maven {
|
||||
name 'builds'
|
||||
url = "file://" + new File("./build/publishing").getAbsolutePath()
|
||||
}
|
||||
maven {
|
||||
name '-ws-'
|
||||
url publishMvnRepoUrl
|
||||
credentials {
|
||||
username publishMvnRepoUsername
|
||||
password publishMvnRepoPassword
|
||||
}
|
||||
}
|
||||
}
|
||||
publications {
|
||||
main (MavenPublication) {
|
||||
from components.java
|
||||
groupId = project.group
|
||||
artifactId = project.ext.artifactId
|
||||
version = project.version
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
20
src/main/java/cc/sukazyo/cono/morny/MornySystem.java
Normal file
20
src/main/java/cc/sukazyo/cono/morny/MornySystem.java
Normal file
@ -0,0 +1,20 @@
|
||||
package cc.sukazyo.cono.morny;
|
||||
|
||||
import cc.sukazyo.cono.morny.util.FileUtils;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class MornySystem {
|
||||
|
||||
public static final String VERSION = "0.3.0";
|
||||
|
||||
public static String getJarMd5() {
|
||||
try {
|
||||
return FileUtils.getMD5Three(MornyCoeur.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace(System.out);
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,12 @@
|
||||
package cc.sukazyo.cono.morny.bot.event;
|
||||
|
||||
import cc.sukazyo.cono.morny.MornyCoeur;
|
||||
import cc.sukazyo.cono.morny.MornySystem;
|
||||
import cc.sukazyo.cono.morny.MornyTrusted;
|
||||
import cc.sukazyo.cono.morny.bot.api.EventListener;
|
||||
import com.pengrad.telegrambot.model.Update;
|
||||
import com.pengrad.telegrambot.model.request.ParseMode;
|
||||
import com.pengrad.telegrambot.request.SendMessage;
|
||||
import com.pengrad.telegrambot.request.SendSticker;
|
||||
|
||||
import static cc.sukazyo.cono.morny.Logger.logger;
|
||||
@ -35,6 +38,10 @@ public class OnCommandExecute extends EventListener {
|
||||
case "/exit@" + MornyCoeur.USERNAME:
|
||||
onCommandExitExec(event);
|
||||
break;
|
||||
case "/version":
|
||||
case "/version@" + MornyCoeur.USERNAME:
|
||||
onCommandVersionExec(event);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -76,4 +83,18 @@ public class OnCommandExecute extends EventListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void onCommandVersionExec (Update event) {
|
||||
MornyCoeur.getAccount().execute(new SendMessage(
|
||||
event.message().chat().id(),
|
||||
String.format(
|
||||
"version:\n" +
|
||||
"\t<code>%s</code>\n" +
|
||||
"core md5_hash:\n" +
|
||||
"\t<code>%s</code>",
|
||||
MornySystem.VERSION,
|
||||
MornySystem.getJarMd5()
|
||||
)
|
||||
).parseMode(ParseMode.HTML));
|
||||
}
|
||||
|
||||
}
|
||||
|
33
src/main/java/cc/sukazyo/cono/morny/util/FileUtils.java
Normal file
33
src/main/java/cc/sukazyo/cono/morny/util/FileUtils.java
Normal file
@ -0,0 +1,33 @@
|
||||
package cc.sukazyo.cono.morny.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class FileUtils {
|
||||
|
||||
public static String getMD5Three (String path) {
|
||||
BigInteger bi;
|
||||
try {
|
||||
byte[] buffer = new byte[8192];
|
||||
int len;
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
File f = new File(path);
|
||||
FileInputStream fis = new FileInputStream(f);
|
||||
while ((len = fis.read(buffer)) != -1) {
|
||||
md.update(buffer, 0, len);
|
||||
}
|
||||
fis.close();
|
||||
byte[] b = md.digest();
|
||||
bi = new BigInteger(1, b);
|
||||
} catch (NoSuchAlgorithmException | IOException e) {
|
||||
e.printStackTrace(System.out);
|
||||
return e.getMessage();
|
||||
}
|
||||
return bi.toString(16);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user