TL;DR New Supybot WikiSearch plugin found here.
So a while back I wanted to add a simple Wiki Search to my Supybot IRC bot(well actually gribble based) so that users could easily search for project documentation on our wiki. I knew there were multiple options here. The first would be to just use an aliased search using Google site:insertwikihere.com but that couldn’t take advantage of the sites own search function and depends on Google’s indexing of the site. As the wiki is constantly being updated and has many technical subject that are not always easily googled I wasn’t sure I liked that idea.
The other option I had thought of was to find an existing Wikipedia search plugin and modify that for use with our wiki. This lead me to quantumlemur‘s github and his Wikipedia plugin. At first glance I could see where to modify the Wikiurl and that it would work for the task fairly well. I set to work modifying it and got it into a working state. I modified the search parts to point to our wiki’s url and removed the part where it pastes a snippit from the page so that it just returned the page title and url. This was to prevent the bot from being too spammy and prevent searches from hiding real channel conversation.
And it didn’t work. It turns out that his plugin actually parses the HTML of the search page and doesn’t use the
nice MediaWiki API. At the time I was lazy and modified it to work with the theme of our wiki and the mediawiki version used and all was good… ish.
Then recently we wanted to add a search for another projects wiki so I had to go in and modify things again, or I could just rewrite it from scratch. And that is what I did.
The end result was 50 lines of code known as the Supybot WikiSearch plugin. If I get unlazy and ambitious I’ll add some way to have one plugin manage searches for multiple wiki’s and have it auto-detect the api.php path from just the wiki’s home page. I also plan on allowing it to display the snippits as quantumlemur‘s version does though it will stay disabled by default.
Edit: Further work on this has lead me to take back my comment about the MediaWiki being “nice” Oh god is it a pain in the arse and totally in consistent on what it returns wiki to wiki installation. Whoever designed that needs a good slap in the face. Perhaps one day I’ll do a full rant on that…