IrcWikiSearch

=== How to search ((Mediawiki)) wiki pages from IRC (current).

Go to Efnet #wiki and use the triggers:

.title

To search the titles of Wiki pages.

Example: .title Debian

.content

To search the full text content of Wiki pages.

Example: .content Sex

Additional triggers include (.stats (statistics) .sysops (sysop emails) and .rc (show last 5 changes).

How to search (UseMod) wiki pages from IRC (outdated & the ugly way)

 * Setup an 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 {\' \'\\\'\'} $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