;--Start topic update timer(s) when you join your set channel(s)..
on me:*:join:#mychannelname: {
;-- First time waits 5 seconds to run,
;-- so you have a chance to get channel ops..
.timerupdtopicjoin 1 5 updatetopic $chan
;-- Second timer runs every 1800 seconds (30 mins)
.timeruptopinter 0 1800 updatetopic $chan
}
;-- Alias to set the data to hash tables for easy retrieval..
alias updatetopic {
if ($me !isop $$1) { echo $color(info2) -at * Topic Update Error: You are not an op on $1 , halting topic update check. }
else {
var %s = $+(topicup.,$$1)
if ($sock(%s)) { sockclose %s }
;- set the site name:
hadd -m %s host mysite.com
;- Set the page you want to GET, using the
;- preceding forward slash '/' as shown below.
hadd -m %s get /news.php
hadd -m %s read $false
sockopen %s $hget(%s,host) 80
}
}
;-- Open the socket to get the data...
on *:sockopen:topicup.*: {
if ($sockerr) { echo $color(info2) -at * Socket Open ERROR: $sock($sockname).wsmsg | return }
sockwrite -nt $sockname GET $hget($sockname,get) HTTP/1.1
sockwrite -nt $sockname Host: $hget($sockname,host)
sockwrite -nt $sockname Accept-Language: en-us
sockwrite -nt $sockname User-Agent: Mozilla/??
sockwrite -nt $sockname $+(Connection: close,$str($crlf,2))
}
;-- Read the socket data..
on *:sockread:topicup.*: {
var %t, %s = $sockname, %c = $gettok(%s,2,46)
sockread %t
if ($sockerr) { echo $color(info2) -at * Socket Read ERROR: $sock(%s).wsmsg | return }
if (%t == $null) { hadd -m %s read $true }
if (($hget(%s,read)) && (%t != $null)) {
if ($chan(%c).topic != %t) { topic %c %t }
}
}