IrcWikiSearch

How to search (UseMod) wiki pages in IrC (the ugly way)


 * Setup an [EggDrops eggdrop] bot.


 * Load a tcl script like this:

---

Using set data10 [exec bash -c "/home/kallisti/egg/scripts/wiki.sh $text"]; is a security risk, as everyone can run commands on your box. Don't do that. The code below is untested, but it should protect from exploits. -- thanks for your input, updated that.

bind pub - !wiki wikisearch

proc wikisearch {nick host hand chan text} { set quotedtext [string map {FOOBAR} $text]; set data [exec bash -c "/home/kallisti/egg/scripts/wiki.sh '$quotedtext'"]; regsub -all { } $data {} output; putlog "$output"; putserv "PRIVMSG $chan :$output";

}

---

Yup,(almost) all it does is execute a shell script (wiki.sh), thats the ugly part about it ,because one could also do the whole job inside the .tcl (please add here if you like)


 * add the wiki.sh

---

tempfile="wikisearch.tmp"
 * 1) /bin/bash

echo "`grep -i -R -l -h $1 /var/www/wiki/page/* | cut -d/ -f7 | cut -d. -f1`" > $tempfile wcount=`less $tempfile | wc -l` echo "Found '$1' in $wcount wiki pages. Outputting 1 random hit: http://wiki.s23.org/wiki.pl?`rl -c1 $tempfile` Find the rest on http://wiki.s23.org/wiki.pl?search=$1&dosearch=Go!"

---

This greps recursively thru /var/www/wiki/page/* (the place all the wiki pages are stored), uses "cut" to get the right piece of text and dumps it to a tempfile. Then it counts the number of hits using "wc" and outputs 1 random hit (using 'rl' = randomline command) and adds the link to the wiki search function.

The result is :

If you type !wiki on a channel you can search the wiki pages for your keyword and click the right link without having to first go to the wiki search function.

thats it so far,, make it more elegant if you like..

mutante