Browse Source

Generic ChatChannelHandler created.

master
MagicBot 2 years ago
parent
commit
920fcd4b8e
  1. 12
      src/discord/MagicBot.java
  2. 55
      src/discord/handlers/AnnounceChannelHandler.java
  3. 44
      src/discord/handlers/ChangeLogHandler.java
  4. 56
      src/discord/handlers/ForToFixChannelHandler.java
  5. 56
      src/discord/handlers/GeneralChannelHandler.java
  6. 55
      src/discord/handlers/PoliticalChannelHandler.java
  7. 56
      src/discord/handlers/RecruitChannelHandler.java

12
src/discord/MagicBot.java

@ -182,22 +182,22 @@ public class MagicBot extends ListenerAdapter {
PasswordChangeHandler.handleRequest(event, args); PasswordChangeHandler.handleRequest(event, args);
break; break;
case "#changelog": case "#changelog":
ChangeLogHandler.handleRequest(event, args); ChatChannelHandler.handleRequest(ChatChannel.CHANGELOG, event, args);
break; break;
case "#general": case "#general":
GeneralChannelHandler.handleRequest(event, args); ChatChannelHandler.handleRequest(ChatChannel.GENERAL, event, args);
break; break;
case "#politics": case "#politics":
PoliticalChannelHandler.handleRequest(event, args); ChatChannelHandler.handleRequest(ChatChannel.POLITICAL, event, args);
break; break;
case "#announce": case "#announce":
AnnounceChannelHandler.handleRequest(event, args); ChatChannelHandler.handleRequest(ChatChannel.ANNOUNCE, event, args);
break; break;
case "#bug": case "#bug":
ForToFixChannelHandler.handleRequest(event, args); ChatChannelHandler.handleRequest(ChatChannel.FORTOFIX, event, args);
break; break;
case "#recruit": case "#recruit":
RecruitChannelHandler.handleRequest(event, args); ChatChannelHandler.handleRequest(ChatChannel.RECRUIT, event, args);
break; break;
case "#lookup": case "#lookup":
LookupRequestHandler.handleRequest(event, args); LookupRequestHandler.handleRequest(event, args);

55
src/discord/handlers/AnnounceChannelHandler.java

@ -1,55 +0,0 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// 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);
}
}

44
src/discord/handlers/ChangeLogHandler.java

@ -1,44 +0,0 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// 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);
}
}

56
src/discord/handlers/ForToFixChannelHandler.java

@ -1,56 +0,0 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// 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);
}
}

56
src/discord/handlers/GeneralChannelHandler.java

@ -1,56 +0,0 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// 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);
}
}

55
src/discord/handlers/PoliticalChannelHandler.java

@ -1,55 +0,0 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// 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);
}
}

56
src/discord/handlers/RecruitChannelHandler.java

@ -1,56 +0,0 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// 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);
}
}
Loading…
Cancel
Save