@verb #1314:"jabber" this none this rxdo #1314 @program #1314:"jabber" this none this "Inputs a line of user text. Returns a line of response." {input} = args "Extract text from 'say'" if (m = match(input, ". %(says%|asks%|exclaims%), \"%(.*%)\"$")) input = input[m[3][2][1]..m[3][2][2]] endif "Normalise spaces" input = " " + $su:from_list($su:explode(input), " ") + " " "Don't respond to input that has no vowels" if (!match(input, "[aeoiu]")) return "" endif "Swearing is easy to detect" if (input != $msg:censor(input)) return ":frowns." endif "Look for matching keyword pairs" matches = {} for pair in (this.keywords) if (index(input, pair[1])) matches = {@matches, pair} endif endfor if (matches) "We found a match to work with" pair = matches[random(length(matches))] result = pair[2] if (index($su.alphabet, result[$])) "This reply needs a clip from the input" clip = input[index(input, pair[1]) + length(pair[1])..$] punc = $math_utils:min_positive(index(clip, "."), index(clip, "?"), index(clip, "!"), index(clip, ";"), index(clip, ":")) clip = " " + clip[1..punc ? punc - 1 | $] + " " clip = $su:substitute(clip, this.conjugate) clip = $su:trim(clip) result = result + " " + clip "If it is a Wh* or How result, add a ?" if (index(result, "Wh") == 1 || index(result, "How ") == 1) result = result + "?" else result = result + "." endif endif result = "\"" + $su:capitalise(result) else "I have *no* idea what the player said" result = this.huhs[random(length(this.huhs))] endif return this:prefix_name(result) "Last modified by Dax (#789) on Sun Nov 3 03:19:44 2002 MST." .