×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles

    TclScripts/Mediawiki: Difference between revisions

    Content added Content deleted
    imported>mutante
    mNo edit summary
    imported>mutante
    Line 9: Line 9:
    *.title <string> - SEARCHes for a string in page TITLE (Alias .find)
    *.title <string> - SEARCHes for a string in page TITLE (Alias .find)
    *.content <string> - SEARCHes for a string in the page CONTENT (Alias .full)
    *.content <string> - SEARCHes for a string in the page CONTENT (Alias .full)
    *.display <page> - SHOWs the CONTENT of a wiki page (currently firsti 120 chars)
    *.display <page> - SHOWs the CONTENT of a wiki page (currently first 120 chars)
    *.rc - SHOWs the last 5 CHANGES on the Wiki (Recent Changes)
    *.rc - SHOWs the last x CHANGES on the Wiki (Recent Changes)
    *.popular - SHOW the most POPULAR wiki pages (hit count)
    *.popular - SHOW the most POPULAR wiki pages (hit count)
    *.stats - SHOW the wiki STATISTICS
    *.stats - SHOW the wiki STATISTICS
    *.ban <IP> - ADD an IP BAN from the Wiki (for 5 days with reason 'spammer')
    *.ban <IP> - ADD an IP BAN from the Wiki (for x days with reason 'spammer')
    *.unban <page> - REMOVE an IP BAN from the Wiki.
    *.unban <page> - REMOVE an IP BAN from the Wiki.
    *.teach <page> - Bonus Trigger: TEACH padma (infobot) about <page> ;)
    *.teach <page> - Bonus Trigger: TEACH padma (infobot) about <page> ;)

    Revision as of 23:54, 24 October 2005

    A tcl script for eggdrop and mediawiki.

    by mutante 01:49, 25 October 2005 (CEST)

    Features

    Mediawiki.tcl

    • .title <string> - SEARCHes for a string in page TITLE (Alias .find)
    • .content <string> - SEARCHes for a string in the page CONTENT (Alias .full)
    • .display <page> - SHOWs the CONTENT of a wiki page (currently first 120 chars)
    • .rc - SHOWs the last x CHANGES on the Wiki (Recent Changes)
    • .popular - SHOW the most POPULAR wiki pages (hit count)
    • .stats - SHOW the wiki STATISTICS
    • .ban <IP> - ADD an IP BAN from the Wiki (for x days with reason 'spammer')
    • .unban <page> - REMOVE an IP BAN from the Wiki.
    • .teach <page> - Bonus Trigger: TEACH padma (infobot) about <page> ;)
    • .help - SHOW this HELP message

    Source

    #      ____  ____       
    #  ___|___ \|___ /             
    # / __| __) | |_ \
    # \__ \/ __/ ___) |
    # |___/_____|____/.org/wiki/
    #
    # mediawiki.tcl v0.23   
    # A Mediawiki <-> IRC - Eggdrop TCL script
    # tested on mediawiki 1.4/1.5 and eggdrop 1.6.13/1.6.16
    # Mediawiki: http://meta.wikimedia.org/wiki/Mediawiki | #mediawiki on Freenode
    # Eggdrop: http://eggheads.org/ | http://egghelp.org/ | #egghelp on Efnet
    # by mutante (http://s23.org/wiki/User:mutante) (mutante@s23.org) of
    # the S23 Cabal (http://s23.org/wiki/) | #wiki,#bots on Efnet
    # v0.23 pre-release by [Hyarion]'s request. 25.Okt.2005
    # licensed under "Attribution-NonCommercial-ShareAlike 2.0"
    # http://creativecommons.org/licenses/by-nc-sa/2.0/
    
    # this script uses "libmysqltcl" for the TCL<->Mysql connection
    # you can get it from http://rufus.o-town.de/eggdrop/
    set file /usr/local/lib/mysqltcl-2.40/libmysqltcl2.40
    load ${file}[info sharedlibextension]
    ##
    
    ####
    # config
    
    # MYSQL
    # database host
    set myhost "localhost"
    # database user
    set myuser "wikiuser"
    # database name
    set mydb "wikidb"
    # database password 
    set mypass "yourpassword"
    
    # BASIC
    # Name of your Wiki
    set mywiki "S23-Wiki"
    # (All Your Base..) URL (the part before the wiki page name)
    set mybaseurl "http://s23.org/wiki"
    
    # MISC
    
    # number of recent changes displayed on .rc
    set myrcnum "7"
    # max number of results shown on .find and .content
    set myfindlimit "5"
    # number of days a spammer is blocked on .ban
    set myspamdays "5"
    # name of another (infobot) bot used on .teach
    set myotherbot "padma"
    # number of popular pages displayed on .popular
    set mypopnum "4"
    # the date your wiki was setup ,used on .stats
    set mysetupdate "Feb,04 2005"
    # number of characters shown of a wikipage content on .display
    set mydisplaychars "120"
    
    ####
    
    ### the (public) triggers
    
    # Recent changes
    bind pub - .rc wikirc
    
    # Search in titles
    bind pub - .find findpage
    bind pub - .title findpage
    
    # Search fulltext
    bind pub - .content findcontent
    bind pub - .full findcontent
    
    # Show popular pages
    bind pub - .popular popular
    
    # Display page content (first x chars)
    bind pub - .display display
    
    # Teach other (info)bot
    bind pub - .teach teach
    
    # Show Statistics
    bind pub - .stats wikistats
    
    # Show Sysops (disabled because broken since 1.5 upgrade / database change)
    # bind pub - .sysops sysops
    
    # add / remove IP bans (only for users with +W flag)
    
    bind pub W .ban ban
    bind pub W .unban unban
    
    # help
    bind pub - .help help
    
    
    # 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 <string> - SEARCHes for a string in page TITLE (Alias .find)"
    puthelp "privmsg $chan : .content <string> - SEARCHes for a string in the page CONTENT (Alias .full)"
    puthelp "privmsg $chan : .display <page> - 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 : .sysops - SHOW the wiki SYSOPS"
    puthelp "privmsg $chan : .stats - SHOW the wiki STATISTICS"
    puthelp "privmsg $chan : .ban <IP> - ADD an IP BAN from the Wiki (for 5 days with reason 'spammer')"
    puthelp "privmsg $chan : .unban <page> - REMOVE an IP BAN from the Wiki."
    puthelp "privmsg $chan : .teach <page> - Bonus Trigger: TEACH padma (infobot) about <page> ;)"
    puthelp "privmsg $chan : .help - SHOW this HELP message"
    puthelp "privmsg $chan : (K)2005 The S23-Cabal - visit us on http://s23.org/wiki/"
    }
    
    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/"
    # fnord
    # mutante@s23.org
    
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.