try
{
// query the database for information about the nickname
DatabaseSeen database_seen = DatabaseSeenFactory.get();
SeenData search_result = database_seen.getSeen(bot, channel, seen);
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone(DroneConfig.getTimezone()));
// check if the nick is part of the current channel names
Iterator channel_nicknames_it = mFinishedChannelNames.getSeens(channel).iterator();
String channel_nickname = null;
while (channel_nicknames_it.hasNext())
{
channel_nickname = (String)channel_nicknames_it.next();
if (seen.equals(channel_nickname.toLowerCase()))
{
StringBuffer formatted_result = new StringBuffer();
formatted_result.append(channel_nickname);
formatted_result.append(" is currently online in ");
formatted_result.append(channel.getName());
if (null == search_result)
{
formatted_result.append(", but never said anything that I saw.");
}
else
{
formatted_result.append(" and last spoke on ");
formatted_result.append(DATE_FORMAT.format(search_result.getMoment()));
formatted_result.append(", saying '");
formatted_result.append(search_result.getDisplayMessage());
formatted_result.append("'.");
}
return formatted_result.toString();
}
}
if (null == search_result)
{
StringBuffer formatted_result = new StringBuffer();
formatted_result.append("I've never seen ");
formatted_result.append(seen);
formatted_result.append(" talk in ");
formatted_result.append(channel.getName());
formatted_result.append(".");
reply = formatted_result.toString();
return reply;
}
else
{
ServerMessage message = ServerMessage.parse(search_result.getRaw());
StringBuffer formatted_result = new StringBuffer();
formatted_result.append(search_result.getNickname());
formatted_result.append(" (");
formatted_result.append(message.getPrefix().getRaw().substring(1));
formatted_result.append(") was last seen in ");
formatted_result.append(channel.getName());
formatted_result.append(" on ");
formatted_result.append(DATE_FORMAT.format(search_result.getMoment()));
formatted_result.append(", saying '");
formatted_result.append(search_result.getDisplayMessage());
formatted_result.append("'.");
reply = formatted_result.toString();
return reply;
}
}