mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-25 18:32:15 -05:00
Do something sane for private messages where the sender is our nick
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.)
This commit is contained in:
parent
159cb8195d
commit
9a8bf44d63
@ -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) {}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -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(),
|
||||
|
Loading…
Reference in New Issue
Block a user