From aeeeb18d2bf5a3d9330e37fa659d413223e47108 Mon Sep 17 00:00:00 2001 From: cnaude Date: Tue, 26 Jul 2016 18:19:59 -0700 Subject: [PATCH] Add missing IRC->VentureChat messages. (join, kick, part, quit) --- .../GameListeners/VentureChatListener.java | 2 +- .../java/com/cnaude/purpleirc/PurpleBot.java | 84 ++++++++++++++++++- .../java/com/cnaude/purpleirc/PurpleIRC.java | 18 +--- 3 files changed, 87 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/cnaude/purpleirc/GameListeners/VentureChatListener.java b/src/main/java/com/cnaude/purpleirc/GameListeners/VentureChatListener.java index 29fe393..f00ca3d 100644 --- a/src/main/java/com/cnaude/purpleirc/GameListeners/VentureChatListener.java +++ b/src/main/java/com/cnaude/purpleirc/GameListeners/VentureChatListener.java @@ -84,7 +84,7 @@ public class VentureChatListener implements Listener { String channelTemplateName = "venture-" + vcChannel + "-chat"; if (bot.isMessageEnabled(channelName, channelTemplateName) || bot.isMessageEnabled(channelName, TemplateName.VENTURE_CHAT)) { - String template = plugin.getVentureChatTemplate(bot.botNick, vcChannel); + String template = plugin.getVentureChatTemplate(bot.botNick, vcChannel, TemplateName.VENTURE_CHAT); plugin.logDebug("VC Template: " + template); bot.asyncIRCMessage(channelName, plugin.tokenizer .ventureChatTokenizer(player, vcChannel, vcColor, message, template)); diff --git a/src/main/java/com/cnaude/purpleirc/PurpleBot.java b/src/main/java/com/cnaude/purpleirc/PurpleBot.java index 3a37fe2..4ca75bc 100644 --- a/src/main/java/com/cnaude/purpleirc/PurpleBot.java +++ b/src/main/java/com/cnaude/purpleirc/PurpleBot.java @@ -2823,7 +2823,7 @@ public final class PurpleBot { */ if (isMessageEnabled(channelName, TemplateName.IRC_VENTURE_CHAT) && plugin.ventureChatEnabled) { String vcChannel = ventureChatChannel.get(channelName); - String vcTemplate = plugin.getIrcVentureChatTemplate(botNick, vcChannel); + String vcTemplate = plugin.getVentureChatTemplate(botNick, vcChannel, TemplateName.IRC_VENTURE_CHAT); plugin.logDebug("broadcastChat [MV]: " + vcChannel + ": " + vcTemplate); String rawMvMessage = filterMessage( plugin.tokenizer.ircChatToVentureChatTokenizer(this, user, channel, vcTemplate, message, vcChannel), channelName); @@ -3108,6 +3108,22 @@ public final class PurpleBot { ) ); } + + // Broadcast kick message to VentureChat + if (isMessageEnabled(channelName, TemplateName.IRC_VENTURE_KICK) && plugin.ventureChatEnabled) { + String vcChannel = ventureChatChannel.get(channelName); + String vcTemplate = plugin.getVentureChatTemplate(botNick, vcChannel, TemplateName.IRC_VENTURE_KICK); + plugin.logDebug("broadcastIRCkick [VC]: " + vcChannel + ": " + vcTemplate); + String rawVcMessage = plugin.tokenizer.ircKickTokenizer(this, recipient, kicker, reason, channel, vcTemplate); + if (!rawVcMessage.isEmpty()) { + plugin.vcHook.sendMessage(vcChannel, rawVcMessage); + if (logIrcToVentureChat.containsKey(channelName)) { + if (logIrcToVentureChat.get(channelName)) { + plugin.getServer().getConsoleSender().sendMessage(rawVcMessage); + } + } + } + } } /** @@ -3165,6 +3181,7 @@ public final class PurpleBot { plugin.logDebug("[broadcastIRCJoin] NOT broadcasting join message because irc-join is false."); } + // Broadcast join message to HeroChat if (isMessageEnabled(channel, TemplateName.IRC_HERO_JOIN)) { Herochat.getChannelManager().getChannel(heroChannel.get(channel.getName())) .sendRawMessage(plugin.tokenizer.ircChatToHeroChatTokenizer( @@ -3173,6 +3190,23 @@ public final class PurpleBot { Herochat.getChannelManager(), heroChannel.get(channel.getName()))); } + + // Broadcast join message to VentureChat + if (isMessageEnabled(channelName, TemplateName.IRC_VENTURE_JOIN) && plugin.ventureChatEnabled) { + String vcChannel = ventureChatChannel.get(channelName); + String vcTemplate = plugin.getVentureChatTemplate(botNick, vcChannel, TemplateName.IRC_VENTURE_JOIN); + plugin.logDebug("broadcastIRCJoin [VC]: " + vcChannel + ": " + vcTemplate); + String rawVcMessage = plugin.tokenizer.chatIRCTokenizer(this, user, channel, vcTemplate); + if (!rawVcMessage.isEmpty()) { + plugin.vcHook.sendMessage(vcChannel, rawVcMessage); + if (logIrcToVentureChat.containsKey(channelName)) { + if (logIrcToVentureChat.get(channelName)) { + plugin.getServer().getConsoleSender().sendMessage(rawVcMessage); + } + } + } + } + } public void broadcastIRCPart(User user, org.pircbotx.Channel channel) { @@ -3196,6 +3230,22 @@ public final class PurpleBot { Herochat.getChannelManager(), heroChannel.get(channel.getName()))); } + + // Broadcast part message to VentureChat + if (isMessageEnabled(channelName, TemplateName.IRC_VENTURE_PART) && plugin.ventureChatEnabled) { + String vcChannel = ventureChatChannel.get(channelName); + String vcTemplate = plugin.getVentureChatTemplate(botNick, vcChannel, TemplateName.IRC_VENTURE_PART); + plugin.logDebug("broadcastIRCPart [VC]: " + vcChannel + ": " + vcTemplate); + String rawVcMessage = plugin.tokenizer.chatIRCTokenizer(this, user, channel, vcTemplate); + if (!rawVcMessage.isEmpty()) { + plugin.vcHook.sendMessage(vcChannel, rawVcMessage); + if (logIrcToVentureChat.containsKey(channelName)) { + if (logIrcToVentureChat.get(channelName)) { + plugin.getServer().getConsoleSender().sendMessage(rawVcMessage); + } + } + } + } } public void broadcastIRCQuit(User user, org.pircbotx.Channel channel, String reason) { @@ -3219,6 +3269,22 @@ public final class PurpleBot { Herochat.getChannelManager(), heroChannel.get(channel.getName()))); } + + // Broadcast part message to VentureChat + if (isMessageEnabled(channelName, TemplateName.IRC_VENTURE_QUIT) && plugin.ventureChatEnabled) { + String vcChannel = ventureChatChannel.get(channelName); + String vcTemplate = plugin.getVentureChatTemplate(botNick, vcChannel, TemplateName.IRC_VENTURE_QUIT); + plugin.logDebug("broadcastIRCQuit [VC]: " + vcChannel + ": " + vcTemplate); + String rawVcMessage = plugin.tokenizer.chatIRCTokenizer(this, user, channel, vcTemplate); + if (!rawVcMessage.isEmpty()) { + plugin.vcHook.sendMessage(vcChannel, rawVcMessage); + if (logIrcToVentureChat.containsKey(channelName)) { + if (logIrcToVentureChat.get(channelName)) { + plugin.getServer().getConsoleSender().sendMessage(rawVcMessage); + } + } + } + } } @@ -3244,6 +3310,22 @@ public final class PurpleBot { Herochat.getChannelManager(), heroChannel.get(channel.getName()))); } + + // Broadcast topic message to VentureChat + if (isMessageEnabled(channelName, TemplateName.IRC_VENTURE_TOPIC) && plugin.ventureChatEnabled) { + String vcChannel = ventureChatChannel.get(channelName); + String vcTemplate = plugin.getVentureChatTemplate(botNick, vcChannel, TemplateName.IRC_VENTURE_TOPIC); + plugin.logDebug("broadcastIRCTopic [VC]: " + vcChannel + ": " + vcTemplate); + String rawVcMessage = plugin.tokenizer.chatIRCTokenizer(this, user, channel, vcTemplate); + if (!rawVcMessage.isEmpty()) { + plugin.vcHook.sendMessage(vcChannel, rawVcMessage); + if (logIrcToVentureChat.containsKey(channelName)) { + if (logIrcToVentureChat.get(channelName)) { + plugin.getServer().getConsoleSender().sendMessage(rawVcMessage); + } + } + } + } } /** diff --git a/src/main/java/com/cnaude/purpleirc/PurpleIRC.java b/src/main/java/com/cnaude/purpleirc/PurpleIRC.java index e53b891..645ecbd 100644 --- a/src/main/java/com/cnaude/purpleirc/PurpleIRC.java +++ b/src/main/java/com/cnaude/purpleirc/PurpleIRC.java @@ -504,21 +504,9 @@ public class PurpleIRC extends JavaPlugin { public String getIrcHeroActionTemplate(String botName, String channel) { return getMessageTemplate(ircHeroActionChannelMessages, botName, channel, TemplateName.IRC_HERO_ACTION); } - - public String getVentureChatTemplate(String botName, String channel) { - return getMessageTemplate(ventureChatChannelMessages, botName, channel, TemplateName.VENTURE_CHAT); - } - - public String getVentureChatActionTemplate(String botName, String channel) { - return getMessageTemplate(ventureChatActionChannelMessages, botName, channel, TemplateName.VENTURE_CHAT_ACTION); - } - - public String getIrcVentureChatTemplate(String botName, String channel) { - return getMessageTemplate(ircVentureChatChannelMessages, botName, channel, TemplateName.IRC_VENTURE_CHAT); - } - - public String getIrcVentureChatActionTemplate(String botName, String channel) { - return getMessageTemplate(ircVentureChatActionChannelMessages, botName, channel, TemplateName.IRC_VENTURE_ACTION); + + public String getVentureChatTemplate(String botName, String channel, String template) { + return getMessageTemplate(ircVentureChatChannelMessages, botName, channel, template); } public String getIrcTownyChatTemplate(String botName, String channel) {