This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Worldtime1.3.tcl working, again.

Support & discussion of released scripts, and announcements of new releases.
Post Reply
User avatar
LOQUILLO
Voice
Posts: 14
Joined: Wed Jul 21, 2004 4:45 pm
Location: Perú

Post by LOQUILLO »

username wrote:What does it mean?

Code: Select all

  if {[lsearch -exact {[censored] poo crap} $tloc] != -1} {
and

Code: Select all

  if {[lsearch -exact {[censored] nigger [censored]} $tloc] != -1} {
I think forum blocks badwords from code and change them to [censored], so code what was copypasted from here wouldnt work.

Later:
I understand, I can change [censored] to any word I like to prevent commands like !tz idiot.
oh! here the newest

Code: Select all

 if {[lsearch -exact {s-h-i-t poo crap} $tloc] != -1} {

Code: Select all

if {[lsearch -exact {f-u-c-k nigger c-u-n-t} $tloc] != -1} {
you have in there the right words but you need delete the "-" in them.
LOQUILLO
IRC Network: EFnet
Channel: #Spanglish
f
froggie
Voice
Posts: 2
Joined: Sat Aug 18, 2007 7:44 pm

Lost it again

Post by froggie »

Not to open an old wound, but I believe the worldtime tcl has broke again. I had the old fix, and sometime between then and now, its fallen over again.

Anyone want to have a fresh look at it?
I am, the Pirate Froglet.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Use the script from this post.

line 109 - change from:

Code: Select all

regexp {<div id="analog-digital"><font size="7">(.+?)</font></div>} $tzout {} tztime
line 109 - change to:

Code: Select all

regexp {<div id="analog-digital">.+?<font size="7">(.+?)</font>.+?</div>} $tzout {} tztime
line 111 - change from:

Code: Select all

 return $tztime
line 111 - change to:

Code: Select all

return [string trim $tztime]
<speechles> !tz san francisco
<bot> The time in San Francisco,United States is 18:18
<speechles> !tz new york
<bot> The time in New York,United States is 21:18
Dunno if that is what the expected output should be but if it is, here you go. :lol:
f
froggie
Voice
Posts: 2
Joined: Sat Aug 18, 2007 7:44 pm

yay!

Post by froggie »

Woot, works again, thank you! :mrgreen:
I am, the Pirate Froglet.
Z
Zircon
Op
Posts: 191
Joined: Mon Aug 21, 2006 4:22 am
Location: Montreal

Post by Zircon »

Hi all

Worldtime.tcl isnt working again. I think something did change in the website and the script cant parse it correctly. Does anyone have a fix for it ? maybe speechles can help us :)
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Zircon wrote:Hi all

Worldtime.tcl isnt working again. I think something did change in the website and the script cant parse it correctly. Does anyone have a fix for it ? maybe speechles can help us :)
Sure I can, this is a simple regexp fix. Enjoy :wink:

line 109 - change from:

Code: Select all

regexp {<div id="analog-digital">.+?<font size="7">(.+?)</font>.+?</div>} $tzout {} tztime
line 109 - change to:

Code: Select all

regexp {<div id="analog-digital">.+?<span class="font7">(.+?)</span>.+?</div>} $tzout {} tztime
Conversely, for a bit more added info, you can change line 109 & 110 to this:

Code: Select all

regexp {<div id="analog-digital">.+?<span class="font7">(.+?)<.+?<span class="font1">(.+?)<} $tzout {} tztime tzzone
return "[string trim $tztime] [string trim $tzzone]"
#NoWordWrap##########################################################################################################
#NoWordWrap### only present to defeat linefeeds on the forum, isn't code you need to use.
example from irc wrote:<speechles> !tz san francisco
<sp33chy> The time in San Francisco,United States is 13:14 Pacific Daylight Time (PDT) -0700 UTC
<speechles> !tz berlin
<sp33chy> The time in Berlin,Germany is 22:16 Central European Summer Time (CEST) +0200 UTC
Tip: You can put what is below after your get html routine, but before the actual parsing begins, as a way to help debug.

Code: Select all

# DEBUG DEBUG                    
set $_debug [open "my_debug.txt" w]
puts $_debug $VARIABLE_STORING_YOUR_HTML
close $_debug
Load your my_debug.txt into a program such as RegexBuddy or similar, it makes dealing with regular expressions childs play.
Last edited by speechles on Sat Sep 22, 2007 6:59 pm, edited 1 time in total.
Z
Zircon
Op
Posts: 191
Joined: Mon Aug 21, 2006 4:22 am
Location: Montreal

Post by Zircon »

Hello speechles

Thanks a lot, it s working again, and thanks for the other infos :)
p
panasonic
Voice
Posts: 25
Joined: Sat Sep 15, 2007 5:27 am

Post by panasonic »

hi!
can u update the latest fixes on the first page so we dont have to scroll pages to see where's the latest fixes?

can i know whether this script can be set to active on certain channel the bot is in by setting e.g .chanset #channel +worldtime ?

btw thanks for this great script!
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

panasonic wrote:hi!
can u update the latest fixes on the first page so we dont have to scroll pages to see where's the latest fixes?
Nah, doing on the first page makes it too easy (not to mention, I'm not LOQUILLO so how do you suggest I edit his post?). Let's instead bury the link to the the full working script here in this part of the thread.. Make them work for their bread.. heh.. Anyways, to get it (click here worldtime v1.3)
panasonic wrote:can i know whether this script can be set to active on certain channel the bot is in by setting e.g .chanset #channel +worldtime ?
It will now work using .chanset #yourchan +worldtime per your request.

Code: Select all

#    v1.3 Nov 02 2007 updated by speechles                            #
#       -- Fixed the regexp scraper.                                  #
#       -- Added scraper for new info to display, exciting! :P        #
#       -- Added chanset ability .chanset #yourchan +worldtime        #
#       -- Added preliminary Multi-Language ability.                  #
#       -- Script now scrapes entire output line directly from the    #
#          webpage, and how it has multilanguage capability, default  #
#          at the moment is english.                                  #
sample from irc wrote:<speechles> !tz .de san francisco
<sp33chy> The current time in San Francisco, California, United States is 17:20 Pacific Daylight Time (PDT) -0700 UTC @ Freitag, 2. November 2007
<speechles> !tz san francisco
<sp33chy> The current time in San Francisco, California, United States is 5:20 PM Pacific Daylight Time (PDT) -0700 UTC @ Friday, November 02, 2007
<speechles> !tz .fr san francisco
<sp33chy> The current time in San Francisco, California, United States is 17:15 Pacific Daylight Time (PDT) -0700 UTC @ vendredi 2 novembre 2007
Now you have a 'full blown' time script. The multi language is functional, but just the date seems to be changing not the 'The current time in...' line (blame the website)... enjoy never the less :wink:
Take note: The multi-language at the moment is an undocumented feature and the comments do not reference it in the usage portion, because of it's limitations. It's there if you want to use it for some reason...
p
panasonic
Voice
Posts: 25
Joined: Sat Sep 15, 2007 5:27 am

Post by panasonic »

thanks sir, it works great!

Code: Select all

<panasonic> !time new york
<chanBot> The current time in New York, New York, United States is 2:02 AM Eastern Daylight Time (EDT) -0400 UTC @ Saturday, November 03, 2007
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

<speechles> !tz san fran
<sp33chy> The current time in San Francisco, California, United States is 8:24 AM Pacific Standard Time (PST) -0800 UTC @ Sunday, November 25, 2007

<speechles> !tz .fr australia
<sp33chy> The current time in Adelaide, South Australia, Australia is 02:55 Central Daylight Time (CDT) +1030 UTC @ lundi 26 novembre 2007
Corrected minor issue with script giving no reply. Method used to parse now allows for much greater changes in html, so minor website changes should no longer affect this script.
Enjoy WorldTime v1.3 available here.
User avatar
Exedore
Halfop
Posts: 43
Joined: Sun Jan 27, 2008 10:04 pm

Post by Exedore »

!This last upgrade works perfect!

BUT..

¿What should I do, to make the bot sends the text in spanish?

Code: Select all

<speechles> !tz san fran
<sp33chy> La hora actual en San Francisco, California, Estados Unidos es 8:24 AM Pacific Standard Time (PST) -0800 UTC @ Domingo 25 de Noviembre de 2007
Or at least partially...

This TCL is great!

Thxs
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Exedore wrote:!This last upgrade works perfect!

BUT..

¿What should I do, to make the bot sends the text in spanish?

Code: Select all

<speechles> !tz san fran
<sp33chy> La hora actual en San Francisco, California, Estados Unidos es 8:24 AM Pacific Standard Time (PST) -0800 UTC @ Domingo 25 de Noviembre de 2007
Or at least partially...

This TCL is great!

Thxs
The partially part I can do for you, in fact, you already have the ability to do so.
<speechles> !tz .es san francisco
<sp33chy> The current time in San Francisco, California, United States is 22:04 Pacific Daylight Time (PDT) -0700 UTC @ miércoles, 16 de abril de 2008
<speechles> !tz .fr new york
<sp33chy> The current time in New York, New York, United States is 01:08 Eastern Daylight Time (EDT) -0400 UTC @ jeudi 17 avril 2008
<speechles> !tz .it london
<sp33chy> The current time in London, United Kingdom is 6.08 DST +0100 UTC @ giovedì 17 aprile 2008
Unfortunately, you can see the parts which remain in english (this is a limitation of the website, not the script). But, you can use this for any regional dialect and it will work similar to how it does in the unoffficial google script.
User avatar
Exedore
Halfop
Posts: 43
Joined: Sun Jan 27, 2008 10:04 pm

Post by Exedore »

I understand...

anyway.. is a minor detail.

I switch this:

Code: Select all

set lang "en"
For this:

Code: Select all

set lang "es"
I don't know if is ok

'ES' of Español

Or should be 'SP'?
for Spanish?..
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Exedore wrote:I understand...

anyway.. is a minor detail.

I switch this:

Code: Select all

set lang "en"
For this:

Code: Select all

set lang "es"
I don't know if is ok

'ES' of Español

Or should be 'SP'?
for Spanish?..
Sure you can change that for the default behavior to be 'ES'.
Then if someone uses just !tz <somewhere> it will give spanish flavored results instead of english. But they can also at anytime, !tz .fr <somewhere> and get french results, even tho you have set that to 'ES'. Do you understand?
The script has a dual behavior. It will let you dynamically select your language when you trigger it (behavior 2). Or, If they choose not to give a language when they trigger it, they will instead be given the default (set lang "XX") language (behavior 1). This follows exactly how the unofficial google script works when dealing with languages, it has dual behavior as well.

And for any curious, this agent line is how languages are handled before loading the html.

Code: Select all

puts $tzsock "Accept-Language: ${lang}-${lang},${lang};q=0.9,${lang};q=0.8,${lang};q=0.7,*;q=0.6"
Post Reply