Commit 2632fe29 authored by Adam Gausmann's avatar Adam Gausmann

Add version command

parent 2f60f0c8
Pipeline #5065232 passed with stages
in 13 seconds
......@@ -28,4 +28,6 @@ public interface Bot {
default void quit() {
quit(0);
}
String getVersion();
}
......@@ -27,6 +27,12 @@
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......
......@@ -52,6 +52,7 @@ public class BotImpl implements Bot {
private final ConnectionManagerImpl connectionManager;
private final CommandSystemImpl commandSystem;
private final PluginManagerImpl pluginManager;
private String version = null;
private boolean running;
private int exitCode;
......@@ -113,6 +114,10 @@ public class BotImpl implements Bot {
properties.load(getClass().getResourceAsStream("bot.properties"));
properties.store(new FileOutputStream(propertiesFile), "Samurai bot properties");
}
Properties versionProperties = new Properties();
versionProperties.load(getClass().getResourceAsStream("version.properties"));
version = versionProperties.getProperty("version");
}
private void storeConfig() throws IOException {
......@@ -164,4 +169,9 @@ public class BotImpl implements Bot {
running = false;
this.exitCode = exitCode;
}
@Override
public String getVersion() {
return version;
}
}
......@@ -15,6 +15,12 @@ public class CommandExecutorImpl {
this.bot = bot;
CommandSystem commandSystem = bot.getCommandSystem();
commandSystem.registerCommand(new CommandInfo(
"version",
"Provides information about the bot and its version.",
"version",
false
), this::handleVersion);
commandSystem.registerCommand(new CommandInfo(
"help",
"Lists all commands available to the user.",
......@@ -71,6 +77,13 @@ public class CommandExecutorImpl {
), this::handleMsg);
}
private boolean handleVersion(CommandSender sender, CommandInfo info, String label, String[] args) {
sender.sendChat("Samurai v" + bot.getVersion() + ", a lightweight extensible IRC bot.");
sender.sendChat("Written by Adam Gausmann (nonemu) <adam@nonemu.ninja>");
sender.sendChat("Source code available at https://gitlab.com/AGausmann/samurai");
return true;
}
private boolean handleHelp(CommandSender sender, CommandInfo info, String label, String[] args) {
int page = 1;
......
version=${project.version}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment