Skip to content

Commit

Permalink
add calc command
Browse files Browse the repository at this point in the history
2020-03-06 15:45:37
  • Loading branch information
SimplyRin committed Mar 6, 2020
1 parent 5460dc6 commit 1a634a8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,30 @@ public void onMessageReceived(MessageReceivedEvent event) {
return;
}

if (args[0].startsWith("=")) {
String input = args[0].replace("=", "");
if (input.length() == 0) {
embedBuilder.setColor(Color.RED);
embedBuilder.setDescription("使用方法: =<計算式>\n=1+1");
channel.sendMessage(embedBuilder.build()).complete();
return;
}

Runtime runtime = Runtime.getRuntime();
Process process = null;
try {
process = runtime.exec(new String[] {"calc", input});
} catch (Exception e) {
this.instance.postError(e);
return;
}
Scanner scanner = new Scanner(process.getInputStream());
if (scanner.hasNext()) {
channel.sendMessage("結果: **" + scanner.nextLine().trim() + "**").complete();
}
scanner.close();
}

if (args[0].equalsIgnoreCase("!jp")) {
if (args.length > 1) {
String text = "";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/simplyrin/pandaentus/utils/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class Version {

public static final String BUILD_NUMBER = "";
public static final String BUILD_TIME ="2020-03-05 19:32:27";
public static final String BUILD_TIME ="2020-03-06 15:45:37";
public static final String POMVERSION = "1.1";

}

0 comments on commit 1a634a8

Please sign in to comment.