Initial Repository Push
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.Database;
|
||||
import discord.DiscordAccount;
|
||||
import discord.MagicBot;
|
||||
import engine.Enum;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AccountInfoRequest {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event) {
|
||||
|
||||
String discordAccountID = event.getAuthor().getId();
|
||||
Enum.AccountStatus accountStatus;
|
||||
|
||||
if (Database.online == false) {
|
||||
|
||||
MagicBot.sendResponse(event,
|
||||
"Database currently: OFFLINE\n" +
|
||||
"Try again later!");
|
||||
return;
|
||||
}
|
||||
|
||||
List<DiscordAccount> discordAccounts = MagicBot.database.getDiscordAccounts(discordAccountID);
|
||||
|
||||
// User has no account registered. Status of what?
|
||||
|
||||
if (discordAccounts.isEmpty()) {
|
||||
MagicBot.sendResponse(event,
|
||||
"I checked my files twice but could not find your detailings!\n" +
|
||||
"You can easily fix this by asking me for to #register one.\n" +
|
||||
"Only one though. Multiple registrations are not allowed!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Send account detailings to user.
|
||||
|
||||
String outString =
|
||||
"I have for to located your account detailings\n" +
|
||||
"Registered on: " + discordAccounts.get(0).registrationDate.toString() +
|
||||
"\n-------------------\n";
|
||||
|
||||
for (DiscordAccount userAccount : discordAccounts)
|
||||
outString += userAccount.gameAccountName + "\n";
|
||||
|
||||
outString += "\n";
|
||||
|
||||
accountStatus = discordAccounts.get(0).status;
|
||||
|
||||
switch (accountStatus) {
|
||||
case BANNED:
|
||||
outString += "Your account status is BANNED. \n\n" +
|
||||
"It is ok player.\n" +
|
||||
"You may cheat on us, but your wife cheats on you!";
|
||||
break;
|
||||
case ACTIVE:
|
||||
outString += "Your account status is ACTIVE.\n" +
|
||||
"Do not cheat or status will change.";
|
||||
break;
|
||||
case ADMIN:
|
||||
outString += "You are an admin. By your command?";
|
||||
break;
|
||||
}
|
||||
|
||||
MagicBot.sendResponse(event, outString);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.MagicBot;
|
||||
import discord.RobotSpeak;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import static discord.ChatChannel.ANNOUNCE;
|
||||
|
||||
public class AnnounceChannelHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event, String[] args) {
|
||||
|
||||
String chatText;
|
||||
String outString;
|
||||
|
||||
// Early exit if database unavailable or is not an admin
|
||||
|
||||
if (MagicBot.isAdminEvent(event) == false)
|
||||
return;
|
||||
|
||||
// Nothing to send?
|
||||
|
||||
if (args.length == 0)
|
||||
return;
|
||||
|
||||
// Convert argument array into string;
|
||||
|
||||
chatText = String.join(" ", args);
|
||||
|
||||
// Build String
|
||||
|
||||
if (chatText.startsWith("-r "))
|
||||
outString =
|
||||
"```\n" + "Hello Players \n\n" +
|
||||
chatText.substring(3) + "\n\n" +
|
||||
RobotSpeak.getRobotSpeak() + "\n```";
|
||||
else outString = chatText;
|
||||
|
||||
// Write string to announce channel
|
||||
|
||||
if (ANNOUNCE.textChannel.canTalk())
|
||||
ANNOUNCE.textChannel.sendMessage(outString).queue();
|
||||
|
||||
Logger.info(event.getAuthor().getName() + " announce: " + chatText);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.DiscordAccount;
|
||||
import discord.MagicBot;
|
||||
import discord.RobotSpeak;
|
||||
import engine.Enum;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BanToggleHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event, String[] args) {
|
||||
|
||||
String discordAccountID;
|
||||
Enum.AccountStatus accountStatus;
|
||||
|
||||
// Early exit if database unavailable or is not an admin
|
||||
|
||||
if (MagicBot.isAdminEvent(event) == false)
|
||||
return;
|
||||
|
||||
// Must supply a discord id
|
||||
|
||||
if (args.length != 1) {
|
||||
MagicBot.sendResponse(event, "Must for to supply a valid discord account.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Must be a number!
|
||||
|
||||
discordAccountID = args[0].trim();
|
||||
|
||||
if (discordAccountID.chars().allMatch(Character::isDigit) == false) {
|
||||
MagicBot.sendResponse(event, "Must for to supply a number!");
|
||||
return;
|
||||
}
|
||||
|
||||
List<DiscordAccount> discordAccounts = MagicBot.database.getDiscordAccounts(discordAccountID);
|
||||
|
||||
if (discordAccounts.isEmpty()) {
|
||||
MagicBot.sendResponse(event, "No match for supplied discord account.");
|
||||
return;
|
||||
}
|
||||
|
||||
// toggle ban status
|
||||
|
||||
if (discordAccounts.get(0).status.equals(Enum.AccountStatus.BANNED))
|
||||
accountStatus = Enum.AccountStatus.ACTIVE;
|
||||
else
|
||||
accountStatus = Enum.AccountStatus.BANNED;
|
||||
|
||||
// We have a valid discord ID at this point. Banstick?
|
||||
|
||||
if (MagicBot.database.updateAccountStatus(discordAccountID, accountStatus) == false) {
|
||||
MagicBot.sendResponse(event, "Error occurred while banning player.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Invalidate login server cache
|
||||
|
||||
MagicBot.database.invalidateLoginCache(discordAccountID);
|
||||
|
||||
// Successful ban. Ancillary processing begins
|
||||
|
||||
User bannedUser = MagicBot.jda.getUserById(discordAccountID);
|
||||
String bannedName = (bannedUser == null ? discordAccounts.get(0).gameAccountName : bannedUser.getName());
|
||||
String banString = discordAccounts.size() + " accounts set to " + accountStatus + " for " + discordAccountID + "/" + bannedName;
|
||||
|
||||
MagicBot.sendResponse(event, banString);
|
||||
Logger.info(event.getAuthor().getName() + " " + banString);
|
||||
|
||||
// If we're toggling status to active we're done here.
|
||||
|
||||
if (accountStatus.equals(Enum.AccountStatus.ACTIVE))
|
||||
return;
|
||||
|
||||
// Set users role to noob
|
||||
|
||||
if (bannedUser != null)
|
||||
MagicBot.magicbaneDiscord.removeRoleFromMember(discordAccountID, MagicBot.memberRole).queue();
|
||||
|
||||
// Anounce event in septic tank channel
|
||||
|
||||
banString = "```\n" + "Goodbye Player " + bannedName + "\n\n";
|
||||
banString += RobotSpeak.getRobotInsult() + "\n```";
|
||||
|
||||
if (MagicBot.septicChannel.canTalk())
|
||||
MagicBot.septicChannel.sendMessage(banString).queue();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.MagicBot;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import static discord.ChatChannel.CHANGELOG;
|
||||
|
||||
public class ChangeLogHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event, String[] args) {
|
||||
|
||||
String outString;
|
||||
|
||||
// Early exit if database unavailable or is not an admin
|
||||
|
||||
if (MagicBot.isAdminEvent(event) == false)
|
||||
return;
|
||||
|
||||
// Nothing to send?
|
||||
|
||||
if (args.length == 0)
|
||||
return;
|
||||
|
||||
// Convert argument array into string;
|
||||
|
||||
outString = String.join(" ", args);
|
||||
|
||||
// Write string to changelog channel
|
||||
|
||||
if (CHANGELOG.textChannel.canTalk())
|
||||
CHANGELOG.textChannel.sendMessage(outString).queue();
|
||||
|
||||
Logger.info(event.getAuthor().getName() + " changelog entry: " + outString);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.MagicBot;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class FlashHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event, String[] args) {
|
||||
|
||||
String flashText;
|
||||
|
||||
// Early exit if database unavailable or is not an admin
|
||||
|
||||
if (MagicBot.isAdminEvent(event) == false)
|
||||
return;
|
||||
|
||||
// Nothing to send?
|
||||
|
||||
if (args.length == 0)
|
||||
return;
|
||||
|
||||
// Convert argument array into string;
|
||||
|
||||
flashText = String.join(" ", args);
|
||||
|
||||
// Write string to flash file.
|
||||
|
||||
try {
|
||||
Files.write(Paths.get("flash"), flashText.getBytes());
|
||||
} catch (IOException e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
|
||||
Logger.info(event.getAuthor().getName() + " sent flash: " + flashText);
|
||||
MagicBot.sendResponse(event, "Flash: " + flashText);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.MagicBot;
|
||||
import discord.RobotSpeak;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import static discord.ChatChannel.FORTOFIX;
|
||||
|
||||
public class ForToFixChannelHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event, String[] args) {
|
||||
|
||||
String chatText;
|
||||
String outString;
|
||||
|
||||
// Early exit if database unavailable or is not an admin
|
||||
|
||||
if (MagicBot.isAdminEvent(event) == false)
|
||||
return;
|
||||
|
||||
// Nothing to send?
|
||||
|
||||
if (args.length == 0)
|
||||
return;
|
||||
|
||||
// Convert argument array into string;
|
||||
|
||||
chatText = String.join(" ", args);
|
||||
|
||||
// Build String
|
||||
|
||||
if (chatText.startsWith("-r "))
|
||||
outString =
|
||||
"```\n" + "Hello Players \n\n" +
|
||||
chatText.substring(3) + "\n\n" +
|
||||
RobotSpeak.getRobotSpeak() + "\n```";
|
||||
else outString = chatText;
|
||||
|
||||
// Write string to changelog channel
|
||||
|
||||
if (FORTOFIX.textChannel.canTalk())
|
||||
FORTOFIX.textChannel.sendMessage(outString).queue();
|
||||
|
||||
Logger.info(event.getAuthor().getName() + "fortofix: " + chatText);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.MagicBot;
|
||||
import discord.RobotSpeak;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import static discord.ChatChannel.GENERAL;
|
||||
|
||||
public class GeneralChannelHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event, String[] args) {
|
||||
|
||||
String chatText;
|
||||
String outString;
|
||||
|
||||
// Early exit if database unavailable or is not an admin
|
||||
|
||||
if (MagicBot.isAdminEvent(event) == false)
|
||||
return;
|
||||
|
||||
// Nothing to send?
|
||||
|
||||
if (args.length == 0)
|
||||
return;
|
||||
|
||||
// Convert argument array into string;
|
||||
|
||||
chatText = String.join(" ", args);
|
||||
|
||||
// Build String
|
||||
|
||||
if (chatText.startsWith("-r "))
|
||||
outString =
|
||||
"```\n" + "Hello Players \n\n" +
|
||||
chatText.substring(3) + "\n\n" +
|
||||
RobotSpeak.getRobotSpeak() + "\n```";
|
||||
else outString = chatText;
|
||||
|
||||
// Write string to changelog channel
|
||||
|
||||
if (GENERAL.textChannel.canTalk())
|
||||
GENERAL.textChannel.sendMessage(outString).queue();
|
||||
|
||||
Logger.info(event.getAuthor().getName() + "general: " + chatText);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.MagicBot;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class LogsRequestHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event, String[] args) {
|
||||
|
||||
String logType;
|
||||
int tailCount;
|
||||
String logOutput;
|
||||
|
||||
// Early exit if database unavailable or is not an admin
|
||||
|
||||
if (MagicBot.isAdminEvent(event) == false)
|
||||
return;
|
||||
|
||||
// No arguments supplied?
|
||||
|
||||
if (args.length != 2)
|
||||
return;
|
||||
|
||||
logType = args[0].toLowerCase().trim();
|
||||
|
||||
if ("worldloginmagicbot".contains(logType) == false)
|
||||
return;
|
||||
|
||||
try {
|
||||
tailCount = Integer.parseInt(args[1].trim());
|
||||
} catch (NumberFormatException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Transform logtype to actual file name
|
||||
|
||||
switch (logType) {
|
||||
case "magicbot":
|
||||
logType = "console_magicbot";
|
||||
break;
|
||||
case "world":
|
||||
logType = "console_server";
|
||||
break;
|
||||
case "login":
|
||||
logType = "console_login";
|
||||
break;
|
||||
}
|
||||
|
||||
// Retrieve the data and send back to the user
|
||||
|
||||
logOutput = MagicBot.readLogFile(logType, tailCount);
|
||||
MagicBot.sendResponse(event, logOutput);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.DiscordAccount;
|
||||
import discord.MagicBot;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LookupRequestHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event, String[] args) {
|
||||
|
||||
String searchString = "";
|
||||
String outString;
|
||||
|
||||
// Early exit if database unavailable or is not an admin
|
||||
|
||||
if (MagicBot.isAdminEvent(event) == false)
|
||||
return;
|
||||
|
||||
// No argument supplied?
|
||||
|
||||
if (args.length != 1)
|
||||
return;
|
||||
|
||||
searchString = args[0].toLowerCase();
|
||||
|
||||
List<DiscordAccount> discordAccounts = MagicBot.database.getAccountsByDiscordName(searchString, false);
|
||||
|
||||
if (discordAccounts.isEmpty()) {
|
||||
MagicBot.sendResponse(event,
|
||||
"No accounts found matching string: " + searchString);
|
||||
return;
|
||||
}
|
||||
|
||||
if (discordAccounts.size() >= 20) {
|
||||
MagicBot.sendResponse(event,
|
||||
discordAccounts.size() + "Sorry more than 20 records were returned! " + searchString);
|
||||
return;
|
||||
}
|
||||
|
||||
// Valid request return results
|
||||
|
||||
Logger.info(event.getAuthor().getName() + " lookup on account:" + searchString);
|
||||
|
||||
outString =
|
||||
"The follow accounts matched: " + searchString + "\n\n" +
|
||||
"-------------------\n";
|
||||
|
||||
for (DiscordAccount userAccount : discordAccounts) {
|
||||
|
||||
// Ternary became a bitch, so broke this out.
|
||||
|
||||
User discordUser = MagicBot.jda.getUserById(userAccount.discordAccount);
|
||||
|
||||
if (discordUser != null)
|
||||
outString += discordUser.getName() + discordUser.getDiscriminator() +
|
||||
"/" + userAccount.discordAccount + " ";
|
||||
else
|
||||
outString += userAccount.discordAccount + " *N/A* ";
|
||||
|
||||
outString += userAccount.gameAccountName + " " + userAccount.status.name() + " ";
|
||||
outString += "\n";
|
||||
}
|
||||
MagicBot.sendResponse(event, outString);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.Database;
|
||||
import discord.DiscordAccount;
|
||||
import discord.MagicBot;
|
||||
import engine.Enum;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public class PasswordChangeHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event, String[] args) {
|
||||
|
||||
String discordAccountID = event.getAuthor().getId();
|
||||
DiscordAccount discordAccount;
|
||||
String newPassword;
|
||||
boolean defaulted = false;
|
||||
|
||||
if (Database.online == false) {
|
||||
|
||||
MagicBot.sendResponse(event,
|
||||
"Database currently: OFFLINE\n" +
|
||||
"Try again later!");
|
||||
return;
|
||||
}
|
||||
|
||||
List<DiscordAccount> discordAccounts = MagicBot.database.getDiscordAccounts(discordAccountID);
|
||||
|
||||
// User has no account registered. Change password?
|
||||
|
||||
if (discordAccounts.isEmpty()) {
|
||||
MagicBot.sendResponse(event,
|
||||
"I checked my files twice but could not find your detailings!\n" +
|
||||
"You can easily fix this by asking me for to #register one.\n" +
|
||||
"Only one though. Multiple registrations are not allowed!");
|
||||
return;
|
||||
}
|
||||
|
||||
// All accounts are updated in one lot. Retrieve the first.
|
||||
|
||||
discordAccount = discordAccounts.get(0);
|
||||
|
||||
// Banned or suspended user's get no love.
|
||||
|
||||
if (discordAccount.status.equals(Enum.AccountStatus.BANNED)) {
|
||||
MagicBot.sendResponse(event,
|
||||
"Sorry but that is too much work. \n" +
|
||||
"Your account detailings cannot for to log into game!");
|
||||
return;
|
||||
}
|
||||
|
||||
// User has requested password change within last 24 hours.
|
||||
|
||||
if (discordAccount.lastUpdateRequest != null &&
|
||||
LocalDateTime.now().isBefore(discordAccount.lastUpdateRequest.plusDays(1))) {
|
||||
|
||||
MagicBot.sendResponse(event,
|
||||
"You must wait 24 hours between password requests. \n" +
|
||||
"Last account updatings: " + discordAccount.lastUpdateRequest.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
// No argument choose new random password *he he he*
|
||||
|
||||
if (args.length != 1) {
|
||||
newPassword = MagicBot.generatePassword(8);
|
||||
defaulted = true;
|
||||
} else
|
||||
newPassword = args[0];
|
||||
|
||||
// Validate password with regex
|
||||
|
||||
if (MagicBot.passwordRegex.matcher(newPassword).matches() == false) {
|
||||
|
||||
MagicBot.sendResponse(event,
|
||||
"Your supplied password does not compute.\n" +
|
||||
"New password must satisfy following regex:\n" +
|
||||
"^[\\p{Alnum}]{6,20}$");
|
||||
return;
|
||||
}
|
||||
|
||||
if (newPassword.toLowerCase().equals("newpass")) {
|
||||
MagicBot.sendResponse(event,
|
||||
"newpass is not valid password.\n" +
|
||||
"Have brain player!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Password validates let's change it
|
||||
|
||||
if (MagicBot.database.updateAccountPassword(discordAccount.discordAccount, newPassword) == true) {
|
||||
|
||||
MagicBot.sendResponse(event,
|
||||
"Please allow short minute for to update account detailings.\n" +
|
||||
"Login Server is hosted in bathroom above toilet. Must flush!\n" +
|
||||
(defaulted == true ? "As you did not for to supply new pass I chose one for you.\n" : "") +
|
||||
"New Password: " + newPassword);
|
||||
}
|
||||
|
||||
Logger.info(event.getAuthor().getName() + " reset their password");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.MagicBot;
|
||||
import discord.RobotSpeak;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import static discord.ChatChannel.POLITICAL;
|
||||
|
||||
public class PoliticalChannelHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event, String[] args) {
|
||||
|
||||
String chatText;
|
||||
String outString;
|
||||
|
||||
// Early exit if database unavailable or is not an admin
|
||||
|
||||
if (MagicBot.isAdminEvent(event) == false)
|
||||
return;
|
||||
|
||||
// Nothing to send?
|
||||
|
||||
if (args.length == 0)
|
||||
return;
|
||||
|
||||
// Convert argument array into string;
|
||||
|
||||
chatText = String.join(" ", args);
|
||||
|
||||
// Build String
|
||||
|
||||
if (chatText.startsWith("-r "))
|
||||
outString =
|
||||
"```\n" + "Hello Players \n\n" +
|
||||
chatText.substring(3) + "\n\n" +
|
||||
RobotSpeak.getRobotSpeak() + "\n```";
|
||||
else outString = chatText;
|
||||
|
||||
// Write string to changelog channel
|
||||
|
||||
if (POLITICAL.textChannel.canTalk())
|
||||
POLITICAL.textChannel.sendMessage(outString).queue();
|
||||
|
||||
Logger.info(event.getAuthor().getName() + " politics: " + chatText);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.MagicBot;
|
||||
import discord.RobotSpeak;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import static discord.ChatChannel.RECRUIT;
|
||||
|
||||
public class RecruitChannelHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event, String[] args) {
|
||||
|
||||
String chatText;
|
||||
String outString;
|
||||
|
||||
// Early exit if database unavailable or is not an admin
|
||||
|
||||
if (MagicBot.isAdminEvent(event) == false)
|
||||
return;
|
||||
|
||||
// Nothing to send?
|
||||
|
||||
if (args.length == 0)
|
||||
return;
|
||||
|
||||
// Convert argument array into string;
|
||||
|
||||
chatText = String.join(" ", args);
|
||||
|
||||
// Build String
|
||||
|
||||
if (chatText.startsWith("-r "))
|
||||
outString =
|
||||
"```\n" + "Hello Players \n\n" +
|
||||
chatText.substring(3) + "\n\n" +
|
||||
RobotSpeak.getRobotSpeak() + "\n```";
|
||||
else outString = chatText;
|
||||
|
||||
// Write string to changelog channel
|
||||
|
||||
if (RECRUIT.textChannel.canTalk())
|
||||
RECRUIT.textChannel.sendMessage(outString).queue();
|
||||
|
||||
Logger.info(event.getAuthor().getName() + "recruit: " + chatText);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.Database;
|
||||
import discord.DiscordAccount;
|
||||
import discord.MagicBot;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RegisterAccountHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event, String[] args) {
|
||||
|
||||
String discordAccountID = event.getAuthor().getId();
|
||||
String discordUserName = event.getAuthor().getName();
|
||||
String discordPassword = MagicBot.generatePassword(8);
|
||||
String accountName;
|
||||
|
||||
if (Database.online == false) {
|
||||
MagicBot.sendResponse(event,
|
||||
"Database currently: OFFLINE\n" +
|
||||
"Try again later!");
|
||||
return;
|
||||
}
|
||||
|
||||
List<DiscordAccount> discordAccounts = MagicBot.database.getDiscordAccounts(discordAccountID);
|
||||
|
||||
// If we have previously registered this discord account let them know
|
||||
// the current status.
|
||||
|
||||
if (discordAccounts.isEmpty() == false) {
|
||||
MagicBot.sendResponse(event,
|
||||
"It seems you already have an account registered.\n" +
|
||||
"Do you need #account detailings or more general #help?");
|
||||
MagicBot.magicbaneDiscord.addRoleToMember(discordAccountID, MagicBot.memberRole).queue();
|
||||
return;
|
||||
}
|
||||
|
||||
// if user supplied argument let's validate it.
|
||||
// otherwise build an account name based on their discord account.
|
||||
|
||||
if (args.length != 1) {
|
||||
|
||||
// Build account name using Discord name along with their discriminator.
|
||||
|
||||
accountName = discordUserName.replaceAll("\\s+", "");
|
||||
accountName += "#" + event.getAuthor().getDiscriminator();
|
||||
} else {
|
||||
|
||||
// Validate account name with regex
|
||||
|
||||
accountName = args[0].replaceAll("\\s+", "");
|
||||
|
||||
if (MagicBot.accountNameRegex.matcher(accountName).matches() == false) {
|
||||
|
||||
MagicBot.sendResponse(event,
|
||||
"Your supplied account name does not compute.\n" +
|
||||
"Account names must satisfy following regex:\n" +
|
||||
"^[\\p{Alnum}]{6,20}$");
|
||||
return;
|
||||
}
|
||||
|
||||
if (accountName.toLowerCase().equals("accountname")) {
|
||||
MagicBot.sendResponse(event,
|
||||
"accountname is not valid account name.\n" +
|
||||
"Have brain player!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure account doesn't already exist.
|
||||
|
||||
if (MagicBot.database.getAccountsByDiscordName(accountName, true).isEmpty() == false) {
|
||||
|
||||
MagicBot.sendResponse(event,
|
||||
"It seems this account name is already taken.\n" +
|
||||
"Perhaps try one less common in frequency.");
|
||||
return;
|
||||
}
|
||||
|
||||
// If there is no registered discord account we oblige and create 4
|
||||
// account based upon his current discord *name* not the ID.
|
||||
|
||||
if (MagicBot.database.registerDiscordAccount(discordAccountID, accountName, discordPassword) == true) {
|
||||
|
||||
Logger.info("Account " + accountName + " created for: " + discordUserName + " " + discordAccountID);
|
||||
|
||||
MagicBot.sendResponse(event,
|
||||
"Welcome to MagicBane!\n" +
|
||||
"-------------------\n" +
|
||||
"I have registered the following accounts to your discord.\n\n" +
|
||||
"1) " + accountName + "#1" + " 2) " + accountName + "#2\n" +
|
||||
"3) " + accountName + "#3" + " 4) " + accountName + "#4\n\n" +
|
||||
"Your default password is: " + discordPassword + "\n" +
|
||||
"Ask me #help for to receive list of robot featurings.\n\n" +
|
||||
"http://magicbane.com/tinyinstaller.zip" +
|
||||
"\n\nPlay for to Crush!");
|
||||
|
||||
// Add Discord member privileges.
|
||||
|
||||
MagicBot.magicbaneDiscord.addRoleToMember(discordAccountID, MagicBot.memberRole).queue();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// The call to the stored procedure abended. Report to player
|
||||
// and return.
|
||||
|
||||
Logger.error("Creating account: " + accountName + " for: " + discordUserName + " " + discordAccountID);
|
||||
Database.online = false;
|
||||
|
||||
MagicBot.sendResponse(event,
|
||||
"-------------------\n" +
|
||||
"I for to had internal error while registering your\n" +
|
||||
"account. This has been reported. Try again later!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.MagicBot;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class RulesRequestHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event) {
|
||||
|
||||
String outString;
|
||||
|
||||
// Add greeting
|
||||
|
||||
outString = "-No hacking.\n";
|
||||
outString += "-No cheating. If you cheat, we will delete.\n";
|
||||
outString += "-Players limited to 4 concurrent accounts.\n";
|
||||
outString += "-Share accounts at own risk.\n";
|
||||
outString += "-No refunds";
|
||||
|
||||
MagicBot.sendResponse(event, outString);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.MagicBot;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ServerRequestHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event, String[] args) {
|
||||
|
||||
String serverCommand;
|
||||
String execString = "";
|
||||
|
||||
// Early exit if database unavailable or is not an admin
|
||||
|
||||
if (MagicBot.isAdminEvent(event) == false)
|
||||
return;
|
||||
|
||||
// No command supplied?
|
||||
|
||||
if (args.length != 1)
|
||||
return;
|
||||
|
||||
serverCommand = args[0].toLowerCase().trim();
|
||||
|
||||
// only reboot or shutdown
|
||||
|
||||
if ("rebootshutdown".contains(serverCommand) == false)
|
||||
return;
|
||||
|
||||
switch (serverCommand) {
|
||||
|
||||
case "reboot":
|
||||
execString = "/bin/sh -c ./mbrestart.sh";
|
||||
break;
|
||||
case "shutdown":
|
||||
execString = "/bin/sh -c ./mbkill.sh";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (execString.isEmpty() == false) {
|
||||
try {
|
||||
Runtime.getRuntime().exec(execString);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
MagicBot.sendResponse(event, "MagicBot has executed your " + serverCommand);
|
||||
Logger.info(event.getAuthor().getName() + " told server to " + serverCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.Database;
|
||||
import discord.MagicBot;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
public class SetAvailHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event, String[] args) {
|
||||
|
||||
String availStatus;
|
||||
String availPass;
|
||||
|
||||
if (args.length != 2)
|
||||
return;
|
||||
|
||||
availStatus = args[0].toLowerCase().trim();
|
||||
|
||||
// only on/off
|
||||
|
||||
if ("truefalse".contains(availStatus) == false)
|
||||
return;
|
||||
|
||||
// Set avail is password driven
|
||||
|
||||
availPass = args[1].toLowerCase().trim();
|
||||
|
||||
if ("myshoes123".equals(availPass) == false)
|
||||
return;
|
||||
|
||||
// Authenticated so change availstatus
|
||||
|
||||
if (availStatus.equals("true"))
|
||||
Database.online = true;
|
||||
else
|
||||
Database.online = false;
|
||||
|
||||
Logger.info(event.getAuthor().getName() + " set avail status to: " + Database.online);
|
||||
MagicBot.sendResponse(event, "Avail status set to: " + Database.online);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.Database;
|
||||
import discord.MagicBot;
|
||||
import engine.gameManager.ConfigManager;
|
||||
import engine.server.login.LoginServer;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class StatusRequestHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event) {
|
||||
|
||||
String outString;
|
||||
|
||||
// Add version information
|
||||
outString = "MagicBot: " + ConfigManager.MB_MAGICBOT_BOTVERSION.getValue() + "\n" +
|
||||
"MagicBane: " + ConfigManager.MB_MAGICBOT_GAMEVERSION.getValue() + "\n";
|
||||
|
||||
// Add server status info
|
||||
outString += "\nServer Status: ";
|
||||
|
||||
if (LoginServer.isPortInUse(Integer.parseInt(ConfigManager.MB_BIND_ADDR.getValue())))
|
||||
outString += "ONLINE\n";
|
||||
else
|
||||
outString += "OFFLINE\n";
|
||||
|
||||
if (Database.online == true)
|
||||
outString += MagicBot.database.getPopulationSTring();
|
||||
else
|
||||
outString += "Database offline: no population data.";
|
||||
|
||||
MagicBot.sendResponse(event, outString);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package discord.handlers;
|
||||
|
||||
import discord.MagicBot;
|
||||
import discord.RobotSpeak;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static discord.ChatChannel.SEPTIC;
|
||||
|
||||
public class TrashRequestHandler {
|
||||
|
||||
public static void handleRequest(MessageReceivedEvent event, String[] args) {
|
||||
|
||||
String outString;
|
||||
int trashCount = 0;
|
||||
|
||||
// Early exit if database unavailable or is not an admin
|
||||
|
||||
if (MagicBot.isAdminEvent(event) == false)
|
||||
return;
|
||||
|
||||
if (args.length == 0) {
|
||||
outString = MagicBot.database.getTrashFile();
|
||||
MagicBot.sendResponse(event, outString);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args[0].equals("flush") == true) {
|
||||
|
||||
// Empty the trash!
|
||||
|
||||
trashCount = MagicBot.database.getTrashCount();
|
||||
|
||||
if (trashCount == 0)
|
||||
return;
|
||||
|
||||
// Anounce event in septic tank channel
|
||||
|
||||
outString = "```\n" + trashCount + " Player Character were for to deleted due to verified cheatings. \n\n";
|
||||
outString += MagicBot.database.getTrashList() + "\n\n";
|
||||
outString += RobotSpeak.getRobotInsult() + "\n```";
|
||||
|
||||
if (SEPTIC.textChannel.canTalk())
|
||||
SEPTIC.textChannel.sendMessage(outString).queue();
|
||||
|
||||
try {
|
||||
Files.write(Paths.get("trash"), "".getBytes());
|
||||
outString = "Flushing trash players...\n";
|
||||
MagicBot.sendResponse(event, outString);
|
||||
} catch (IOException e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (args[0].equals("detail") == true) {
|
||||
|
||||
outString = MagicBot.database.getTrashDetail();
|
||||
MagicBot.sendResponse(event, outString);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user