mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-16 05:55:08 -05:00
Implemented IRCConnection.onAction()
This commit is contained in:
parent
da70bcd515
commit
7445f51422
@ -28,6 +28,7 @@ import org.jibble.pircbot.User;
|
|||||||
|
|
||||||
import org.yaaic.Yaaic;
|
import org.yaaic.Yaaic;
|
||||||
import org.yaaic.model.Broadcast;
|
import org.yaaic.model.Broadcast;
|
||||||
|
import org.yaaic.model.Channel;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
import org.yaaic.model.Status;
|
import org.yaaic.model.Status;
|
||||||
|
|
||||||
@ -63,6 +64,8 @@ public class IRCConnection extends PircBot
|
|||||||
@Override
|
@Override
|
||||||
public void onConnect()
|
public void onConnect()
|
||||||
{
|
{
|
||||||
|
debug("Connect", "");
|
||||||
|
|
||||||
server.setStatus(Status.CONNECTED);
|
server.setStatus(Status.CONNECTED);
|
||||||
|
|
||||||
service.sendBroadcast(new Intent(Broadcast.SERVER_UPDATE));
|
service.sendBroadcast(new Intent(Broadcast.SERVER_UPDATE));
|
||||||
@ -75,6 +78,9 @@ public class IRCConnection extends PircBot
|
|||||||
protected void onAction(String sender, String login, String hostname, String target, String action)
|
protected void onAction(String sender, String login, String hostname, String target, String action)
|
||||||
{
|
{
|
||||||
debug("Action", target + " " + sender + " " + action);
|
debug("Action", target + " " + sender + " " + action);
|
||||||
|
|
||||||
|
server.getChannel(target).addMessage("* " + sender + " " + action);
|
||||||
|
service.sendBroadcast(new Intent(Broadcast.CHANNEL_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -120,6 +126,11 @@ public class IRCConnection extends PircBot
|
|||||||
protected void onJoin(String channel, String sender, String login, String hostname)
|
protected void onJoin(String channel, String sender, String login, String hostname)
|
||||||
{
|
{
|
||||||
debug("Join", channel + " " + sender);
|
debug("Join", channel + " " + sender);
|
||||||
|
|
||||||
|
if (sender.equals(getNick())) {
|
||||||
|
// We joined a new channel
|
||||||
|
server.addChannel(new Channel(channel));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,7 +148,7 @@ public class IRCConnection extends PircBot
|
|||||||
@Override
|
@Override
|
||||||
protected void onMessage(String channel, String sender, String login, String hostname, String message)
|
protected void onMessage(String channel, String sender, String login, String hostname, String message)
|
||||||
{
|
{
|
||||||
debug("Deop", channel + " " + sender + " " + message);
|
debug("Message", channel + " " + sender + " " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -173,7 +184,7 @@ public class IRCConnection extends PircBot
|
|||||||
@Override
|
@Override
|
||||||
protected void onOp(String channel, String sourceNick, String sourceLogin, String sourceHostname, String recipient)
|
protected void onOp(String channel, String sourceNick, String sourceLogin, String sourceHostname, String recipient)
|
||||||
{
|
{
|
||||||
debug("Deop", channel + " " + recipient + "(" + sourceNick + ")");
|
debug("Op", channel + " " + recipient + "(" + sourceNick + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -246,7 +257,7 @@ public class IRCConnection extends PircBot
|
|||||||
private void debug(String event, String params)
|
private void debug(String event, String params)
|
||||||
{
|
{
|
||||||
if (DEBUG_EVENTS) {
|
if (DEBUG_EVENTS) {
|
||||||
Log.d(TAG, "[" + event + "]: " + params);
|
Log.d(TAG, "(" + server.getTitle() + ") [" + event + "]: " + params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ public class Broadcast
|
|||||||
{
|
{
|
||||||
public static final String SERVER_UPDATE = "org.yaaic.server.status";
|
public static final String SERVER_UPDATE = "org.yaaic.server.status";
|
||||||
|
|
||||||
|
public static final String CHANNEL_MESSAGE = "org.yaaic.channel.message";
|
||||||
|
/*
|
||||||
public static final String CHANNEL_ACTION = "org.yaaic.channel.action";
|
public static final String CHANNEL_ACTION = "org.yaaic.channel.action";
|
||||||
public static final String CHANNEL_INFO = "org.yaaic.channel.info";
|
public static final String CHANNEL_INFO = "org.yaaic.channel.info";
|
||||||
public static final String CHANNEL_DEOP = "org.yaaic.channel.deop";
|
public static final String CHANNEL_DEOP = "org.yaaic.channel.deop";
|
||||||
@ -43,4 +45,12 @@ public class Broadcast
|
|||||||
public static final String USER_NOTICE = "org.yaaic.user.notice";
|
public static final String USER_NOTICE = "org.yaaic.user.notice";
|
||||||
public static final String USER_MESSAGE = "org.yaaic.user.message";
|
public static final String USER_MESSAGE = "org.yaaic.user.message";
|
||||||
public static final String USER_QUIT = "org.yaaic.user.quit";
|
public static final String USER_QUIT = "org.yaaic.user.quit";
|
||||||
|
|
||||||
|
public static final String EXTRA_SENDER = "sender";
|
||||||
|
public static final String EXTRA_CHANNEL = "channel";
|
||||||
|
public static final String EXTRA_MESSAGE = "message";
|
||||||
|
public static final String EXTRA_TOPIC = "topic";
|
||||||
|
public static final String EXTRA_USERCOUNT = "usercount";
|
||||||
|
public static final String EXTRA_RECEIVER = "receiver";
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
package org.yaaic.model;
|
package org.yaaic.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.yaaic.R;
|
import org.yaaic.R;
|
||||||
|
|
||||||
@ -36,7 +38,7 @@ public class Server
|
|||||||
private String host;
|
private String host;
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
private ArrayList<Channel> channels = new ArrayList<Channel>();
|
private HashMap<String, Channel> channels = new HashMap<String, Channel>();
|
||||||
|
|
||||||
private int status = Status.DISCONNECTED;
|
private int status = Status.DISCONNECTED;
|
||||||
|
|
||||||
@ -165,9 +167,17 @@ public class Server
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ArrayList<Channel> getChannels()
|
public Collection<Channel> getChannels()
|
||||||
{
|
{
|
||||||
return channels;
|
return channels.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get channel by name
|
||||||
|
*/
|
||||||
|
public Channel getChannel(String name)
|
||||||
|
{
|
||||||
|
return channels.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -177,7 +187,7 @@ public class Server
|
|||||||
*/
|
*/
|
||||||
public void addChannel(Channel channel)
|
public void addChannel(Channel channel)
|
||||||
{
|
{
|
||||||
channels.add(channel);
|
channels.put(channel.getName(), channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user