mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-25 04:27:41 +08:00
添加获取当前版本的命令,gradle更新,maven打包发布支持
This commit is contained in:
parent
14d3f76ac1
commit
c715287fb7
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 {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
|
id 'maven-publish'
|
||||||
|
id 'application'
|
||||||
|
id 'com.github.johnrengelman.shadow' version '7.1.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'cc.sukazyo'
|
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 {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -31,6 +28,10 @@ test {
|
|||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
withSourcesJar()
|
||||||
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
}
|
}
|
||||||
@ -49,7 +50,38 @@ apply plugin: 'com.github.johnrengelman.shadow'
|
|||||||
apply plugin: 'application'
|
apply plugin: 'application'
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
mainClassName = 'cc.sukazyo.cono.morny.MornyCoeur'
|
archiveBaseName.set("${project.ext.archiveBaseName}")
|
||||||
archiveBaseName.set("Morny_Coeur")
|
archiveVersion.set("${project.version}")
|
||||||
archiveVersion.set(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
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -52,7 +52,7 @@ public class MornyCoeur {
|
|||||||
try {
|
try {
|
||||||
String username = account.execute(new GetMe()).user().username();
|
String username = account.execute(new GetMe()).user().username();
|
||||||
if (!USERNAME.equals(username))
|
if (!USERNAME.equals(username))
|
||||||
throw new RuntimeException("Required the bot @"+USERNAME + " but @"+username + "logged in!");
|
throw new RuntimeException("Required the bot @"+USERNAME + " but @"+username + " logged in!");
|
||||||
logger.info("Succeed login to @" + username);
|
logger.info("Succeed login to @" + username);
|
||||||
return account;
|
return account;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
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;
|
package cc.sukazyo.cono.morny.bot.event;
|
||||||
|
|
||||||
import cc.sukazyo.cono.morny.MornyCoeur;
|
import cc.sukazyo.cono.morny.MornyCoeur;
|
||||||
|
import cc.sukazyo.cono.morny.MornySystem;
|
||||||
import cc.sukazyo.cono.morny.MornyTrusted;
|
import cc.sukazyo.cono.morny.MornyTrusted;
|
||||||
import cc.sukazyo.cono.morny.bot.api.EventListener;
|
import cc.sukazyo.cono.morny.bot.api.EventListener;
|
||||||
import com.pengrad.telegrambot.model.Update;
|
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 com.pengrad.telegrambot.request.SendSticker;
|
||||||
|
|
||||||
import static cc.sukazyo.cono.morny.Logger.logger;
|
import static cc.sukazyo.cono.morny.Logger.logger;
|
||||||
@ -35,6 +38,10 @@ public class OnCommandExecute extends EventListener {
|
|||||||
case "/exit@" + MornyCoeur.USERNAME:
|
case "/exit@" + MornyCoeur.USERNAME:
|
||||||
onCommandExitExec(event);
|
onCommandExitExec(event);
|
||||||
break;
|
break;
|
||||||
|
case "/version":
|
||||||
|
case "/version@" + MornyCoeur.USERNAME:
|
||||||
|
onCommandVersionExec(event);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
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