Apologies, I was distracted. It did work. lol
Well, you really didn't need regex nor the alias. Here is my take on yours:
on $*:text:/^!joke$/iS:*:{
if (!$($+(%,fp,.,$site,.,#,.,$network),2)) {
inc -u3 $+(%,fp,.,$site,.,#,.,$network)
var %j = joke. $+ $r(1,9999)
sockopen %j www.randomfunnyjokes.com 80
sockmark %j .msg $iif(#,#,$nick)
halt
}
.notice $nick please wait at least 3 seconds before using $1 again!
.ignore -cpu3 $nick 2
}
on *:sockopen:joke.*:{
if ($sockerr) { $sock($sockname).mark Connection Error's Occurred! | halt }
sockwrite -nt $sockname GET / HTTP/1.1
sockwrite -nt $sockname Connection: close
sockwrite -nt $sockname Host: $+($sock($sockname).addr,$str($crlf,2))
}
on *:sockread:joke.*:{
if ($sockerr) { $sock($sockname).mark Connection Error's Occurred! | halt }
var %joke | sockread %joke
if (<br><br> isin %joke) { $sock($sockname).mark $remove(%joke,$v1) }
}
I've taken the liberty of adding the trigger flood control and sockerr checks, making the script more secure if someone malicious wants to tamper with you, or the socket runs into errors.
You should learn about the use of sockmark so you don't have to rely on the global variable and then get it unset.
I've made it capable of listening to both channel and pm.