}
String key = getKey(bot, nick);
HashMap last_channels = null;
SoftReference reference = (SoftReference)mLastMessages.get(key);
if (reference !=null)
{
last_channels = (HashMap)reference.get();
}
Matcher detect_matcher = DETECT.matcher(fullMessage.getTrailing());
if (detect_matcher.matches())
{
if (null == last_channels)
{
return;
}
String last_log = (String)last_channels.get(channel.getName());
if (null == last_log)
{
return;
}
try
{
Pattern log_pattern = Pattern.compile(detect_matcher.group(1));
Matcher log_matcher = log_pattern.matcher(last_log);
String result = null;
if ("g".equals(detect_matcher.group(3)))
{
result = log_matcher.replaceAll(detect_matcher.group(2));
}
else
{
result = log_matcher.replaceFirst(detect_matcher.group(2));
}
if (!last_log.equals(result))
{
if (result.length() > 120)
{
result = result.substring(0, 120);
}
channel.send(nick+": "+result);
}
}
catch (PatternSyntaxException e)
{
List list = StringUtils.split(e.getMessage(), "\n");
Iterator list_it = list.iterator();
boolean first = true;
while (list_it.hasNext())
{
if (first)
{
channel.send(nick+": your regular expression was not valid, "+list_it.next());
}
else
{
channel.send(nick+": "+list_it.next());
}
first = false;
}
}
}
else
{
if (null == last_channels)
{
last_channels = new HashMap();
mLastMessages.put(key, new SoftReference(last_channels));
}
last_channels.put(channel.getName(), fullMessage.getTrailing());
}
}