heartbroken It is an excellent code but it needs to add words that link to other examples such as words from Spanish to English
I added to the tcl this route which will recognize a word in Spanish
example: (españa=spain) or (republica dominicana=Dominican Republic) in IRC: .t españa
Code: Select all
set text [string map [list México mexico japon japan granada Grenada españa Spain Japón japon italia Italy francia France egipto egypt rusia russia alemania germany chipre cyprus {republica dominicana} {Dominican Republic}] $text]
Code: Select all
bind pub - .t worldntime
proc worldntime {nick uhost hand chan text} {
if {![channel get $chan wtime]} { return 0 }
if {![llength $text]} { puthelp "privmsg $chan :Usage: $::lastbind <location>"; return 0 }
set text [string map [list México mexico japon japan granada Grenada españa Spain Japón japon italia Italy francia France egipto egypt rusia russia alemania germany chipre cyprus {republica dominicana} {Dominican Republic}] $text]
set token [http::geturl http://localtimes.mobi/search/?s=[join $text +]&x=0&y=0 -timeout 9000]
set data [http::data $token]
::http::cleanup $token
if {[regexp -- {Home</a>(.+?)</span>.+?<div class="timeinfo">(.+?)</div>.+?<div class="tz_container">(.+?)</li>} $data - loc t1 t2]} {
puthelp "privmsg $chan :\00304[cleanup $loc]\003: [cleanup $t1]"
puthelp "privmsg $chan :[cleanup $t2]"
} else { puthelp "privmsg $chan :No any information found for \"$text\". Please be more specific!"; return }
return 0
}
proc cleanup str {
regsub -all -- {(?:<label>|</label>)} $str \002 str
regsub -all -- "<.+?>" $str " " str
regsub -all -- {»} $str \003\u00bb\00304 str
regsub -all -- { } $str { } str
regsub -all -- {\s+} $str { } str
return $str
}
setudef flag wtime
What I added works well for me but I don't know if it will be fine like that, I would like you to review it please
Code: Select all
set text [string map [list México mexico japon japan granada Grenada españa Spain Japón japon italia Italy francia France egipto egypt rusia russia alemania germany chipre cyprus {republica dominicana} {Dominican Republic}] $text]
Code: Select all
[00:37] <@Arnold_X-P> .t spain
[00:37] <@Kantuta> » Europe » Spain : Current local time: 5:37:27 am Date: Sunday 14 November 2021 Time zone: CET (Central Europe Time) Current time zone offset: +01:00 hours
[00:37] <@Kantuta> Western Europe Time WET 31 Oct 2021 Sunday 31 Oct 2021 at 1:00:00 am local time to 27 Mar 2022 Sunday 27 Mar 2022 at 1:00:00 pm local time, the time changes to 2:00:00 am Offset: UTC +0:00 DST ended on 31 Oct 2021, clocks moved back 1 hour; from 2:00:00 am to 1:00:00 am
and the linked variant from Spanish to English (spain= españa)
Code: Select all
[00:37] <@Arnold_X-P> .t españa
[00:37] <@Kantuta> » Europe » Spain : Current local time: 5:37:30 am Date: Sunday 14 November 2021 Time zone: CET (Central Europe Time) Current time zone offset: +01:00 hours
[00:37] <@Kantuta> Western Europe Time WET 31 Oct 2021 Sunday 31 Oct 2021 at 1:00:00 am local time to 27 Mar 2022 Sunday 27 Mar 2022 at 1:00:00 pm local time, the time changes to 2:00:00 am Offset: UTC +0:00 DST ended on 31 Oct 2021, clocks moved back 1 hour; from 2:00:00 am to 1:00:00 am
Also if it is possible to add that when there is no internet connection the bot makes it known by means of a message to the channel.
Code: Select all
if {[string match -nocase "*couldn't open socket*" $error]} {
puthelp "PRIVMSG $chan :Error: There is no internet connection .. Please try again later."