Reworked versions command.
This commit is contained in:
parent
4b95b0bbe2
commit
f7e2651619
4 changed files with 104 additions and 83 deletions
|
@ -38,13 +38,13 @@ import net.thauvin.erik.mobibot.commands.Cycle;
|
||||||
import net.thauvin.erik.mobibot.commands.Ignore;
|
import net.thauvin.erik.mobibot.commands.Ignore;
|
||||||
import net.thauvin.erik.mobibot.commands.Info;
|
import net.thauvin.erik.mobibot.commands.Info;
|
||||||
import net.thauvin.erik.mobibot.commands.Me;
|
import net.thauvin.erik.mobibot.commands.Me;
|
||||||
import net.thauvin.erik.mobibot.commands.MobibotVersion;
|
|
||||||
import net.thauvin.erik.mobibot.commands.Modules;
|
import net.thauvin.erik.mobibot.commands.Modules;
|
||||||
import net.thauvin.erik.mobibot.commands.Msg;
|
import net.thauvin.erik.mobibot.commands.Msg;
|
||||||
import net.thauvin.erik.mobibot.commands.Nick;
|
import net.thauvin.erik.mobibot.commands.Nick;
|
||||||
import net.thauvin.erik.mobibot.commands.Recap;
|
import net.thauvin.erik.mobibot.commands.Recap;
|
||||||
import net.thauvin.erik.mobibot.commands.Say;
|
import net.thauvin.erik.mobibot.commands.Say;
|
||||||
import net.thauvin.erik.mobibot.commands.Users;
|
import net.thauvin.erik.mobibot.commands.Users;
|
||||||
|
import net.thauvin.erik.mobibot.commands.Versions;
|
||||||
import net.thauvin.erik.mobibot.commands.links.Comment;
|
import net.thauvin.erik.mobibot.commands.links.Comment;
|
||||||
import net.thauvin.erik.mobibot.commands.links.Posting;
|
import net.thauvin.erik.mobibot.commands.links.Posting;
|
||||||
import net.thauvin.erik.mobibot.commands.links.Tags;
|
import net.thauvin.erik.mobibot.commands.links.Tags;
|
||||||
|
@ -117,19 +117,10 @@ public class Mobibot extends PircBot {
|
||||||
// Info strings
|
// Info strings
|
||||||
@SuppressWarnings("indentation")
|
@SuppressWarnings("indentation")
|
||||||
public static final List<String> INFO =
|
public static final List<String> INFO =
|
||||||
List.of(ReleaseInfo.PROJECT + " v" + ReleaseInfo.VERSION + " by Erik C. Thauvin (erik@thauvin.net)",
|
List.of(
|
||||||
"https://www.mobitopia.org/mobibot/");
|
ReleaseInfo.PROJECT + " v" + ReleaseInfo.VERSION
|
||||||
// Version strings
|
+ " (" + Utils.green("https://www.mobitopia.org/mobibot/") + ')',
|
||||||
@SuppressWarnings("indentation")
|
"Written by Erik C. Thauvin (" + Utils.green("https://erik.thauvin.net/") + ')');
|
||||||
public static final List<String> MOBIBOT_VERSIONS =
|
|
||||||
List.of("Version: " + ReleaseInfo.VERSION + " (" + Utils.isoLocalDate(ReleaseInfo.BUILDDATE) + ')',
|
|
||||||
"Platform: " + System.getProperty("os.name") + " (" + System.getProperty("os.version") + ", "
|
|
||||||
+ System.getProperty("os.arch") + ", " + System.getProperty("user.country") + ')',
|
|
||||||
"Runtime: " + System.getProperty("java.runtime.name") + " (build " + System.getProperty(
|
|
||||||
"java.runtime.version") + ')',
|
|
||||||
"VM: " + System.getProperty("java.vm.name") + " (build " + System.getProperty("java.vm.version")
|
|
||||||
+ ", "
|
|
||||||
+ System.getProperty("java.vm.info") + ')');
|
|
||||||
// Timer
|
// Timer
|
||||||
public static final Timer timer = new Timer(true);
|
public static final Timer timer = new Timer(true);
|
||||||
// Default port
|
// Default port
|
||||||
|
@ -253,13 +244,13 @@ public class Mobibot extends PircBot {
|
||||||
commands.add(ignoreCommand);
|
commands.add(ignoreCommand);
|
||||||
commands.add(new Info());
|
commands.add(new Info());
|
||||||
commands.add(new Me());
|
commands.add(new Me());
|
||||||
commands.add(new MobibotVersion());
|
|
||||||
commands.add(new Modules());
|
commands.add(new Modules());
|
||||||
commands.add(new Msg());
|
commands.add(new Msg());
|
||||||
commands.add(new Nick());
|
commands.add(new Nick());
|
||||||
commands.add(new Recap());
|
commands.add(new Recap());
|
||||||
commands.add(new Say());
|
commands.add(new Say());
|
||||||
commands.add(new Users());
|
commands.add(new Users());
|
||||||
|
commands.add(new Versions());
|
||||||
|
|
||||||
// Load the links commands
|
// Load the links commands
|
||||||
commands.add(new Comment());
|
commands.add(new Comment());
|
||||||
|
|
|
@ -57,12 +57,8 @@ class Info : AbstractCommand() {
|
||||||
isPrivate: Boolean
|
isPrivate: Boolean
|
||||||
) {
|
) {
|
||||||
for (info in Mobibot.INFO) {
|
for (info in Mobibot.INFO) {
|
||||||
if (info.startsWith("https://")) {
|
|
||||||
bot.send(sender, info, Colors.DARK_GREEN, isPrivate)
|
|
||||||
} else {
|
|
||||||
bot.send(sender, info, isPrivate)
|
bot.send(sender, info, isPrivate)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val info = StringBuilder("Uptime: ")
|
val info = StringBuilder("Uptime: ")
|
||||||
|
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
/*
|
|
||||||
* AbstractCommandImpl.kt
|
|
||||||
*
|
|
||||||
* Copyright (c) 2004-2020, Erik C. Thauvin (erik@thauvin.net)
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* Neither the name of this project nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software without
|
|
||||||
* specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.thauvin.erik.mobibot.commands
|
|
||||||
|
|
||||||
import net.thauvin.erik.mobibot.Mobibot
|
|
||||||
import net.thauvin.erik.mobibot.Utils
|
|
||||||
|
|
||||||
class MobibotVersion : AbstractCommand() {
|
|
||||||
override val command = "version"
|
|
||||||
override val help = listOf(
|
|
||||||
Utils.bold("To view the version data (bot, java, etc.):"),
|
|
||||||
Utils.helpIndent("/msg %s $command")
|
|
||||||
)
|
|
||||||
override val isOp = true
|
|
||||||
override val isPublic = false
|
|
||||||
override val isVisible = true
|
|
||||||
|
|
||||||
override fun commandResponse(
|
|
||||||
bot: Mobibot,
|
|
||||||
sender: String,
|
|
||||||
login: String,
|
|
||||||
args: String,
|
|
||||||
isOp: Boolean,
|
|
||||||
isPrivate: Boolean
|
|
||||||
) {
|
|
||||||
if (isOp) {
|
|
||||||
for (v in Mobibot.MOBIBOT_VERSIONS) {
|
|
||||||
bot.send(sender, v, isPrivate)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
bot.helpDefault(sender, isOp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
* Version.java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of this project nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software without
|
||||||
|
* specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.thauvin.erik.mobibot.commands;
|
||||||
|
|
||||||
|
import net.thauvin.erik.mobibot.Mobibot;
|
||||||
|
import net.thauvin.erik.mobibot.ReleaseInfo;
|
||||||
|
import net.thauvin.erik.mobibot.Utils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Versions extends AbstractCommand {
|
||||||
|
private final List<String> versions =
|
||||||
|
List.of("Version: " + ReleaseInfo.VERSION + " (" + Utils.isoLocalDate(ReleaseInfo.BUILDDATE) + ')',
|
||||||
|
"Platform: " + System.getProperty("os.name") + " (" + System.getProperty("os.version") + ", "
|
||||||
|
+ System.getProperty("os.arch") + ", " + System.getProperty("user.country") + ')',
|
||||||
|
"Runtime: " + System.getProperty("java.runtime.name") + " (build " + System.getProperty(
|
||||||
|
"java.runtime.version") + ')',
|
||||||
|
"VM: " + System.getProperty("java.vm.name") + " (build " + System.getProperty("java.vm.version")
|
||||||
|
+ ", "
|
||||||
|
+ System.getProperty("java.vm.info") + ')');
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public String getCommand() {
|
||||||
|
return "versions";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public List<String> getHelp() {
|
||||||
|
return List.of(Utils.bold("To view the versions data (bot, java, etc.):"),
|
||||||
|
Utils.helpIndent("/msg %s $command"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOp() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPublic() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisible() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void commandResponse(@NotNull final Mobibot bot,
|
||||||
|
@NotNull final String sender,
|
||||||
|
@NotNull final String login,
|
||||||
|
@NotNull final String args,
|
||||||
|
final boolean isOp,
|
||||||
|
final boolean isPrivate) {
|
||||||
|
if (isOp) {
|
||||||
|
for (final String v : versions) {
|
||||||
|
bot.send(sender, v, isPrivate);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
bot.helpDefault(sender, isOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue