//} */
}
@Override
public ParsedResult trigger(ParsedResult inputText) {
ParsedResult result = null;
try {
String matchTrigger = inputText.getStrippedText().trim();
for (Integer priority : loadedTriggerSets.keySet()) {
HashSet<TriggerSet> triggersForPriority = loadedTriggerSets
.get(priority);
for (TriggerSet aTrigger : triggersForPriority) {
if (aTrigger.isActive()) {
// First we check the endPattern
if (aTrigger.getEndPattern() != null) {
Matcher endMatcher = aTrigger.getEndPattern()
.matcher(matchTrigger);
if (endMatcher.matches()) {
result = aTrigger.handleEndTrigger(endMatcher,
inputText);
return result;
}
}
// Loop over trigger patterns
for (String triggerName : aTrigger.getTriggerPatterns()
.keySet()) {
Pattern trigPattern = aTrigger.getTriggerPatterns()
.get(triggerName);
Matcher triggerMatcher = trigPattern
.matcher(matchTrigger);
if (triggerMatcher.matches()) {
result = aTrigger.handleTrigger(triggerName,
triggerMatcher, inputText);
}
}
}
}
}
if (GagHandler.gagLine(inputText)) {
debugInfo("Gagging: " + inputText.getStrippedText().trim());
result = inputText;
result.setStrippedText("");
}
} catch (Throwable t) {
debugInfo("EXCEPTION: " + t.getMessage());
t.printStackTrace();
}