added tengwar command. View TengwarCommand.java for more info
This commit is contained in:
parent
e29c3d7701
commit
b3455e0b8d
15
pom.xml
15
pom.xml
|
@ -46,27 +46,32 @@
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
|
||||||
<id>jcenter</id>
|
|
||||||
<url>http://jcenter.bintray.com</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>jitpack.io</id>
|
<id>jitpack.io</id>
|
||||||
<url>https://jitpack.io</url>
|
<url>https://jitpack.io</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>jcenter</id>
|
||||||
|
<url>http://jcenter.bintray.com</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.austinv11</groupId>
|
<groupId>com.github.austinv11</groupId>
|
||||||
<artifactId>Discord4J</artifactId>
|
<artifactId>Discord4J</artifactId>
|
||||||
<version>2.8.3</version>
|
<version>2.8.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sedmelluq</groupId>
|
<groupId>com.sedmelluq</groupId>
|
||||||
<artifactId>lavaplayer</artifactId>
|
<artifactId>lavaplayer</artifactId>
|
||||||
<version>1.2.39</version>
|
<version>1.2.39</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.andrewlalis</groupId>
|
||||||
|
<artifactId>TengwarTranslatorLibrary</artifactId>
|
||||||
|
<version>1.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -2,6 +2,7 @@ package handiebot.command;
|
||||||
|
|
||||||
import handiebot.command.commands.admin.QuitCommand;
|
import handiebot.command.commands.admin.QuitCommand;
|
||||||
import handiebot.command.commands.admin.SetPrefixCommand;
|
import handiebot.command.commands.admin.SetPrefixCommand;
|
||||||
|
import handiebot.command.commands.misc.TengwarCommand;
|
||||||
import handiebot.command.commands.music.*;
|
import handiebot.command.commands.music.*;
|
||||||
import handiebot.command.commands.support.HelpCommand;
|
import handiebot.command.commands.support.HelpCommand;
|
||||||
import handiebot.command.commands.support.InfoCommand;
|
import handiebot.command.commands.support.InfoCommand;
|
||||||
|
@ -39,6 +40,7 @@ public class Commands {
|
||||||
commands.add(new InfoCommand());
|
commands.add(new InfoCommand());
|
||||||
commands.add(new SetPrefixCommand());
|
commands.add(new SetPrefixCommand());
|
||||||
commands.add(new QuitCommand());
|
commands.add(new QuitCommand());
|
||||||
|
commands.add(new TengwarCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
package handiebot.command.commands.misc;
|
||||||
|
|
||||||
|
import handiebot.command.CommandContext;
|
||||||
|
import handiebot.command.types.ContextCommand;
|
||||||
|
import net.agspace.TengwarImageGenerator;
|
||||||
|
import net.agspace.Translator;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
|
||||||
|
import static handiebot.HandieBot.resourceBundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Andrew Lalis
|
||||||
|
*/
|
||||||
|
public class TengwarCommand extends ContextCommand {
|
||||||
|
|
||||||
|
public TengwarCommand() {
|
||||||
|
super("tengwar",
|
||||||
|
"<translateTo|translateFrom> <TEXT>",
|
||||||
|
resourceBundle.getString("commands.command.tengwar.description"),
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandContext context) {
|
||||||
|
if (context.getArgs().length == 0){
|
||||||
|
context.getChannel().sendMessage(this.getUsage(context.getGuild()));
|
||||||
|
} else if (context.getArgs().length >= 2){
|
||||||
|
String input = readTextFromArgs(context.getArgs());
|
||||||
|
if (context.getArgs()[0].equalsIgnoreCase("translateTo")){
|
||||||
|
String result = Translator.translateToTengwar(input);
|
||||||
|
try {
|
||||||
|
context.getChannel().sendFile(TengwarImageGenerator.generateImage(result,
|
||||||
|
500,
|
||||||
|
24f,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
System.getProperty("user.home")+"/.handiebot/tengwarTemp.png"));
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else if (context.getArgs()[0].equalsIgnoreCase("translateFrom")){
|
||||||
|
context.getChannel().sendMessage(Translator.translateToEnglish(input));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
context.getChannel().sendMessage(this.getUsage(context.getGuild()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String readTextFromArgs(String[] args){
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 1; i < args.length; i++){
|
||||||
|
sb.append(args[i]).append(' ');
|
||||||
|
}
|
||||||
|
return sb.toString().trim();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
/**
|
||||||
|
* @author Andrew Lalis
|
||||||
|
* Contains miscellaneous commands that do not belong in a group.
|
||||||
|
*/
|
||||||
|
package handiebot.command.commands.misc;
|
|
@ -90,6 +90,8 @@ commands.command.shuffle.description=Sets shuffling.
|
||||||
commands.command.skip.description=Skips the current song.
|
commands.command.skip.description=Skips the current song.
|
||||||
#Stop
|
#Stop
|
||||||
commands.command.stop.description=Stops playing music.
|
commands.command.stop.description=Stops playing music.
|
||||||
|
#Tengwar translator
|
||||||
|
commands.command.tengwar.description=Translates text to tengwar, or decodes tengwar text back into human readable form.
|
||||||
#Music Player
|
#Music Player
|
||||||
player.setRepeat=Set repeat to {0}
|
player.setRepeat=Set repeat to {0}
|
||||||
player.setShuffle=Set shuffle to {0}
|
player.setShuffle=Set shuffle to {0}
|
||||||
|
|
|
@ -99,4 +99,5 @@ trackSchedule.trackStarted=Started audio track: {0}
|
||||||
trackSchedule.nowPlaying=Now playing: **{0}** {1}\
|
trackSchedule.nowPlaying=Now playing: **{0}** {1}\
|
||||||
{2}
|
{2}
|
||||||
player.playQueueEmpty=There's nothing in the queue to play.
|
player.playQueueEmpty=There's nothing in the queue to play.
|
||||||
|
commands.command.tengwar.description=Translates text to tengwar, or decodes tengwar text back into human readable form.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue