!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
return
}
}
}
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))) }
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
[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
@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.