TclScripts/Mediawiki


 * 1)      ____  ____
 * 2)  ___|___ \|___ /
 * 3) / __| __) | |_ \
 * 4) \__ \/ __/ ___) |
 * |___/_____|____/.org/wiki/
 * 1) mediawiki.tcl v0.23
 * 2) A Mediawiki <-> IRC - Eggdrop TCL script
 * 3) tested on mediawiki 1.4/1.5 and eggdrop 1.6.13/1.6.16
 * 4) Mediawiki: http://meta.wikimedia.org/wiki/Mediawiki | #mediawiki on Freenode
 * 5) Eggdrop: http://eggheads.org/ | http://egghelp.org/ | #egghelp on Efnet
 * 6) by mutante (http://s23.org/wiki/User:mutante) (mutante@s23.org) of
 * 7) the S23 Cabal (http://s23.org/wiki/) | #wiki,#bots on Efnet
 * 8) v0.23 pre-release by [Hyarion]'s request. 25.Okt.2005
 * 9) licensed under "Attribution-NonCommercial-ShareAlike 2.0"
 * 10) http://creativecommons.org/licenses/by-nc-sa/2.0/
 * 1) http://creativecommons.org/licenses/by-nc-sa/2.0/

set file /usr/local/lib/mysqltcl-2.40/libmysqltcl2.40 load ${file}[info sharedlibextension]
 * 1) this script uses "libmysqltcl" for the TCL<->Mysql connection
 * 2) you can get it from http://rufus.o-town.de/eggdrop/


 * 1) config
 * 1) config

set myhost "localhost" set myuser "wikiuser" set mydb "wikidb" set mypass "yourpassword"
 * 1) MYSQL
 * 2) database host
 * 1) database user
 * 1) database name
 * 1) database password

set mywiki "S23-Wiki" set mybaseurl "http://s23.org/wiki"
 * 1) BASIC
 * 2) Name of your Wiki
 * 1) (All Your Base..) URL (the part before the wiki page name)


 * 1) MISC

set myrcnum "7" set myfindlimit "5" set myspamdays "5" set myotherbot "padma" set mypopnum "4" set mysetupdate "Feb,04 2005" set mydisplaychars "120"
 * 1) number of recent changes displayed on .rc
 * 1) max number of results shown on .find and .content
 * 1) number of days a spammer is blocked on .ban
 * 1) name of another (infobot) bot used on .teach
 * 1) number of popular pages displayed on .popular
 * 1) the date your wiki was setup ,used on .stats
 * 1) number of characters shown of a wikipage content on .display




 * 1) the (public) triggers

bind pub - .rc wikirc
 * 1) Recent changes

bind pub - .find findpage bind pub - .title findpage
 * 1) Search in titles

bind pub - .content findcontent bind pub - .full findcontent
 * 1) Search fulltext

bind pub - .popular popular
 * 1) Show popular pages

bind pub - .display display
 * 1) Display page content (first x chars)

bind pub - .teach teach
 * 1) Teach other (info)bot

bind pub - .stats wikistats
 * 1) Show Statistics


 * 1) Show Sysops (disabled because broken since 1.5 upgrade / database change)
 * 2) bind pub - .sysops sysops


 * 1) add / remove IP bans (only for users with +W flag)

bind pub W .ban ban bind pub W .unban unban

bind pub - .help help
 * 1) help


 * 1) the procs

proc help {nick host hand chan args} { puthelp "privmsg $chan : Mediawiki.tcl script by S23/mutante. Here are the triggers, $nick" puthelp "privmsg $chan : .title - SEARCHes for a string in page TITLE (Alias .find)" puthelp "privmsg $chan : .content - SEARCHes for a string in the page CONTENT (Alias .full)" puthelp "privmsg $chan : .display - SHOWs the CONTENT of a wiki page (currently first $::mydisplaychars chars)" puthelp "privmsg $chan : .rc - SHOWs the last 5 CHANGES on the Wiki (Recent Changes)" puthelp "privmsg $chan : .popular - SHOW the most POPULAR wiki pages (hit count)" puthelp "privmsg $chan : .stats - SHOW the wiki STATISTICS" puthelp "privmsg $chan : .ban  - ADD an IP BAN from the Wiki (for 5 days with reason 'spammer')" puthelp "privmsg $chan : .unban - REMOVE an IP BAN from the Wiki." puthelp "privmsg $chan : .teach - Bonus Trigger: TEACH padma (infobot) about ;)" puthelp "privmsg $chan : .help - SHOW this HELP message" puthelp "privmsg $chan : (K)2005 The S23-Cabal - visit us on http://s23.org/wiki/" }
 * 1) puthelp "privmsg $chan : .sysops - SHOW the wiki SYSOPS"

proc wikistats {nick host hand chan args} { set db [mysqlconnect -host $::myhost -user $::myuser -password $::mypass -db $::mydb] mysqlsel $db {SELECT ss_total_views,ss_total_edits,ss_good_articles from site_stats} putquick "privmsg $chan :$::mywiki Site-Stats" mysqlmap $db {ss_total_views ss_total_edits ss_good_articles} { putquick "privmsg $chan :Total Views: $ss_total_views Total Edits: $ss_total_edits Good Articles: $ss_good_articles (since mediawiki setup on $::mysetupdate)" } mysqlendquery $db mysqlclose $db }

