diff --git a/application/src/org/jibble/pircbot/PircBot.java b/application/src/org/jibble/pircbot/PircBot.java index e1f1d27..63e37c7 100644 --- a/application/src/org/jibble/pircbot/PircBot.java +++ b/application/src/org/jibble/pircbot/PircBot.java @@ -991,7 +991,8 @@ public abstract class PircBot implements ReplyConstants { } else if (command.equals("PRIVMSG")) { // This is a private message to us. - this.onPrivateMessage(sourceNick, sourceLogin, sourceHostname, line.substring(line.indexOf(" :") + 2)); + // XXX PircBot patch to pass target info to privmsg callback + this.onPrivateMessage(sourceNick, sourceLogin, sourceHostname, target, line.substring(line.indexOf(" :") + 2)); } else if (command.equals("JOIN")) { // Someone is joining a channel. @@ -1305,7 +1306,8 @@ public abstract class PircBot implements ReplyConstants { * @param hostname The hostname of the person who sent the private message. * @param message The actual message. */ - protected void onPrivateMessage(String sender, String login, String hostname, String message) {} + // XXX PircBot patch to pass target info to privmsg callback + protected void onPrivateMessage(String sender, String login, String hostname, String target, String message) {} /** diff --git a/application/src/org/yaaic/irc/IRCConnection.java b/application/src/org/yaaic/irc/IRCConnection.java index 790e05e..9bb81a3 100644 --- a/application/src/org/yaaic/irc/IRCConnection.java +++ b/application/src/org/yaaic/irc/IRCConnection.java @@ -208,44 +208,41 @@ public class IRCConnection extends PircBot Message message = new Message(sender + " " + action); message.setIcon(R.drawable.action); - if (target.equals(this.getNick())) { + String queryNick = target; + if (queryNick.equals(this.getNick())) { // We are the target - this is an action in a query - conversation = server.getConversation(sender); - if (conversation == null) { - // Open a query if there's none yet - conversation = new Query(sender); - server.addConversation(conversation); - conversation.addMessage(message); + queryNick = sender; + } + conversation = server.getConversation(queryNick); - Intent intent = Broadcast.createConversationIntent( - Broadcast.CONVERSATION_NEW, - server.getId(), - sender - ); - service.sendBroadcast(intent); - } else { - conversation.addMessage(message); + if (conversation == null) { + // Open a query if there's none yet + conversation = new Query(queryNick); + server.addConversation(conversation); + conversation.addMessage(message); - Intent intent = Broadcast.createConversationIntent( - Broadcast.CONVERSATION_MESSAGE, - server.getId(), - sender - ); - service.sendBroadcast(intent); - } + Intent intent = Broadcast.createConversationIntent( + Broadcast.CONVERSATION_NEW, + server.getId(), + queryNick + ); + service.sendBroadcast(intent); } else { - // A action in a channel - conversation = server.getConversation(target); conversation.addMessage(message); Intent intent = Broadcast.createConversationIntent( Broadcast.CONVERSATION_MESSAGE, server.getId(), - target + queryNick ); service.sendBroadcast(intent); } + if (sender.equals(this.getNick())) { + // Don't notify for something sent in our name + return; + } + boolean mentioned = isMentioned(action); if (mentioned || target.equals(this.getNick())) { service.updateNotification( @@ -584,22 +581,26 @@ public class IRCConnection extends PircBot * On Private Message */ @Override - protected void onPrivateMessage(String sender, String login, String hostname, String text) + protected void onPrivateMessage(String sender, String login, String hostname, String target, String text) { Message message = new Message("<" + sender + "> " + text); + String queryNick = sender; - Conversation conversation = server.getConversation(sender); + if (queryNick.equals(this.getNick())) { + queryNick = target; + } + Conversation conversation = server.getConversation(queryNick); if (conversation == null) { // Open a query if there's none yet - conversation = new Query(sender); + conversation = new Query(queryNick); conversation.addMessage(message); server.addConversation(conversation); Intent intent = Broadcast.createConversationIntent( Broadcast.CONVERSATION_NEW, server.getId(), - sender + queryNick ); service.sendBroadcast(intent); } else { @@ -608,11 +609,16 @@ public class IRCConnection extends PircBot Intent intent = Broadcast.createConversationIntent( Broadcast.CONVERSATION_MESSAGE, server.getId(), - sender + queryNick ); service.sendBroadcast(intent); } + if (sender.equals(this.getNick())) { + // Don't notify for something sent in our name + return; + } + service.updateNotification( "<" + sender + "> " + text, service.getSettings().isVibrateHighlightEnabled(),