新增获取idea激活码的功能
This commit is contained in:
parent
bfe83babce
commit
c326e22699
@ -12,7 +12,7 @@ import org.springframework.context.annotation.Import;
|
|||||||
@Import(BTDownloadManager.class)
|
@Import(BTDownloadManager.class)
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class NasApplication {
|
public class NasApplication {
|
||||||
public static final String version="1.0.0";
|
public static final String version="1.1.0";
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(NasApplication.class, args);
|
SpringApplication.run(NasApplication.class, args);
|
||||||
AppData.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");
|
AppData.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");
|
||||||
|
53
src/main/java/com/yutou/nas/utils/IdeaTools.java
Normal file
53
src/main/java/com/yutou/nas/utils/IdeaTools.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package com.yutou.nas.utils;
|
||||||
|
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
|
public class IdeaTools {
|
||||||
|
public static String getIdea(String name) {
|
||||||
|
if(StringUtils.isEmpty(name)){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
File file = new File("tmp" + File.separator + "idea.zip");
|
||||||
|
try {
|
||||||
|
ZipFile zipFile = new ZipFile(file, Charset.forName("gbk"));
|
||||||
|
String data = "";
|
||||||
|
if (file.exists()) {
|
||||||
|
data = StreamTools.streamReadLine(zipFile.getInputStream(zipFile.getEntry(name)));
|
||||||
|
}
|
||||||
|
zipFile.close();
|
||||||
|
return data;
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getIdeaList() {
|
||||||
|
File file = HttpTools.syncDownload("http://idea.medeming.com/a/jihuoma.zip", "idea.zip");
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
ZipFile zip = new ZipFile(file, Charset.forName("gbk"));
|
||||||
|
Enumeration<? extends ZipEntry> ez = zip.entries();
|
||||||
|
while (ez.hasMoreElements()) {
|
||||||
|
ZipEntry entry = ez.nextElement();
|
||||||
|
if (entry.getName().endsWith(".txt")) {
|
||||||
|
list.add(entry.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zip.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
@ -43,6 +43,8 @@ public class QQBotManager {
|
|||||||
private final static String QQ_AUDIO_OPEN_LAMP = "!开灯";
|
private final static String QQ_AUDIO_OPEN_LAMP = "!开灯";
|
||||||
private final static String QQ_AUDIO_OPEN_AIR = "!开空调";
|
private final static String QQ_AUDIO_OPEN_AIR = "!开空调";
|
||||||
private final static String QQ_BT_RELOAD = "!刷BT";
|
private final static String QQ_BT_RELOAD = "!刷BT";
|
||||||
|
private final static String QQ_TOOLS_IDEA = "!idea";
|
||||||
|
private final static String QQ_TOOLS_IDEA_FILE = "!idea>";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static QQBotManager botManager = null;
|
private static QQBotManager botManager = null;
|
||||||
@ -223,6 +225,7 @@ public class QQBotManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void myGroup(String msg) {
|
private void myGroup(String msg) {
|
||||||
|
StringBuilder builder;
|
||||||
msg = msg.replace("!", "!").toLowerCase();
|
msg = msg.replace("!", "!").toLowerCase();
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case QQCommands.QQ_OPEN_PC:
|
case QQCommands.QQ_OPEN_PC:
|
||||||
@ -262,7 +265,7 @@ public class QQBotManager {
|
|||||||
System.exit(0);
|
System.exit(0);
|
||||||
break;
|
break;
|
||||||
case QQCommands.QQ_HELP:
|
case QQCommands.QQ_HELP:
|
||||||
StringBuilder builder = new StringBuilder();
|
builder = new StringBuilder();
|
||||||
for (Field field : QQCommands.class.getDeclaredFields()) {
|
for (Field field : QQCommands.class.getDeclaredFields()) {
|
||||||
try {
|
try {
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
@ -273,6 +276,13 @@ public class QQBotManager {
|
|||||||
}
|
}
|
||||||
getInstance().sendMessage(builder.toString());
|
getInstance().sendMessage(builder.toString());
|
||||||
break;
|
break;
|
||||||
|
case QQCommands.QQ_TOOLS_IDEA:
|
||||||
|
builder = new StringBuilder();
|
||||||
|
for (String name : IdeaTools.getIdeaList()) {
|
||||||
|
builder.append(QQCommands.QQ_TOOLS_IDEA_FILE).append(name).append("\n");
|
||||||
|
}
|
||||||
|
getInstance().sendMessage(builder.toString());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (msg.startsWith(QQCommands.QQ_CMD)) {
|
if (msg.startsWith(QQCommands.QQ_CMD)) {
|
||||||
RedisTools.Consumer.system("cmd", msg.replace(QQCommands.QQ_CMD, ""));
|
RedisTools.Consumer.system("cmd", msg.replace(QQCommands.QQ_CMD, ""));
|
||||||
@ -298,6 +308,8 @@ public class QQBotManager {
|
|||||||
|
|
||||||
} else if (msg.startsWith(QQCommands.QQ_AUDIO)) {
|
} else if (msg.startsWith(QQCommands.QQ_AUDIO)) {
|
||||||
QQAudio.playText(msg.replace(QQCommands.QQ_AUDIO, ""));
|
QQAudio.playText(msg.replace(QQCommands.QQ_AUDIO, ""));
|
||||||
|
}else if(msg.startsWith(QQCommands.QQ_TOOLS_IDEA_FILE)){
|
||||||
|
getInstance().sendMessage(IdeaTools.getIdea(msg.replace(QQCommands.QQ_TOOLS_IDEA_FILE,"")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
src/main/java/com/yutou/nas/utils/StreamTools.java
Normal file
22
src/main/java/com/yutou/nas/utils/StreamTools.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package com.yutou.nas.utils;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
public class StreamTools {
|
||||||
|
public static String streamReadLine(InputStream stream) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
try {
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
||||||
|
String tmp;
|
||||||
|
while ((tmp = reader.readLine()) != null) {
|
||||||
|
builder.append(tmp);
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user