proc sysops {nick host hand chan args} { global myhost,myuser,mypass,mydb set db [mysqlconnect -host $::myhost -user $::myuser -password $::mypass -db $::mydb] mysqlsel $db {SELECT user_name,user_email FROM user WHERE user_rights LIKE "%sysop%"} puthelp "privmsg $chan :$::mywiki Sysops" mysqlmap $db {user_name user_email} { puthelp "privmsg $chan :$user_name - $user_email" } mysqlendquery $db mysqlclose $db }

proc display {nick host hand chan args} { global myhost,myuser,mypass,mydb set db [mysqlconnect -host $::myhost -user $::myuser -password $::mypass -db $::mydb] set query "SELECT left(cur_text,120) as cur_sum FROM cur WHERE cur_title='$args'" mysqlsel $db $query puthelp "privmsg $chan :$::mywiki - Displaying page '$args' (first 120 chars)" mysqlmap $db {cur_sum} { puthelp "privmsg $chan :$cur_sum ... continued on $::mybaseurl/$args" } mysqlendquery $db mysqlclose $db }

proc ban {nick host hand chan args} { global myhost,myuser,mypass,mydb set db [mysqlconnect -host $::myhost -user $::myuser -password $::mypass -db $::mydb] set query "INSERT into ipblocks (ipb_address,ipb_user,ipb_by,ipb_reason,ipb_timestamp,ipb_auto,ipb_expiry) values ('$args','0','74','spammer (banned via IRC)',NOW+0,'0',ADDDATE(NOW,INTERVAL 1 DAY)+0);" mysqlsel $db $query puthelp "privmsg $chan :Ok, $nick, blocked '$args' for $::myspamdays days with reason 'spammer'" mysqlendquery $db mysqlclose $db }

proc unban {nick host hand chan args} { global myhost,myuser,mypass,mydb set db [mysqlconnect -host $::myhost -user $::myuser -password $::mypass -db $::mydb] set query "DELETE from ipblocks WHERE ipb_address='$args';" mysqlsel $db $query puthelp "privmsg $chan :Ok, $nick, removed block on '$args'" mysqlendquery $db mysqlclose $db }

proc teach {nick host hand chan args} { global myhost,myuser,mypass,mydb set db [mysqlconnect -host $::myhost -user $::myuser -password $::mypass -db $::mydb] set query "SELECT left(cur_text,120) as cur_sum FROM cur WHERE cur_title='$args'" mysqlsel $db $query mysqlmap $db {cur_sum} { puthelp "privmsg $chan :$::myotherbot, $args is $cur_sum ... $::mybaseurl/$args" } mysqlendquery $db mysqlclose $db }

proc wikirc {nick host hand chan args} { global myhost,myuser,mypass,mydb set db [mysqlconnect -host $::myhost -user $::myuser -password $::mypass -db $::mydb] set query "select rc_id,rc_title,rc_comment,rc_user_text from recentchanges order by rc_id desc LIMIT 0,$::myrcnum" mysqlsel $db $query puthelp "privmsg $chan :$::mywiki - Last $::myrcnum changes" mysqlmap $db {rc_id rc_title rc_comment rc_user_text} { puthelp "privmsg $chan :#$rc_id '$rc_title' $rc_comment by $rc_user_text ($::mybaseurl/$rc_title)" } mysqlendquery $db mysqlclose $db }

proc findpage {nick host hand chan args} { global myhost,myuser,mypass,mydb set db [mysqlconnect -host $::myhost -user $::myuser -password $::mypass -db $::mydb] set query "SELECT cur_title FROM cur WHERE cur_title LIKE '%$args%' LIMIT 0,$::myfindlimit" mysqlsel $db $query puthelp "privmsg $chan :$::mywiki - Searching for page titles containing '$args'" mysqlmap $db {cur_title} { puthelp "privmsg $chan :Found page $cur_title ($::mybaseurl/$cur_title)" } mysqlendquery $db mysqlclose $db }

proc findcontent {nick host hand chan args} { global myhost,myuser,mypass,mydb set db [mysqlconnect -host $::myhost -user $::myuser -password $::mypass -db $::mydb] set query "SELECT cur_title FROM cur WHERE cur_text LIKE '%$args%' LIMIT 0,$::myfindlimit" mysqlsel $db $query puthelp "privmsg $chan :$::mywiki - Searching for pages fulltext containing $args" mysqlmap $db {cur_title} { puthelp "privmsg $chan :Found page $cur_title ($::mybaseurl/$cur_title)" } mysqlendquery $db mysqlclose $db }

proc popular {nick host hand chan args} { global myhost,myuser,mypass,mydb set db [mysqlconnect -host $::myhost -user $::myuser -password $::mypass -db $::mydb] set query "select cur_title,cur_counter from cur ORDER by cur_counter DESC LIMIT 1,$::mypopnum" mysqlsel $db $query puthelp "privmsg $chan :$::mywiki Top $::mypopnum popular pages" mysqlmap $db {cur_title cur_counter} { puthelp "privmsg $chan :$cur_title ($cur_counter hits) - ($::mybaseurl/$cur_title)" } mysqlendquery $db mysqlclose $db }

putlog "Mediawiki.tcl by S23 loaded. Fnord. http://s23.org/wiki/"
 * 1) fnord
 * 2) mutante@s23.org