1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-26 02:42:16 -05:00

Open a new query if it doesnt exist on "external" action (/me)

This commit is contained in:
Sebastian Kaspari 2010-03-10 21:46:12 +01:00
parent 2f97adaf30
commit 94f624360d

View File

@ -88,21 +88,38 @@ public class IRCConnection extends PircBot
// Strip mIRC colors and formatting // Strip mIRC colors and formatting
action = Colors.removeFormattingAndColors(action); action = Colors.removeFormattingAndColors(action);
Message message = new Message(sender + " " + action);
message.setIcon(R.drawable.action);
if (target.equals(this.getNick())) { if (target.equals(this.getNick())) {
// We are the target - this is an action in a query // We are the target - this is an action in a query
target = sender; Conversation conversation = server.getConversation(sender);
if (conversation == null) {
// Open a query if there's none yet
conversation = new Query(sender);
server.addConversationl(conversation);
conversation.addMessage(message);
Intent intent = new Intent(Broadcast.CHANNEL_NEW);
intent.putExtra(Broadcast.EXTRA_CHANNEL, sender);
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
service.sendBroadcast(intent);
} else {
Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE);
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
intent.putExtra(Broadcast.EXTRA_CHANNEL, sender);
service.sendBroadcast(intent);
}
} else {
// A action in a channel
server.getConversation(target).addMessage(message);
Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE);
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
intent.putExtra(Broadcast.EXTRA_CHANNEL, target);
service.sendBroadcast(intent);
} }
Message message = new Message(sender + " " + action);
message.setIcon(R.drawable.action);
server.getConversation(target).addMessage(message);
Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE);
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
intent.putExtra(Broadcast.EXTRA_CHANNEL, target);
service.sendBroadcast(intent);
} }
/** /**
@ -357,23 +374,22 @@ public class IRCConnection extends PircBot
// Strip mIRC colors and formatting // Strip mIRC colors and formatting
text = Colors.removeFormattingAndColors(text); text = Colors.removeFormattingAndColors(text);
Message message = new Message("<" + sender + "> " + text);
Conversation conversation = server.getConversation(sender); Conversation conversation = server.getConversation(sender);
if (conversation == null) { if (conversation == null) {
// Open a query if there's none yet // Open a query if there's none yet
conversation = new Query(sender); conversation = new Query(sender);
server.addConversationl(conversation);
Message message = new Message("<" + sender + "> " + text);
conversation.addMessage(message); conversation.addMessage(message);
server.addConversationl(conversation);
Intent intent = new Intent(Broadcast.CHANNEL_NEW); Intent intent = new Intent(Broadcast.CHANNEL_NEW);
intent.putExtra(Broadcast.EXTRA_CHANNEL, sender); intent.putExtra(Broadcast.EXTRA_CHANNEL, sender);
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId()); intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
service.sendBroadcast(intent); service.sendBroadcast(intent);
} else { } else {
Message message = new Message("<" + sender + "> " + text);
conversation.addMessage(message); conversation.addMessage(message);
Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE); Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE);