By FordLawnmower on Mar 18, 2009

!Time script. Gets the time from Wunderground.com.
Syntax is !time city state | !time city country | !time airportcode | !time zipcode.
Or: @time city state | @time city country | @time airportcode | @time zipcode.

The !trigger will notice the user and the @trigger will message the channel if the user has halfops or higher.

It also has an alias /time that uses the same syntax but only echo's to the active screen.
There is also a menu on the channel screen to disable the trigger.

To start using just right click channel or status screen, go to !Time and click On.

Example Output:
14:05:35 !time cvg
14:05:36 -Gliiim- Searching for Time ..................
14:05:39 -Gliiim- Time for Cincinnati-Northern KY International Kentucky is 3:05 PM EST
14:06:01 !time london england
14:06:02 -Gliiim- Searching for Time ..................
14:06:04 -Gliiim- Time for London United Kingdom is 8:06 PM GMT

;!Time by Ford_Lawnmower irc.GeekShed.net #Script-Help
menu Channel,Status {
  .$iif($group(#Time) == On,$style(1)) !Time Trigger
  ..$iif($group(#Time) == On,$style(2)) On: .enable #Time
  ..$iif($group(#Time) == Off,$style(2)) Off: .disable #Time
#Time on
On $*:Text:/^(!|@)Time.*/Si:#: {
  if (!$timer($+(Time,$network,$nick))) {
    .timer $+ $+(Time,$network,$nick) 1 6 noop
    var %method $iif($regml(1) == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/),.msg $chan,.notice $nick))
    TimeCheck %method $2-
#Time end
alias Time { TimeCheck echo -a $1- }
alias -l TimeCheck {
  $1-2 04Searching for Time ..................
  var %sockname $+(Time,$network,$2,$ticks)
  sockopen %sockname www.wunderground.com 80
  sockmark %sockname $1-2 $+(/cgi-bin/findweather/getForecast?query=,$fixurl($3-),&wuSelect=WEATHER) $replace($rfixurl($($fixurl($3-),1)),$chr(32),+)
On *:sockopen:Time*: {
  if (!$sockerr) {
    sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
    sockwrite -n $sockname Host: www.wunderground.com
    sockwrite -n $sockname $crlf
  else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
On *:sockread:Time*: {
  if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  else {
    var %Time | sockread %Time
    if (There has been an error isin %Time) { $gettok($sock($sockname).mark,1-2,32) Time Not Found | sockclose $sockname }
    elseif ($regex(%Time,/Weather Forecast for (?:.*)">(.*?)</i)) { sockmark $sockname $addtok($sock($sockname).mark,$+($remove($regml(1),$chr(32)),$chr(7)),32) }
    elseif ($regex(%Time,/Left5">(.*?)<\/h1>/gi)) { sockmark $sockname $addtok($sock($sockname).mark,$+($regml(1),$chr(7)),32) }    
    elseif ($regex(%Time,<div id="infoTime"><span>(.*:.*)<\/span>)) {
      $gettok($sock($sockname).mark,1-2,32) 04Time for $remove($gettok($sock($sockname).mark,5-,32),$chr(7)) 04is $regml(1)
      sockclose $sockname
On *:sockclose:Time*: { 
  tokenize 7 $gettok($sock($sockname).mark,4-,32)
  $gettok($sock($sockname).mark,1-2,32) 04Time Not Found. Suggestions for $+($replace($1,+,$chr(32)), :) $replace($2-,$chr(32),|-|)
alias -l fixurl { return $regsubex($1-,/([^a-z0-9])/iSg,% $+ $base($asc(\t),10,16,2)) }
alias -l rfixurl { return $regsubex($1-,/\%([a-f0-9]{1,2})/ig,$chr($base(\t,16,10))) }


Sign in to comment.
cptpan   -  Feb 25, 2015

This doesn't quite work. Can anyone fix it? Ford, update it? Anyone know an alternative?

skrillex123   -  Jul 30, 2014

Sr. Ford can you Update your Script, i try to fix it but it's not working :s

jasonh   -  Jul 01, 2014

Hello, this no longer works. wunderground changed their website

Stewie1k94   -  Mar 05, 2012

Works perfect, thank's

Stewie1k94   -  Mar 05, 2012

OK' thank's. I'll try it when I get home in a few hour's.

FordLawnmower   -  Mar 03, 2012

I just noticed issues on this post.
I've tested it over and over with no issues, so I've updated the post to my current test code.
I'm pretty sure they are the same but if you are having problems please try the code at the top of the page.
If you have an issue please post an example as toclafane1 did.

I was able to test that city with no issues.

19:24:48 <Ford_Lawnmower> @time Skopje
19:24:48 -Lurkerzs- Searching for Time ..................
19:24:49 -Lurkerzs- Time for Skopje Macedonia is 1:24 AM CET on March 04 2012

RoflCopter   -  Mar 02, 2012
* /sockwrite: 'GET' no such socket (line 13, remote.ini)
ON Unknown command 

Needs an update :)

b0sse   -  Feb 28, 2012

Yup, needs updating since it doesn't work anymore.
Just gives me:

Searching for Time ...
Time for is Main Site
Stewie1k94   -  Feb 20, 2012

Script needs updating I think...

[4:43pm] <~toclafane[sleep]> @Time Skopje
[4:43pm] <~thunderbolt> Searching for Time ..................
[4:43pm] <~thunderbolt> Time for is 5:43 PM CET on February 20, 2012
[4:44pm] <~toclafane[sleep]> -.-

jasonh   -  Oct 23, 2011

thanks for continuing to update your old scripts

Stewie1k94   -  Oct 10, 2011

thanks ford!

FordLawnmower   -  Oct 09, 2011

This was broken by site changes.

^WeSt   -  Oct 09, 2011

The same problem as toclafane1 the results are incorrect

Stewie1k94   -  Oct 07, 2011

[5:54pm] <~toclafane> @time Skopje
[5:54pm] <&thunderbolt> Searching for Time ..................
[5:54pm] <&thunderbolt> Time for is 6:54 PM CEST on October 07, 2011
[5:54pm] <~toclafane> :O
[5:54pm] <~toclafane> @time London
[5:54pm] <&thunderbolt> Searching for Time ..................
[5:54pm] <&thunderbolt> Time Not Found. Suggestions for London:
[5:54pm] <~toclafane> wtf? any ideas, wont seem to work correctly, like not showing suggestions or the place it searched time for

FordLawnmower   -  Mar 18, 2011

np jasonh :) Glad you finally updated.

jasonh   -  Mar 18, 2011

thanks for the update. i updated my mirc version. i guess i'm good for another 5 years :D

SoulMuncher   -  Mar 12, 2011


Jordyk19   -  Mar 12, 2011

I like it.

toclafane   -  Mar 12, 2011

yeh true that is a good point

FordLawnmower   -  Mar 12, 2011

@toclafane Yea, I have it working fine also but as jasonh said, he is using mIRC 6.2 .
6.2 is 5 years old and doesn't have the same command set as newer versions of mIRC.

toclafane   -  Mar 12, 2011

this script works for me

FordLawnmower   -  Mar 12, 2011

@jasonh This is an edited version of my old time script -->> http://pastebin.com/URKG9U8C
Keep in mind that it relies on classic.wunderground.com and I don't know how long they will keep the old pages running.

The version at the top of this post uses wundergrounds new pages.

toclafane   -  Mar 12, 2011

jasonh try @time london united kingdom
it needs to know what u want to show the time as needs to be typed with a @ or u could use !

jasonh   -  Mar 12, 2011

yeah it's not working for me. just tried it with the code from here again.
doesnt output any error either.
maybe i should update my mirc version for my bot

toclafane   -  Mar 11, 2011

i rate this 10/10 good job

Jethro   -  Mar 06, 2011

I wonder what would happen if Ford retired from MSL....

FordLawnmower   -  Mar 05, 2011

This code was recently updated jasonh. Are you using the current code ?

jasonh   -  Mar 05, 2011

used to work before the site changed though

jasonh   -  Mar 05, 2011

using mirc 6.2 for my bot.

not working for me

FordLawnmower   -  Feb 26, 2011

@Henco I posted an update for this a couple of weeks ago. Should be working now.

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.