Hi Sir, can you help me to fixed this? Kudos Sir, Happy New Year!
# Procedure to retrieve a random quote from the website
proc get_random_quote {url} {
package require http
package require html
package require tls
http::register https 443 [list ::tls::socket -tls1 1]
# Retrieve the HTML data from the website
set cookie [http::geturl $url]
set data [http::data $cookie]
# Parse the HTML data using the html package
set html [html::parse $data]
# Extract the quote and author from the HTML
set quote [html::select $html "div.quoteText"]
set author [html::select $html "div.authorText"]
# Return the quote and author
return [list $quote $author]
}
# Procedure to handle the "!quote" command in the IRC channel
proc quote {nick uhost hand chan text} {
# Get a random quote from the website
set quote_info [get_random_quote "https://www.goodreads.com/quotes/random"]
# Check if the quote was successfully retrieved
if {[llength $quote_info] == 2} {
# Extract the quote and author from the returned list
set quote [lindex $quote_info 0]
set author [lindex $quote_info 1]
# Split the quote into a list of words
set words [split $quote]
# Initialize an empty list to store the colored words
set colored_words {}
# Iterate through each word in the quote
foreach word $words {
# Generate a random color code
set color [format "#%02x%02x%02x" [expr {int(rand()*256)}] [expr {int(rand()*256)}] [expr {int(rand()*256)}]]
# Add the colored word to the list of colored words
lappend colored_words [format "\003%s%s" $color $word]
}
# Join the colored words into a single string
set colored_quote [join $colored_words " "]
# Send the colored quote to the channel
putserv "PRIVMSG $chan :$colored_quote - $author"
} else {
# Send an error message if the quote was not retrieved
putserv "PRIVMSG $chan :Unable to retrieve quote of the day"
}
}
# Bind the "!quote" command to the quote procedure
bind pub -|- !quote quote
Hello Sir,
Great, but another error appear the following:
Tcl error [goodreads:randomQuote]: list element in quotes followed by "
Tcl error [goodreads:randomQuote]: list element in quotes followed by "Why" instead of space
Kudos Sir!
Great, but another error appear the following:
Tcl error [goodreads:randomQuote]: list element in quotes followed by "
Tcl error [goodreads:randomQuote]: list element in quotes followed by "Why" instead of space
Kudos Sir!
Hi Sir,
Happy New Year, the qotd.tcl gets error
[23:03:03] Tcl error [goodreads:randomQuote]: list element in braces followed by "{}{—ShelSilverstei" instead of space
Kudos Sir!
Happy New Year, the qotd.tcl gets error
[23:03:03] Tcl error [goodreads:randomQuote]: list element in braces followed by "{}{—ShelSilverstei" instead of space
Kudos Sir!
It's done, downoad it from here: https://www.tclscripts.net/product/qotd-tcl/