weather bot

Platform:  mIRC
Published  Jul 19, 2005
Updated  Sep 04, 2008
this weather bot is 100% good:) alias htmlfree { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $replace($remove(%x,&nbsp;,$chr(9)),gt;,>,$chr(35) $+ 39;,') | return %x }
on *:text:!weather*:#:{
if ($1 == !weather) {
if (!%weather) {
if ($2) {
if ($sock(weather)) { .sockclose weather }
set -u15 %weather $chan $replace($2-,$chr(32),+)
.sockopen weather weather.cnn.com 80
}
else { .msg $chan [Weather] Syntax: !Weather <city> }
.ignore -u2 $nick
}
}
}

ctcp *:version:*:{ .ctcpreply $nick $1 $decode(U2NyaXB0ZWQgYnkgI1d1bG9uZyBAIFF1YWtlbmV0IC0gaHR0cDovL3d1bG9uZy5hZnJhaWQub3Jn,m) | .ignore -tu7 $nick }
on *:sockopen:weather:{
if ($sockerr > 0) { .msg $gettok(%weather,1,32) [Weather] http://weather.cnn.com is down at the moment, cannot continue your search }

else {
sockwrite -n $sockname GET /weather/search?wsearch= $+ $replace($gettok(%weather,2,32),æ,$chr(37) $+ E6,ø,$chr(37) $+ F8,å,$chr(37) $+ C5) HTTP/1.1
sockwrite -n $sockname Host: http://weather.cnn.com
sockwrite -n $sockname user-agent: Mozilla/??
sockwrite -n $sockname Connection: Keep-Alive
sockwrite -n $sockname $crlf
}
}

on *:sockread:weather:{
if ($sockerr > 0) { return }
:nextread
sockread %weatherInfo
if ($sockbr == 0) { return }
if (%weatherInfo == $null) { %weatherInfo = - }
if (&#149;&nbsp;<a isin %weatherInfo) && (href="http://weather.cnn.com/weather isin %weatherInfo) && (</a> isin %weatherInfo) && ($replace($gettok(%weather,2,32),æ,$chr(37) $+ E6,ø,&oslash;,å,$chr(37) $+ C5) iswm $right($gettok($htmlfree(%weatherInfo),1,44),-6)) && (!%weather.page) { weather.page $wildtok(%weatherInfo,*http://*,1,34) | set -u2 %weather.results 1 }
if (Location: http://weather.cnn.com/weather/fore* iswm %weatherInfo) && ($wildtok(%weatherInfo,*http://*,1,32)) { weather.page $wildtok(%weatherInfo,*http://*,1,32) | set -u2 %weather.results 1 }
if (*class="cnnWeathSearch">No search results found for* iswm %weatherInfo) { .msg $gettok(%weather,1,32) [Weather] No Results were found. | set -u2 %weather.results 1 }
if (<td><div class="cnnSectExtSites">All external sites will open in a new browser.<BR>CNN.com does not endorse external sites.</div></td></tr></table>* iswm %weatherInfo) && (!%weather.results) { .msg $gettok(%weather,1,32) [Weather] No Results were found. }
goto nextread
}
alias weather.page {
if ($sock(weather.page)) { .sockclose weather.page }
set -u7 %weather.page / $+ $gettok($1-,3-,47)
.sockopen weather.page weather.cnn.com 80
}

on *:sockopen:weather.page:{
sockwrite -n $sockname GET %weather.page HTTP/1.1
sockwrite -n $sockname Host: http://weather.cnn.com
sockwrite -n $sockname user-agent: Mozilla/??
sockwrite -n $sockname Connection: Keep-Alive
sockwrite -n $sockname $crlf
}

on *:sockread:weather.page:{
if ($sockerr > 0) { return }
:nextread
sockread %weather.pageinfo
if ($sockbr == 0) { return }
if (%weather.pageinfo == $null) { %weather.pageinfo = - }
if (*<title>CNN.com - Weather- *</title>* iswm %weather.pageinfo) { set %weather.name $gettok($htmlfree(%weather.pageinfo),3-,45) }
if (font-family:arial;font-size:30px;font-weight:bold; isin %weather.pageinfo) { set %weather.conditions $replace($htmlfree(%weather.pageinfo),&deg;,°) }
if (font-family:arial;font-size:12px;font-weight:bold; isin %weather.pageinfo) { set %weather.conditions %weather.conditions $replace($htmlfree(%weather.pageinfo),&deg;,°) }
if (*<td colspan="2"><div class="cnnBodyText" style="font-size:22px;padding-top:3px;padding-bottom:3px;" align="center"><b>*</b></div></td>* iswm %weather.pageinfo) { set %weather.conditions %weather.conditions - $htmlfree(%weather.pageinfo) }
if (Wind: <b>* at * mph (* km/h)</b><BR> iswm %weather.pageinfo) { set %weather.var 1 }
if (%weather.var) {
set %weather.conditions %weather.conditions - $+ $remove(%weather.pageinfo,wind:,sunrise:,sunset:,<b>,</b>,<BR>)
}
if (Sunset: <b>*</b><BR> iswm %weather.pageinfo) {
unset %weather.var
if (%weather) { .msg $gettok(%weather,1,32) [Weather] $+ $replace($gettok(%weather.name,1,44),&oslash;,ø) $+ 's sky is currently $left($gettok(%weather.conditions,2,45),-1) $+ . The temperature is $left($gettok(%weather.conditions,1,45),-1) $+ . Wind at $gettok($gettok(%weather.conditions,3,45),3-,32) $+ . Sunrise was at $gettok(%weather.conditions,4,45) and Sunset at $gettok(%weather.conditions,5,45) $+ . | unset %weather.* }
}
goto nextread
}
}

Comments

Sign in to comment.
Pam G.   -  Jan 18, 2012
Is there a way to make a java bot verison of the weather bot?
 Respond  
darkarrow   -  Jan 22, 2009
kk ty
 Respond  
Scakk   -  Jan 21, 2009
darkarrow: He was last seen in 2005. I doubt he will be back to fix it. If you want a working one you can use mine located http://www.hawkee.com/snippet/3661/
 Respond  
darkarrow   -  Jan 21, 2009
doesn't work
 Respond  
M[n]M   -  Sep 29, 2007
dude its not workin!! what should i do ? i don\'t even know how to fix that crap..

Quote


lol
 Respond  
joshieprince   -  Sep 16, 2007
useless. no workie
 Respond  
M[n]M   -  Sep 13, 2007
+03:04+ <M[n]M> !weather newyork brooklyn


Nothing is happening ..
 Respond  
DeathRyder082   -  Aug 03, 2005
well, just make sure they work before posting. cause this doesn\'t work
 Respond  
henrikthesexy   -  Jul 23, 2005
i make my own and i find manny and work more on it.... osv......
 Respond  
DeathRyder082   -  Jul 20, 2005
i dont think he is making his snippets. ripper :/
 Respond  
Noutrious   -  Jul 20, 2005
Doesnt seem to work.. Sry, but sucks :|
 Respond  
UK-Sw1ft   -  Jul 20, 2005
dosnt work for me, dunno y, but fix it :>
 Respond  
xDaeMoN   -  Jul 19, 2005
Maybe he is Wulong because most of his snippets have it.
 Respond  
Pariah   -  Jul 19, 2005
doesn\'t seem smart to leave the version reply in if you\'re trying to pass it off as your own.
 Respond  
bearruler   -  Jul 19, 2005
Why does it say Scripted by Wulong?
Is the $decode to cover up the fact you didnt make the script?


Bear
 Respond  
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.