/*
This file is part of leafdigital leafChat.
leafChat is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
leafChat is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with leafChat. If not, see <http://www.gnu.org/licenses/>.
Copyright 2011 Samuel Marshall.
*/
package com.leafdigital.irc.api;
import java.util.Collection;
import leafchat.core.api.*;
/** Represents a parsed message received from an IRC server, parsed */
public abstract class WatchMsg extends Msg
{
/** Server that sent the message */
private Server s;
/** Address of user who logged on/off line */
private IRCUserAddress ua;
/** True if this was really a change in user's status */
private boolean realChange;
protected WatchMsg(Server s,IRCUserAddress ua, boolean realChange)
{
this.s=s;
this.ua=ua;
this.realChange=realChange;
}
/** @return Server we're dealing with */
public Server getServer()
{
return s;
}
/** @return Nickname */
public String getNick()
{
return ua.getNick();
}
/** @return User address. Note that if ISON was used, all except nick will be blank */
public IRCUserAddress getUserAddress()
{
return ua;
}
/** @return True if this was really a result of user change, false if it's just 'cause we started watching */
public boolean isRealChange()
{
return realChange;
}
/** Scripting event information. */
public static MessageInfo info = new MessageInfo(WatchMsg.class, "Watch list",
"Events generated by leafChat to notify when people on the watch list " +
"(friends, plus a few others added by the system) come online or go offline.")
{
@Override
public String getContextInit()
{
return "registerContext(msg.getServer(),null,null,null);";
}
@Override
public boolean allowScripting()
{
return true;
}
@Override
protected void listAppropriateFilters(Collection<FilterInfo> list)
{
super.listAppropriateFilters(list);
list.add(NickFilter.info);
}
@Override
protected void listScriptingVariables(Variables v)
{
super.listScriptingVariables(v);
v.add("nick");
}
};
}