|
|
@ -79,7 +79,7 @@ import org.pircbotx.hooks.ListenerAdapter;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public final class PurpleBot {
|
|
|
|
public final class PurpleBot {
|
|
|
|
|
|
|
|
|
|
|
|
private PircBotX bot;
|
|
|
|
protected PircBotX bot;
|
|
|
|
|
|
|
|
|
|
|
|
protected boolean goodBot;
|
|
|
|
protected boolean goodBot;
|
|
|
|
public final PurpleIRC plugin;
|
|
|
|
public final PurpleIRC plugin;
|
|
|
@ -118,6 +118,7 @@ public final class PurpleBot {
|
|
|
|
public ArrayList<String> botChannels;
|
|
|
|
public ArrayList<String> botChannels;
|
|
|
|
public CaseInsensitiveMap<Collection<String>> channelNicks;
|
|
|
|
public CaseInsensitiveMap<Collection<String>> channelNicks;
|
|
|
|
public CaseInsensitiveMap<Collection<String>> tabIgnoreNicks;
|
|
|
|
public CaseInsensitiveMap<Collection<String>> tabIgnoreNicks;
|
|
|
|
|
|
|
|
public CaseInsensitiveMap<Boolean> tabIgnoreDuplicates;
|
|
|
|
public CaseInsensitiveMap<Collection<String>> filters;
|
|
|
|
public CaseInsensitiveMap<Collection<String>> filters;
|
|
|
|
public CaseInsensitiveMap<String> channelPassword;
|
|
|
|
public CaseInsensitiveMap<String> channelPassword;
|
|
|
|
public CaseInsensitiveMap<String> channelTopic;
|
|
|
|
public CaseInsensitiveMap<String> channelTopic;
|
|
|
@ -173,6 +174,7 @@ public final class PurpleBot {
|
|
|
|
private int reconnectCount;
|
|
|
|
private int reconnectCount;
|
|
|
|
private final ReadWriteLock rwl;
|
|
|
|
private final ReadWriteLock rwl;
|
|
|
|
private final Lock wl;
|
|
|
|
private final Lock wl;
|
|
|
|
|
|
|
|
public String sslInfo = "";
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -182,7 +184,7 @@ public final class PurpleBot {
|
|
|
|
public PurpleBot(File file, PurpleIRC plugin) {
|
|
|
|
public PurpleBot(File file, PurpleIRC plugin) {
|
|
|
|
this.rwl = new ReentrantReadWriteLock();
|
|
|
|
this.rwl = new ReentrantReadWriteLock();
|
|
|
|
this.wl = rwl.writeLock();
|
|
|
|
this.wl = rwl.writeLock();
|
|
|
|
fileName = file.getName();
|
|
|
|
this.fileName = file.getName();
|
|
|
|
this.altNicks = new ArrayList<>();
|
|
|
|
this.altNicks = new ArrayList<>();
|
|
|
|
this.connected = false;
|
|
|
|
this.connected = false;
|
|
|
|
this.botChannels = new ArrayList<>();
|
|
|
|
this.botChannels = new ArrayList<>();
|
|
|
@ -216,6 +218,7 @@ public final class PurpleBot {
|
|
|
|
this.channelTopic = new CaseInsensitiveMap<>();
|
|
|
|
this.channelTopic = new CaseInsensitiveMap<>();
|
|
|
|
this.channelPassword = new CaseInsensitiveMap<>();
|
|
|
|
this.channelPassword = new CaseInsensitiveMap<>();
|
|
|
|
this.tabIgnoreNicks = new CaseInsensitiveMap<>();
|
|
|
|
this.tabIgnoreNicks = new CaseInsensitiveMap<>();
|
|
|
|
|
|
|
|
this.tabIgnoreDuplicates = new CaseInsensitiveMap<>();
|
|
|
|
this.filters = new CaseInsensitiveMap<>();
|
|
|
|
this.filters = new CaseInsensitiveMap<>();
|
|
|
|
this.channelNicks = new CaseInsensitiveMap<>();
|
|
|
|
this.channelNicks = new CaseInsensitiveMap<>();
|
|
|
|
this.channelTopicChanserv = new CaseInsensitiveMap<>();
|
|
|
|
this.channelTopicChanserv = new CaseInsensitiveMap<>();
|
|
|
@ -485,32 +488,6 @@ public final class PurpleBot {
|
|
|
|
messageQueue.add(new IRCMessage(target, plugin.colorConverter.gameColorsToIrc(message), true));
|
|
|
|
messageQueue.add(new IRCMessage(target, plugin.colorConverter.gameColorsToIrc(message), true));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void blockingIRCMessage(final String target, final String message) {
|
|
|
|
|
|
|
|
if (!this.isConnected()) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
plugin.logDebug("[blockingIRCMessage] About to send IRC message to " + target);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
bot.sendIRC().message(target, plugin.colorConverter.gameColorsToIrc(message));
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
plugin.logError("Problem sending IRC message: " + ex.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
plugin.logDebug("[blockingIRCMessage] Message sent to " + target);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void blockingCTCPMessage(final String target, final String message) {
|
|
|
|
|
|
|
|
if (!this.isConnected()) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
plugin.logDebug("[blockingCTCPMessage] About to send IRC message to " + target);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
bot.sendIRC().ctcpResponse(target, plugin.colorConverter.gameColorsToIrc(message));
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
plugin.logError("Problem sending IRC CTCP message: " + ex.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
plugin.logDebug("[blockingCTCPMessage] Message sent to " + target);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void asyncCTCPCommand(final String target, final String command) {
|
|
|
|
public void asyncCTCPCommand(final String target, final String command) {
|
|
|
|
if (!this.isConnected()) {
|
|
|
|
if (!this.isConnected()) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -832,6 +809,9 @@ public final class PurpleBot {
|
|
|
|
channelPrefix.put(channelName, config.getString("channels." + enChannelName + ".prefix", ""));
|
|
|
|
channelPrefix.put(channelName, config.getString("channels." + enChannelName + ".prefix", ""));
|
|
|
|
plugin.logDebug(" ChannelPrefix => " + channelPrefix.get(channelName));
|
|
|
|
plugin.logDebug(" ChannelPrefix => " + channelPrefix.get(channelName));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tabIgnoreDuplicates.put(channelName, config.getBoolean("channels." + enChannelName + ".custom-tab-ignore-duplicates", false));
|
|
|
|
|
|
|
|
plugin.logDebug(" TabIgnoreDuplicates => " + tabIgnoreDuplicates.get(channelName));
|
|
|
|
|
|
|
|
|
|
|
|
// build channel op list
|
|
|
|
// build channel op list
|
|
|
|
Collection<String> cOps = new ArrayList<>();
|
|
|
|
Collection<String> cOps = new ArrayList<>();
|
|
|
|
for (String channelOper : config.getStringList("channels." + enChannelName + ".ops")) {
|
|
|
|
for (String channelOper : config.getStringList("channels." + enChannelName + ".ops")) {
|
|
|
@ -907,7 +887,7 @@ public final class PurpleBot {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tabIgnoreNicks.put(channelName, t);
|
|
|
|
tabIgnoreNicks.put(channelName, t);
|
|
|
|
if (tabIgnoreNicks.isEmpty()) {
|
|
|
|
if (tabIgnoreNicks.isEmpty()) {
|
|
|
|
plugin.logInfo("World list is empty!");
|
|
|
|
plugin.logInfo("Tab ignore list is empty!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// build valid world list
|
|
|
|
// build valid world list
|
|
|
@ -1000,16 +980,17 @@ public final class PurpleBot {
|
|
|
|
+ "Reload for the change to take effect.");
|
|
|
|
+ "Reload for the change to take effect.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isPlayerInValidWorld(Player player, String channelName) {
|
|
|
|
public boolean isPlayerInValidWorld(Player player, String channelName) {
|
|
|
|
|
|
|
|
boolean validWorld = false;
|
|
|
|
|
|
|
|
String worldName = player.getWorld().getName();
|
|
|
|
if (worldList.containsKey(channelName)) {
|
|
|
|
if (worldList.containsKey(channelName)) {
|
|
|
|
if (worldList.get(channelName).contains("*")) {
|
|
|
|
if (worldList.get(channelName).contains("*")
|
|
|
|
return true;
|
|
|
|
|| worldList.get(channelName).contains(worldName)) {
|
|
|
|
}
|
|
|
|
validWorld = true;
|
|
|
|
if (worldList.get(channelName).contains(player.getWorld().getName())) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
plugin.logDebug("[isPlayerInValidWorld] [p: " + player.getName() + "] [w: " + worldName + "] [b: " + validWorld + "]");
|
|
|
|
|
|
|
|
return validWorld;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -1027,9 +1008,7 @@ public final class PurpleBot {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
if (!isPlayerInValidWorld(player, channelName)) {
|
|
|
|
if (isPlayerInValidWorld(player, channelName)) {
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plugin.fcHook != null) {
|
|
|
|
if (plugin.fcHook != null) {
|
|
|
|
String playerChatMode;
|
|
|
|
String playerChatMode;
|
|
|
|
String playerFactionName;
|
|
|
|
String playerFactionName;
|
|
|
@ -1063,13 +1042,9 @@ public final class PurpleBot {
|
|
|
|
plugin.logDebug("No Factions");
|
|
|
|
plugin.logDebug("No Factions");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.GAME_CHAT)) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.GAME_CHAT)) {
|
|
|
|
plugin.logDebug("[" + TemplateName.GAME_CHAT + "] => "
|
|
|
|
|
|
|
|
+ channelName + " => " + message);
|
|
|
|
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(botNick, TemplateName.GAME_CHAT), message));
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(botNick, TemplateName.GAME_CHAT), message));
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
plugin.logDebug("Ignoring message due to "
|
|
|
|
|
|
|
|
+ TemplateName.GAME_CHAT + " not being listed.");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1100,9 +1075,7 @@ public final class PurpleBot {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
if (!isPlayerInValidWorld(player, channelName)) {
|
|
|
|
if (isPlayerInValidWorld(player, channelName)) {
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String hChannel = chatter.getActiveChannel().getName();
|
|
|
|
String hChannel = chatter.getActiveChannel().getName();
|
|
|
|
String hNick = chatter.getActiveChannel().getNick();
|
|
|
|
String hNick = chatter.getActiveChannel().getNick();
|
|
|
|
String hColor = chatColor.toString();
|
|
|
|
String hColor = chatColor.toString();
|
|
|
@ -1118,6 +1091,7 @@ public final class PurpleBot {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void mcMMOAdminChat(Player player, String message) {
|
|
|
|
public void mcMMOAdminChat(Player player, String message) {
|
|
|
|
if (!this.isConnected()) {
|
|
|
|
if (!this.isConnected()) {
|
|
|
@ -1128,9 +1102,7 @@ public final class PurpleBot {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
if (!isPlayerInValidWorld(player, channelName)) {
|
|
|
|
if (isPlayerInValidWorld(player, channelName)) {
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.MCMMO_ADMIN_CHAT)) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.MCMMO_ADMIN_CHAT)) {
|
|
|
|
plugin.logDebug("Sending message because " + TemplateName.MCMMO_ADMIN_CHAT + " is enabled.");
|
|
|
|
plugin.logDebug("Sending message because " + TemplateName.MCMMO_ADMIN_CHAT + " is enabled.");
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
@ -1142,6 +1114,7 @@ public final class PurpleBot {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void mcMMOPartyChat(Player player, String partyName, String message) {
|
|
|
|
public void mcMMOPartyChat(Player player, String partyName, String message) {
|
|
|
|
if (!this.isConnected()) {
|
|
|
|
if (!this.isConnected()) {
|
|
|
@ -1152,9 +1125,7 @@ public final class PurpleBot {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
if (!isPlayerInValidWorld(player, channelName)) {
|
|
|
|
if (isPlayerInValidWorld(player, channelName)) {
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.MCMMO_PARTY_CHAT)) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.MCMMO_PARTY_CHAT)) {
|
|
|
|
plugin.logDebug("Sending message because " + TemplateName.MCMMO_PARTY_CHAT + " is enabled.");
|
|
|
|
plugin.logDebug("Sending message because " + TemplateName.MCMMO_PARTY_CHAT + " is enabled.");
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
@ -1166,6 +1137,7 @@ public final class PurpleBot {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void mcMMOChat(Player player, String message) {
|
|
|
|
public void mcMMOChat(Player player, String message) {
|
|
|
|
if (!this.isConnected()) {
|
|
|
|
if (!this.isConnected()) {
|
|
|
@ -1176,9 +1148,7 @@ public final class PurpleBot {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
if (!isPlayerInValidWorld(player, channelName)) {
|
|
|
|
if (isPlayerInValidWorld(player, channelName)) {
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.MCMMO_CHAT)) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.MCMMO_CHAT)) {
|
|
|
|
plugin.logDebug("Sending message because " + TemplateName.MCMMO_CHAT + " is enabled.");
|
|
|
|
plugin.logDebug("Sending message because " + TemplateName.MCMMO_CHAT + " is enabled.");
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
@ -1190,34 +1160,6 @@ public final class PurpleBot {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void townyChat(Player player, com.palmergames.bukkit.TownyChat.channels.Channel townyChannel, String message) {
|
|
|
|
|
|
|
|
if (!this.isConnected()) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (floodChecker.isSpam(player)) {
|
|
|
|
|
|
|
|
sendFloodWarning(player);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plugin.tcHook != null) {
|
|
|
|
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
|
|
|
|
if (!isPlayerInValidWorld(player, channelName)) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
plugin.logDebug("townyChat: Checking for towny-"
|
|
|
|
|
|
|
|
+ townyChannel.getName() + "-chat"
|
|
|
|
|
|
|
|
+ " or " + "towny-" + townyChannel.getChannelTag() + "-chat"
|
|
|
|
|
|
|
|
+ " or towny-chat");
|
|
|
|
|
|
|
|
if (isMessageEnabled(channelName, "towny-" + townyChannel.getName() + "-chat")
|
|
|
|
|
|
|
|
|| isMessageEnabled(channelName, "towny-" + townyChannel.getChannelTag() + "-chat")
|
|
|
|
|
|
|
|
|| isMessageEnabled(channelName, "towny-chat")
|
|
|
|
|
|
|
|
|| isMessageEnabled(channelName, "towny-channel-chat")) {
|
|
|
|
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
|
|
|
|
.chatTownyChannelTokenizer(player, townyChannel, message,
|
|
|
|
|
|
|
|
plugin.getMsgTemplate(botNick, "towny-channel-chat")));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void heroAction(Chatter chatter, ChatColor chatColor, String message) {
|
|
|
|
public void heroAction(Chatter chatter, ChatColor chatColor, String message) {
|
|
|
@ -1476,7 +1418,9 @@ public final class PurpleBot {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
|
|
|
|
plugin.logDebug("dynmapWebChat: " + channelName);
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.DYNMAP_WEB_CHAT)) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.DYNMAP_WEB_CHAT)) {
|
|
|
|
|
|
|
|
plugin.logDebug("dynmapWebChat: sending message");
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
.dynmapWebChatToIRCTokenizer(source, name, plugin.getMsgTemplate(
|
|
|
|
.dynmapWebChatToIRCTokenizer(source, name, plugin.getMsgTemplate(
|
|
|
|
botNick, TemplateName.DYNMAP_WEB_CHAT),
|
|
|
|
botNick, TemplateName.DYNMAP_WEB_CHAT),
|
|
|
@ -1512,12 +1456,8 @@ public final class PurpleBot {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.REDDIT_MESSAGES)) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.REDDIT_MESSAGES)) {
|
|
|
|
plugin.logDebug("Checking if " + TemplateName.REDDIT_MESSAGES + " is enabled... YES");
|
|
|
|
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer.gameChatToIRCTokenizer(plugin.getMsgTemplate(botNick, TemplateName.REDDIT_MESSAGES), message));
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer.gameChatToIRCTokenizer(plugin.getMsgTemplate(botNick, TemplateName.REDDIT_MESSAGES), message));
|
|
|
|
} else {
|
|
|
|
|
|
|
|
plugin.logDebug("Checking if " + TemplateName.REDDIT_MESSAGES + " is enabled... NOPE");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1531,23 +1471,16 @@ public final class PurpleBot {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.GAME_JOIN)) {
|
|
|
|
|
|
|
|
if (!isPlayerInValidWorld(player, channelName)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hideJoinWhenVanished.get(channelName)) {
|
|
|
|
if (hideJoinWhenVanished.get(channelName)) {
|
|
|
|
plugin.logDebug("Checking if player " + player.getName() + " is vanished.");
|
|
|
|
|
|
|
|
if (plugin.vanishHook.isVanished(player)) {
|
|
|
|
if (plugin.vanishHook.isVanished(player)) {
|
|
|
|
plugin.logDebug("Not sending join message to IRC for player "
|
|
|
|
|
|
|
|
+ player.getName() + " due to being vanished.");
|
|
|
|
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.GAME_JOIN)
|
|
|
|
|
|
|
|
&& isPlayerInValidWorld(player, channelName)) {
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
botNick, TemplateName.GAME_JOIN), message));
|
|
|
|
botNick, TemplateName.GAME_JOIN), message));
|
|
|
|
} else {
|
|
|
|
|
|
|
|
plugin.logDebug("Not sending join message due to " + TemplateName.GAME_JOIN + " being disabled");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1562,19 +1495,13 @@ public final class PurpleBot {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.GAME_QUIT)) {
|
|
|
|
|
|
|
|
if (!isPlayerInValidWorld(player, channelName)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hideQuitWhenVanished.get(channelName)) {
|
|
|
|
if (hideQuitWhenVanished.get(channelName)) {
|
|
|
|
plugin.logDebug("Checking if player " + player.getName()
|
|
|
|
|
|
|
|
+ " is vanished.");
|
|
|
|
|
|
|
|
if (plugin.vanishHook.isVanished(player)) {
|
|
|
|
if (plugin.vanishHook.isVanished(player)) {
|
|
|
|
plugin.logDebug("Not sending quit message to IRC for player "
|
|
|
|
|
|
|
|
+ player.getName() + " due to being vanished.");
|
|
|
|
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.GAME_QUIT)
|
|
|
|
|
|
|
|
&& isPlayerInValidWorld(player, channelName)) {
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
botNick, TemplateName.GAME_QUIT), message));
|
|
|
|
botNick, TemplateName.GAME_QUIT), message));
|
|
|
@ -1592,15 +1519,11 @@ public final class PurpleBot {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.FAKE_JOIN)) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.FAKE_JOIN)
|
|
|
|
if (!isPlayerInValidWorld(player, channelName)) {
|
|
|
|
&& isPlayerInValidWorld(player, channelName)) {
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
botNick, TemplateName.FAKE_JOIN), message));
|
|
|
|
botNick, TemplateName.FAKE_JOIN), message));
|
|
|
|
} else {
|
|
|
|
|
|
|
|
plugin.logDebug("Not sending join message due to " + TemplateName.FAKE_JOIN + " being disabled");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1615,10 +1538,8 @@ public final class PurpleBot {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.FAKE_QUIT)) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.FAKE_QUIT)
|
|
|
|
if (!isPlayerInValidWorld(player, channelName)) {
|
|
|
|
&& isPlayerInValidWorld(player, channelName)) {
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
botNick, TemplateName.FAKE_QUIT), message));
|
|
|
|
botNick, TemplateName.FAKE_QUIT), message));
|
|
|
@ -1637,10 +1558,8 @@ public final class PurpleBot {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String message = achievement.toString();
|
|
|
|
String message = achievement.toString();
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.GAME_ACHIEVEMENT)) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.GAME_ACHIEVEMENT)
|
|
|
|
if (!isPlayerInValidWorld(player, channelName)) {
|
|
|
|
&& isPlayerInValidWorld(player, channelName)) {
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
botNick, TemplateName.GAME_ACHIEVEMENT), message));
|
|
|
|
botNick, TemplateName.GAME_ACHIEVEMENT), message));
|
|
|
@ -1659,10 +1578,8 @@ public final class PurpleBot {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String message = gameMode.toString();
|
|
|
|
String message = gameMode.toString();
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.GAME_MODE)) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.GAME_MODE)
|
|
|
|
if (!isPlayerInValidWorld(player, channelName)) {
|
|
|
|
&& isPlayerInValidWorld(player, channelName)) {
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
botNick, TemplateName.GAME_MODE), message));
|
|
|
|
botNick, TemplateName.GAME_MODE), message));
|
|
|
@ -1681,10 +1598,8 @@ public final class PurpleBot {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.GAME_KICK)) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.GAME_KICK)
|
|
|
|
if (!isPlayerInValidWorld(player, channelName)) {
|
|
|
|
&& isPlayerInValidWorld(player, channelName)) {
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
.gameKickTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
.gameKickTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
botNick, TemplateName.GAME_KICK), message, reason));
|
|
|
|
botNick, TemplateName.GAME_KICK), message, reason));
|
|
|
@ -1706,10 +1621,8 @@ public final class PurpleBot {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.GAME_ACTION)) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.GAME_ACTION)
|
|
|
|
if (!isPlayerInValidWorld(player, channelName)) {
|
|
|
|
&& isPlayerInValidWorld(player, channelName)) {
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
botNick, TemplateName.GAME_ACTION), message));
|
|
|
|
botNick, TemplateName.GAME_ACTION), message));
|
|
|
@ -1729,15 +1642,14 @@ public final class PurpleBot {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
if (isMessageEnabled(channelName, templateName)) {
|
|
|
|
if (isMessageEnabled(channelName, templateName)) {
|
|
|
|
if (!isPlayerInValidWorld(player, channelName)) {
|
|
|
|
if (isPlayerInValidWorld(player, channelName)) {
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
asyncIRCMessage(channelName, plugin.tokenizer
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
|
|
|
botNick, templateName), message));
|
|
|
|
botNick, templateName), message));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -1881,7 +1793,6 @@ public final class PurpleBot {
|
|
|
|
+ ChatColor.RESET + " is not in the voices list.");
|
|
|
|
+ ChatColor.RESET + " is not in the voices list.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
saveConfig("channels." + encodeChannel(getConfigChannelName(channelName)) + ".voices", voicesList.get(channelName));
|
|
|
|
saveConfig("channels." + encodeChannel(getConfigChannelName(channelName)) + ".voices", voicesList.get(channelName));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -2439,9 +2350,7 @@ public final class PurpleBot {
|
|
|
|
Send messages to TownyChat if enabled
|
|
|
|
Send messages to TownyChat if enabled
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (plugin.tcHook != null) {
|
|
|
|
if (plugin.tcHook != null) {
|
|
|
|
plugin.logDebug("Checking if " + TemplateName.IRC_TOWNY_CHAT + " is enabled ...");
|
|
|
|
if (isMessageEnabled(myChannel, TemplateName.IRC_TOWNY_CHAT)) {
|
|
|
|
if (enabledMessages.get(myChannel).contains(TemplateName.IRC_TOWNY_CHAT)) {
|
|
|
|
|
|
|
|
plugin.logDebug("Yes, " + TemplateName.IRC_TOWNY_CHAT + " is enabled...");
|
|
|
|
|
|
|
|
if (townyChannel.containsKey(myChannel)) {
|
|
|
|
if (townyChannel.containsKey(myChannel)) {
|
|
|
|
String tChannel = townyChannel.get(myChannel);
|
|
|
|
String tChannel = townyChannel.get(myChannel);
|
|
|
|
if (!tChannel.isEmpty()) {
|
|
|
|
if (!tChannel.isEmpty()) {
|
|
|
@ -2453,17 +2362,13 @@ public final class PurpleBot {
|
|
|
|
messageSent = true;
|
|
|
|
messageSent = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
plugin.logDebug("Nope, " + TemplateName.IRC_TOWNY_CHAT + " is NOT enabled...");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
Send messages to players if enabled
|
|
|
|
Send messages to players if enabled
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
plugin.logDebug("Checking if " + TemplateName.IRC_CHAT + " is enabled before broadcasting chat from IRC");
|
|
|
|
if (isMessageEnabled(myChannel, TemplateName.IRC_CHAT) || override) {
|
|
|
|
if (enabledMessages.get(myChannel).contains(TemplateName.IRC_CHAT) || override) {
|
|
|
|
|
|
|
|
plugin.logDebug("Yup we can broadcast due to " + TemplateName.IRC_CHAT + " enabled");
|
|
|
|
|
|
|
|
String newMessage = filterMessage(
|
|
|
|
String newMessage = filterMessage(
|
|
|
|
plugin.tokenizer.ircChatToGameTokenizer(this, user, channel, plugin.getMsgTemplate(
|
|
|
|
plugin.tokenizer.ircChatToGameTokenizer(this, user, channel, plugin.getMsgTemplate(
|
|
|
|
botNick, TemplateName.IRC_CHAT), message), myChannel);
|
|
|
|
botNick, TemplateName.IRC_CHAT), message), myChannel);
|
|
|
@ -2471,14 +2376,12 @@ public final class PurpleBot {
|
|
|
|
plugin.broadcastToGame(newMessage, "irc.message.chat");
|
|
|
|
plugin.broadcastToGame(newMessage, "irc.message.chat");
|
|
|
|
messageSent = true;
|
|
|
|
messageSent = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
plugin.logDebug("NOPE we can't broadcast due to " + TemplateName.IRC_CHAT + " disabled");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
Send messages to console if enabled
|
|
|
|
Send messages to console if enabled
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (enabledMessages.get(myChannel).contains(TemplateName.IRC_CONSOLE_CHAT)) {
|
|
|
|
if (isMessageEnabled(myChannel, TemplateName.IRC_CONSOLE_CHAT)) {
|
|
|
|
String tmpl = plugin.getMsgTemplate(botNick, TemplateName.IRC_CONSOLE_CHAT);
|
|
|
|
String tmpl = plugin.getMsgTemplate(botNick, TemplateName.IRC_CONSOLE_CHAT);
|
|
|
|
plugin.logDebug("broadcastChat [Console]: " + tmpl);
|
|
|
|
plugin.logDebug("broadcastChat [Console]: " + tmpl);
|
|
|
|
plugin.getServer().getConsoleSender().sendMessage(plugin.tokenizer.ircChatToGameTokenizer(
|
|
|
|
plugin.getServer().getConsoleSender().sendMessage(plugin.tokenizer.ircChatToGameTokenizer(
|
|
|
@ -2489,8 +2392,7 @@ public final class PurpleBot {
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
Send messages to Herochat if enabled
|
|
|
|
Send messages to Herochat if enabled
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
plugin.logDebug("Checking if " + TemplateName.IRC_HERO_CHAT + " is enabled before broadcasting chat from IRC to HeroChat");
|
|
|
|
if (isMessageEnabled(myChannel, TemplateName.IRC_HERO_CHAT)) {
|
|
|
|
if (enabledMessages.get(myChannel).contains(TemplateName.IRC_HERO_CHAT)) {
|
|
|
|
|
|
|
|
String hChannel = heroChannel.get(myChannel);
|
|
|
|
String hChannel = heroChannel.get(myChannel);
|
|
|
|
String tmpl = plugin.getIRCHeroChatChannelTemplate(botNick, hChannel);
|
|
|
|
String tmpl = plugin.getIRCHeroChatChannelTemplate(botNick, hChannel);
|
|
|
|
plugin.logDebug("broadcastChat [HC]: " + hChannel + ": " + tmpl);
|
|
|
|
plugin.logDebug("broadcastChat [HC]: " + hChannel + ": " + tmpl);
|
|
|
@ -2505,17 +2407,13 @@ public final class PurpleBot {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
plugin.logDebug("NOPE we can't broadcast to HeroChat due to " + TemplateName.IRC_HERO_CHAT + " disabled");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
Send messages to Essentials if enabled
|
|
|
|
Send messages to Essentials if enabled
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (plugin.isPluginEnabled("Essentials")) {
|
|
|
|
if (plugin.isPluginEnabled("Essentials")) {
|
|
|
|
plugin.logDebug("Checking if " + TemplateName.IRC_ESS_HELPOP + " is enabled before broadcasting chat from IRC");
|
|
|
|
if (isMessageEnabled(myChannel, TemplateName.IRC_ESS_HELPOP) || override) {
|
|
|
|
if (enabledMessages.get(myChannel).contains(TemplateName.IRC_ESS_HELPOP) || override) {
|
|
|
|
|
|
|
|
plugin.logDebug("Yup we can broadcast due to " + TemplateName.IRC_ESS_HELPOP + " enabled");
|
|
|
|
|
|
|
|
String newMessage = filterMessage(
|
|
|
|
String newMessage = filterMessage(
|
|
|
|
plugin.tokenizer.ircChatToGameTokenizer(this, user, channel, plugin.getMsgTemplate(
|
|
|
|
plugin.tokenizer.ircChatToGameTokenizer(this, user, channel, plugin.getMsgTemplate(
|
|
|
|
botNick, TemplateName.IRC_ESS_HELPOP), message), myChannel);
|
|
|
|
botNick, TemplateName.IRC_ESS_HELPOP), message), myChannel);
|
|
|
@ -2523,9 +2421,6 @@ public final class PurpleBot {
|
|
|
|
plugin.broadcastToGame(newMessage, "essentials.helpop.receive");
|
|
|
|
plugin.broadcastToGame(newMessage, "essentials.helpop.receive");
|
|
|
|
messageSent = true;
|
|
|
|
messageSent = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
plugin.logDebug("NOPE we can't broadcast due to " + TemplateName.IRC_ESS_HELPOP
|
|
|
|
|
|
|
|
+ " disabled");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2533,9 +2428,7 @@ public final class PurpleBot {
|
|
|
|
Send messages to AdminPrivateChat if enabled
|
|
|
|
Send messages to AdminPrivateChat if enabled
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (plugin.adminPrivateChatHook != null) {
|
|
|
|
if (plugin.adminPrivateChatHook != null) {
|
|
|
|
plugin.logDebug("Checking if " + TemplateName.IRC_A_CHAT + " is enabled before broadcasting chat from IRC");
|
|
|
|
if (isMessageEnabled(myChannel, TemplateName.IRC_A_CHAT) || override) {
|
|
|
|
if (enabledMessages.get(myChannel).contains(TemplateName.IRC_A_CHAT) || override) {
|
|
|
|
|
|
|
|
plugin.logDebug("Yup we can broadcast due to " + TemplateName.IRC_A_CHAT + " enabled");
|
|
|
|
|
|
|
|
String newMessage = filterMessage(
|
|
|
|
String newMessage = filterMessage(
|
|
|
|
plugin.tokenizer.ircChatToGameTokenizer(this, user, channel, plugin.getMsgTemplate(
|
|
|
|
plugin.tokenizer.ircChatToGameTokenizer(this, user, channel, plugin.getMsgTemplate(
|
|
|
|
botNick, TemplateName.IRC_A_CHAT), message), myChannel);
|
|
|
|
botNick, TemplateName.IRC_A_CHAT), message), myChannel);
|
|
|
@ -2543,15 +2436,13 @@ public final class PurpleBot {
|
|
|
|
plugin.adminPrivateChatHook.sendMessage(newMessage, user.getNick());
|
|
|
|
plugin.adminPrivateChatHook.sendMessage(newMessage, user.getNick());
|
|
|
|
messageSent = true;
|
|
|
|
messageSent = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
plugin.logDebug("NOPE we can't broadcast due to " + TemplateName.IRC_A_CHAT + " disabled");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
Notify IRC user that message was sent.
|
|
|
|
Notify IRC user that message was sent.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (enabledMessages.get(myChannel).contains(TemplateName.IRC_CHAT_RESPONSE) && messageSent && target != null) {
|
|
|
|
if (isMessageEnabled(myChannel, TemplateName.IRC_CHAT_RESPONSE) && messageSent && target != null) {
|
|
|
|
// Let the sender know the message was sent
|
|
|
|
// Let the sender know the message was sent
|
|
|
|
String responseTemplate = plugin.getMsgTemplate(botNick, TemplateName.IRC_CHAT_RESPONSE);
|
|
|
|
String responseTemplate = plugin.getMsgTemplate(botNick, TemplateName.IRC_CHAT_RESPONSE);
|
|
|
|
if (!responseTemplate.isEmpty()) {
|
|
|
|
if (!responseTemplate.isEmpty()) {
|
|
|
@ -2585,7 +2476,6 @@ public final class PurpleBot {
|
|
|
|
String msg;
|
|
|
|
String msg;
|
|
|
|
hChannel = message.split(" ", 2)[0];
|
|
|
|
hChannel = message.split(" ", 2)[0];
|
|
|
|
msg = message.split(" ", 2)[1];
|
|
|
|
msg = message.split(" ", 2)[1];
|
|
|
|
plugin.logDebug("Check if " + TemplateName.IRC_HERO_CHAT + " is enabled before broadcasting chat from IRC");
|
|
|
|
|
|
|
|
if (enabledMessages.get(ircChannel).contains(TemplateName.IRC_HERO_CHAT)) {
|
|
|
|
if (enabledMessages.get(ircChannel).contains(TemplateName.IRC_HERO_CHAT)) {
|
|
|
|
plugin.logDebug("Checking if " + hChannel + " is a valid hero channel...");
|
|
|
|
plugin.logDebug("Checking if " + hChannel + " is a valid hero channel...");
|
|
|
|
if (Herochat.getChannelManager().hasChannel(hChannel)) {
|
|
|
|
if (Herochat.getChannelManager().hasChannel(hChannel)) {
|
|
|
@ -2608,9 +2498,6 @@ public final class PurpleBot {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
asyncIRCMessage(target, "Hero channel \"" + hChannel + "\" does not exist!");
|
|
|
|
asyncIRCMessage(target, "Hero channel \"" + hChannel + "\" does not exist!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
plugin.logDebug("NOPE we can't broadcast due to "
|
|
|
|
|
|
|
|
+ TemplateName.IRC_HERO_CHAT + " disabled");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
asyncIRCMessage(target, "No message specified.");
|
|
|
|
asyncIRCMessage(target, "No message specified.");
|
|
|
@ -2637,10 +2524,7 @@ public final class PurpleBot {
|
|
|
|
String msg;
|
|
|
|
String msg;
|
|
|
|
pName = message.split(" ", 2)[0];
|
|
|
|
pName = message.split(" ", 2)[0];
|
|
|
|
msg = message.split(" ", 2)[1];
|
|
|
|
msg = message.split(" ", 2)[1];
|
|
|
|
plugin.logDebug("Check if " + TemplateName.IRC_PCHAT + " is enabled before broadcasting chat from IRC");
|
|
|
|
if (isMessageEnabled(myChannel, TemplateName.IRC_PCHAT)) {
|
|
|
|
if (enabledMessages.get(myChannel).contains(TemplateName.IRC_PCHAT)) {
|
|
|
|
|
|
|
|
plugin.logDebug("Yup we can broadcast due to " + TemplateName.IRC_PCHAT
|
|
|
|
|
|
|
|
+ " enabled... Checking if " + pName + " is a valid player...");
|
|
|
|
|
|
|
|
Player player = plugin.getServer().getPlayer(pName);
|
|
|
|
Player player = plugin.getServer().getPlayer(pName);
|
|
|
|
if (player != null) {
|
|
|
|
if (player != null) {
|
|
|
|
if (player.isOnline()) {
|
|
|
|
if (player.isOnline()) {
|
|
|
@ -2662,8 +2546,6 @@ public final class PurpleBot {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
asyncIRCMessage(target, "Player not found (possibly offline): " + pName);
|
|
|
|
asyncIRCMessage(target, "Player not found (possibly offline): " + pName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
plugin.logDebug("NOPE we can't broadcast due to irc-pchat disabled");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
asyncIRCMessage(target, "No message specified.");
|
|
|
|
asyncIRCMessage(target, "No message specified.");
|
|
|
@ -2679,7 +2561,7 @@ public final class PurpleBot {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void broadcastAction(User user, org.pircbotx.Channel channel, String message) {
|
|
|
|
public void broadcastAction(User user, org.pircbotx.Channel channel, String message) {
|
|
|
|
String myChannel = channel.getName();
|
|
|
|
String myChannel = channel.getName();
|
|
|
|
if (enabledMessages.get(myChannel).contains(TemplateName.IRC_ACTION)) {
|
|
|
|
if (isMessageEnabled(myChannel, TemplateName.IRC_ACTION)) {
|
|
|
|
plugin.broadcastToGame(plugin.tokenizer.ircChatToGameTokenizer(
|
|
|
|
plugin.broadcastToGame(plugin.tokenizer.ircChatToGameTokenizer(
|
|
|
|
this, user, channel, plugin.getMsgTemplate(botNick,
|
|
|
|
this, user, channel, plugin.getMsgTemplate(botNick,
|
|
|
|
TemplateName.IRC_ACTION), message), "irc.message.action");
|
|
|
|
TemplateName.IRC_ACTION), message), "irc.message.action");
|
|
|
@ -2688,7 +2570,7 @@ public final class PurpleBot {
|
|
|
|
+ TemplateName.IRC_ACTION + " is false");
|
|
|
|
+ TemplateName.IRC_ACTION + " is false");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (enabledMessages.get(myChannel).contains(TemplateName.IRC_HERO_ACTION)) {
|
|
|
|
if (isMessageEnabled(myChannel, TemplateName.IRC_HERO_ACTION)) {
|
|
|
|
String hChannel = heroChannel.get(myChannel);
|
|
|
|
String hChannel = heroChannel.get(myChannel);
|
|
|
|
String tmpl = plugin.getIRCHeroActionChannelTemplate(botNick, hChannel);
|
|
|
|
String tmpl = plugin.getIRCHeroActionChannelTemplate(botNick, hChannel);
|
|
|
|
plugin.logDebug("broadcastChat [HA]: " + hChannel + ": " + tmpl);
|
|
|
|
plugin.logDebug("broadcastChat [HA]: " + hChannel + ": " + tmpl);
|
|
|
@ -2705,17 +2587,11 @@ public final class PurpleBot {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (plugin.dynmapHook != null) {
|
|
|
|
if (plugin.dynmapHook != null) {
|
|
|
|
plugin.logDebug("xChecking if " + TemplateName.IRC_ACTION_DYNMAP_WEB_CHAT + " is enabled ...");
|
|
|
|
if (isMessageEnabled(myChannel, TemplateName.IRC_ACTION_DYNMAP_WEB_CHAT)) {
|
|
|
|
if (enabledMessages.get(myChannel).contains(TemplateName.IRC_ACTION_DYNMAP_WEB_CHAT)) {
|
|
|
|
|
|
|
|
plugin.logDebug("Yes, " + TemplateName.IRC_ACTION_DYNMAP_WEB_CHAT + " is enabled...");
|
|
|
|
|
|
|
|
String template = plugin.getMsgTemplate(botNick, TemplateName.IRC_ACTION_DYNMAP_WEB_CHAT);
|
|
|
|
String template = plugin.getMsgTemplate(botNick, TemplateName.IRC_ACTION_DYNMAP_WEB_CHAT);
|
|
|
|
String rawDWMessage = filterMessage(
|
|
|
|
String rawDWMessage = filterMessage(
|
|
|
|
plugin.tokenizer.ircChatToGameTokenizer(this, user, channel, template, message), myChannel);
|
|
|
|
plugin.tokenizer.ircChatToGameTokenizer(this, user, channel, template, message), myChannel);
|
|
|
|
String nickTmpl = plugin.getMsgTemplate(botNick, TemplateName.IRC_DYNMAP_ACTION_NICK);
|
|
|
|
plugin.dynmapHook.sendMessage(user.getNick(), rawDWMessage);
|
|
|
|
String rawNick = nickTmpl.replace("%NICK%", user.getNick());
|
|
|
|
|
|
|
|
plugin.dynmapHook.sendMessage(rawNick, rawDWMessage);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
plugin.logDebug("Nope, " + TemplateName.IRC_ACTION_DYNMAP_WEB_CHAT + " is NOT enabled...");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2729,14 +2605,14 @@ public final class PurpleBot {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void broadcastIRCKick(User recipient, User kicker, String reason, org.pircbotx.Channel channel) {
|
|
|
|
public void broadcastIRCKick(User recipient, User kicker, String reason, org.pircbotx.Channel channel) {
|
|
|
|
String myChannel = channel.getName();
|
|
|
|
String myChannel = channel.getName();
|
|
|
|
if (enabledMessages.get(myChannel).contains(TemplateName.IRC_KICK)) {
|
|
|
|
if (isMessageEnabled(myChannel, TemplateName.IRC_KICK)) {
|
|
|
|
plugin.broadcastToGame(plugin.tokenizer.ircKickTokenizer(
|
|
|
|
plugin.broadcastToGame(plugin.tokenizer.ircKickTokenizer(
|
|
|
|
this, recipient, kicker, reason, channel, plugin.getMsgTemplate(
|
|
|
|
this, recipient, kicker, reason, channel, plugin.getMsgTemplate(
|
|
|
|
botNick, TemplateName.IRC_KICK)),
|
|
|
|
botNick, TemplateName.IRC_KICK)),
|
|
|
|
"irc.message.kick");
|
|
|
|
"irc.message.kick");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (enabledMessages.get(myChannel).contains(TemplateName.IRC_HERO_KICK)) {
|
|
|
|
if (isMessageEnabled(myChannel, TemplateName.IRC_HERO_KICK)) {
|
|
|
|
Herochat.getChannelManager().getChannel(heroChannel.get(myChannel))
|
|
|
|
Herochat.getChannelManager().getChannel(heroChannel.get(myChannel))
|
|
|
|
.sendRawMessage(plugin.tokenizer
|
|
|
|
.sendRawMessage(plugin.tokenizer
|
|
|
|
.ircKickToHeroChatTokenizer(this,
|
|
|
|
.ircKickToHeroChatTokenizer(this,
|
|
|
@ -2885,7 +2761,9 @@ public final class PurpleBot {
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public boolean isMessageEnabled(String channelName, String templateName) {
|
|
|
|
public boolean isMessageEnabled(String channelName, String templateName) {
|
|
|
|
return enabledMessages.get(channelName).contains(templateName);
|
|
|
|
boolean isEnabled = enabledMessages.get(channelName).contains(templateName);
|
|
|
|
|
|
|
|
plugin.logDebug("[isMessageEnabled] " + channelName + ":" + templateName + ":" + isEnabled);
|
|
|
|
|
|
|
|
return isEnabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -2951,10 +2829,7 @@ public final class PurpleBot {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
for (String channelName : botChannels) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.GAME_AFK)) {
|
|
|
|
if (isMessageEnabled(channelName, TemplateName.GAME_AFK) && isPlayerInValidWorld(player, channelName)) {
|
|
|
|
if (!isPlayerInValidWorld(player, channelName)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String template;
|
|
|
|
String template;
|
|
|
|
if (afk) {
|
|
|
|
if (afk) {
|
|
|
|
template = plugin.getMsgTemplate(botNick, TemplateName.ESS_PLAYER_AFK);
|
|
|
|
template = plugin.getMsgTemplate(botNick, TemplateName.ESS_PLAYER_AFK);
|
|
|
@ -3021,13 +2896,15 @@ public final class PurpleBot {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isValidChannel(String channelName) {
|
|
|
|
public boolean isValidChannel(String channelName) {
|
|
|
|
|
|
|
|
boolean valid = false;
|
|
|
|
for (String s : botChannels) {
|
|
|
|
for (String s : botChannels) {
|
|
|
|
if (channelName.equalsIgnoreCase(s)) {
|
|
|
|
if (channelName.equalsIgnoreCase(s)) {
|
|
|
|
return true;
|
|
|
|
valid = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
plugin.logDebug("Channel " + channelName + " is not valid.");
|
|
|
|
plugin.logDebug("[isValidChannel] [c: " + channelName + "] [b: " + valid + "]");
|
|
|
|
return false;
|
|
|
|
return valid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public PircBotX getBot() {
|
|
|
|
public PircBotX getBot() {
|
|
|
|