[Eggdrop] hashkiller.tcl

Ne Doku braucht es dafuer hoffentlich nicht.

# hashkiller.tcl by TamCore
# ** setting
set hashkiller(trigger) "\$hash"

# ** binding
bind    PUB -|- "$hashkiller(trigger)"  hashkiller:default

# ** code
package require http

proc hashkiller:default { nickname handle hostname channel arguments } {
    global lastbind
    set hash [lindex $arguments ]
    if { $hash == "" || [strlen $hash] != "32" } {
        putquick "NOTICE $nickname :Usage:   $lastbind "
        putquick "NOTICE $nickname :Example: $lastbind 098f6bcd4621d373cade4e832627b4f6"
        return
    }
    set url "http://hashkiller.com/api/api.php?md5=$hash"
    set connection [http::config -useragent "Mozilla 4.0"]
    catch {set connection [http::geturl $url -timeout 3000]} error
    set data   [http::data $connection]
        set found  [lindex [split $data "\n"] 2]
    regexp {^.*<found>(.*)</found>} $found -> found
    set plain  [lindex [split $data "\n"] 3]
        regexp {^.*<plain>(.*)</plain>} $plain -> plain
    set hash   [lindex [split $data "\n"] 4]
        regexp {^.*<md5>(.*)</md5>} $hash -> hash
    http::cleanup $connection
    if { $found == "true" } {
        putquick "PRIVMSG $channel :\002(\002$lastbind\002)\002 $hash => $plain"    
    } else {
        putquick "PRIVMSG $channel :\002(\002$lastbind\002)\002 could not find $hash"
    }
}