wordoftheday.tcl
#1
Hi All, i need help from this script to an autoshow message to the channel. And if you can explain the added code for autoshow. that much better so that i can understand more. Thank you.

tcl
package require tdom
package require http
 
bind pub - !word pub:wordoftheday
 
set wotdurl "http://www.urbandictionary.com/"
 
proc pub:wordoftheday {nick host handle chan text} {
    global wotdurl
 
    if {[catch {
set page [::http::data [::http::geturl $wotdurl]]
set doc [dom parse -html $page]
set root [$doc documentElement]
 
set titleNode [$root selectNodes {//div[@class='word']/a[1]/text()}]
 
if {$titleNode == ""} {
    set titleNode [$root selectNodes {//td[@class='def_word']/a[1]/text()}]
}
 
set title [string trim [[lindex $titleNode 0] nodeValue]]
putserv "PRIVMSG $chan :Word of the day is: \002$title\002"
 
set defs [$root selectNodes {//div[@class='definition']}]
if {$defs != ""} {
    set deftextnodes [[lindex $defs 0] selectNodes {self::*//text()}]
 
    set examples [$root selectNodes {//div[@class='example']}]
    set exampletextnodes [[lindex $examples 0] selectNodes {self::*//text()}]
 
    set def ""
    set example ""
 
    foreach node $deftextnodes {
# why doesn't eggdrop output newlines?
# it just stops outputting when newline comes up
append def [string map {"\n" " "} [string trim [$node nodeValue]]]
append def " "
    }
    putserv "PRIVMSG $chan :$def"
 
    foreach node $exampletextnodes {
# why doesn't eggdrop output newlines?
# it just stops outputting when newline comes up
append example [string map {"\n" " "} [string trim [$node nodeValue]]]
append example " "
    }
    putserv "PRIVMSG $chan :$example"
} else {
    set parags [$root selectNodes {//tr[2]//p}]
 
    foreach p $parags {
set text ""
set textnodes [$p selectNodes {self::*//text()}]
foreach node $textnodes {
    # why doesn't eggdrop output newlines?
    # it just stops outputting when newline comes up
    append text [string map {"\n" " "} [$node nodeValue]]
}
putserv "PRIVMSG $chan :$text"
    }
 
}
    } err]} {
putserv "PRIVMSG $chan :WotD failed - $err"
    }
 
}

###################################
putlog "Word Of The Day script loaded!"
###################################


Répondre


Messages dans ce sujet
wordoftheday.tcl - par aslpls - 06/08/2025, 18:02
RE: wordoftheday.tcl - par CrazyCat - 06/08/2025, 18:35
RE: wordoftheday.tcl - par aslpls - 07/08/2025, 08:17

Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)
Tchat 100% gratuit - Discutez en toute liberté - Transitionnez vers Linux - Discussions dans le Lauragais - Communauté LGBT respectueuse - soutien aux victimes de cybermalveillance - pour les filles par les filles