If you've seen or interacted with an IRC bot before, than this is nothing new. The bot sits in the channel and waits for commands (or may run them on its own if programmed to), and then prints the output to the channel.
(11:20:13 PM) bbby: .chuck (11:20:14 PM) botzilla: Chuck Norris does not have to answer the phone. His beard picks up the incoming electrical impulses and translates them into audible sound. (11:21:22 PM) bibuntu: .weather 02138 (11:21:24 PM) botzilla: Fair, and 72° F.
Other bots use characters ! or ` as "command characters" to distinguish an ordinary word from a specific command to the bot. For no real reason, botzilla's command char is ., but if authored appropriately, a plugin would use the PHP constant CMD_CHAR, and then you are free to define nay char that you want. Or, you don't need one at all (some plugins in the repo just listen for certain words in general).
pipe |
CoWorker of mine, and plugin author, David Gucwa, insisted on being able to pipe the output of one plugin into another. I resisted this at first, but quickly became of fan of it once it was finished. Consider this example where a method existed .chuck that printed a Chuck Norris "factoid" and a method .jumble that rearranged the words in a sentence.
(11:29:32 PM) bibuntu: .jumble one two three four (11:29:33 PM) botzilla: three one four two (11:29:35 PM) bibuntu: .chuck (11:29:35 PM) botzilla: As an infant, Chuck Norris' parents gave him a toy hammer. He gave the world Stonehenge. // one could.. // (11:30:26 PM) bibuntu: .chuck | .jumble (11:30:27 PM) botzilla: Little Chuck on her roundhouse tuffet, a until Norris into Miss glacier. Muffet sat kicked her
This makes for the great occasional channel topic.
To help stay out of the way of popular sed and grep plugins,
"pipe" is defined as space-pipe-space ( | ) for splitting functions.
Here's something I've wanted to fix with pipe, though.
Some output is multi-lined. Say for fictional example, .haiku
bbby: .haiku botzilla: A place for dying botzilla: They all migrate every year botzilla: state of FloridaSo far, this can be piped to another function to get a different result, say reverse
bbby: .haiku | .reverse botzilla: gniyd rof ecalp A botzilla: raey yreve etargim lla yehT botzilla: adirolF fo etatsThat's fine. And is the case where multilined output calls multilined output
bbby: .haiku | .haiku botzilla: A place for dying botzilla: They all migrate every year botzilla: state of Florida botzilla: A place for dying botzilla: They all migrate every year botzilla: state of Florida botzilla: A place for dying botzilla: They all migrate every year botzilla: state of FloridaThe above is (to me) a good result. Each line of the first haiku called it's own haiku, netting 9 lines total.
There's only one depth level of pipe-cache, so here's where it breaks.
bbby: .haiku | .haiku | .reverse botzilla: gniyd rof ecalp A botzilla: raey yreve etargim lla yehT botzilla: adirolF fo etatsThe first line of the first haiku is given back three lines. But as soon as the first line is piped into rev, that pipe cache is replaced by the second haiku that it calls. The desired result would be 9 revered lines.