Add %CUSTOMPREFIX% to irc-nickchange template tokenizer.

This commit is contained in:
cnaude 2017-02-20 18:00:51 -07:00
parent debdcbffb8
commit 0cc1d3b044
2 changed files with 24 additions and 6 deletions

View File

@ -20,6 +20,7 @@ import com.cnaude.purpleirc.TemplateName;
import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import org.pircbotx.Channel;
import org.pircbotx.User;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.NickChangeEvent;
@ -50,18 +51,16 @@ public class NickChangeListener extends ListenerAdapter {
public void onNickChange(NickChangeEvent event) {
String newNick = event.getNewNick();
String oldNick = event.getOldNick();
User user = event.getUser();
plugin.logDebug("OLD: " + oldNick);
plugin.logDebug("NEW: " + newNick);
for (String channelName : ircBot.channelNicks.keySet()) {
Channel channel = ircBot.getChannel(channelName);
if (channel != null) {
if (ircBot.enabledMessages.get(channelName).contains(TemplateName.IRC_NICK_CHANGE)) {
plugin.broadcastToGame(plugin.colorConverter.ircColorsToGame(
plugin.getMessageTemplate(ircBot.botNick, channelName, TemplateName.IRC_NICK_CHANGE)
.replace("%NEWNICK%", newNick)
.replace("%OLDNICK%", oldNick)
.replace("%CHANNEL%", channelName)), "irc.message.nickchange");
if (ircBot.enabledMessages.get(channelName).contains(TemplateName.IRC_NICK_CHANGE)) {
String message = plugin.tokenizer.ircNickChangeTokenizer(user, oldNick, newNick, channelName, ircBot);
plugin.broadcastToGame(message, "irc.message.nickchange");
}
if (plugin.netPackets != null) {
plugin.netPackets.remFromTabList(oldNick);

View File

@ -108,6 +108,25 @@ public class ChatTokenizer {
.replace("%SERVER%", server)
.replace("%AWAY%", away);
}
/**
*
* @param user
* @param oldNick
* @param newNick
* @param channelName
* @param ircBot
* @return
*/
public String ircNickChangeTokenizer(User user, String oldNick, String newNick, String channelName, PurpleBot ircBot) {
String template = plugin.getMessageTemplate(ircBot.botNick, channelName, TemplateName.IRC_NICK_CHANGE);
String message = template.replace("%NEWNICK%", newNick)
.replace("%OLDNICK%", oldNick)
.replace("%CHANNEL%", channelName);
message = plugin.colorConverter.ircColorsToGame(ircUserTokenizer(message, user, ircBot));
return plugin.colorConverter.ircColorsToGame(message);
}
/**
*