Impressive!  Please think about adding DCC send/receive for Yaaic.
On May 29, 2011 7:49 PM, "Steven Luo" <[email protected]> wrote:
> As of now, private messages where the sender is our nick end up in
> a query window targeted at us. Show these messages in the query window
> of the target instead, which is probably what we want.
>
> This is useful for use with irssi proxy, which will send messages sent
> by another client attached to the proxy to us in this way.
>
> (Note that this patch makes a change to PircBot to pass the target of a
> private message to the onPrivateMessage handler.)
> ---
> application/src/org/jibble/pircbot/PircBot.java | 6 +-
> application/src/org/yaaic/irc/IRCConnection.java | 70
++++++++++++----------
> 2 files changed, 42 insertions(+), 34 deletions(-)
>
> 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(),
> --
> 1.7.2.5
>

Reply via email to