Put it into a NEW remotes file either on your script or a bots if on a bots the command is @nfact if on your personal script is /nfact will randomly post a chuck norris joke/fact
on *:text:*:#: {
tokenize 32 $strip($1-)
if ($1 == @nfact) {
.var %nfactchan $chan
sockopen nfact www.chucknorrisjokes.linkpress.info 80
}
}
alias nfact {
var %nfactchan $chan
sockopen nfact www.chucknorrisjokes.linkpress.info 80
}
on *:sockopen:nfact: {
sockwrite -n $sockname GET /random-fact.php HTTP/1.1
sockwrite -n $sockname Host: $+($sock(nfact).addr,$str($crlf,2))
}
on *:sockread:nfact: {
var %nfact | sockread %nfact
if ($regex(%nfact,/<p style="font-size: 2.5em;">(.+)(Norris.+)<\/p>/)) {
msg %nfactchan $regml(1) $regml(2)
sockclose nfact
}
}
Yes, that's a smart, witty sock error reply, isn't it? :P I think I made a socket alternative to someone's random thought socket script, and I had it made, "I'm currently thoughtless; please try me again in 4 seconds" if no thoughts are found. lol And that corresponds to the trigger flood control time limit, too.
If you make a socket script to gather info from a website and have it jotted down in a text file, doesn't that defeat the purpose of using socket in the first place? ;\
I understand the odds of a website being down, but that's not really a frequent matter...what matters is the website source code being altered, which could happen every once in a while.
lol @ you using the trigger @nfact
anyways you are getting better at sockets.. ;x
you may want to add in ur description to add this to it's own remote an leave it by it's self, cuz of the way you have ur trigger ie:
on *:text:*:#: {
it will make what ever is in there not work
one more thing if you have my random nick fact socket on a bot that has this in it, it will conflict with it.
Thats cuz the trigger and socket name for that is also called nfact
you should add a bit of flood protect to it as well use sockmark
here is an example:
on $*:text:/^@nfact$/iS:#:nfact
alias nfact {
if (!%f) { inc -u4 %f
sockopen nfact www.chucknorrisjokes.linkpress.info 80
sockmark nfact msg # 12,1
}
}
on *:sockopen:nfact: {
sockwrite -n nfact GET /random-fact.php HTTP/1.1
sockwrite -n nfact Host: $+($sock(nfact).addr,$str($crlf,2))
}
on *:sockread:nfact: {
var %nfact | sockread %nfact
if ($regex(%nfact,/\t{3}<p style.+>(.+?)<\/p>/)) {
$sock(nfact).mark $regml(1)
sockclose nfact
}
}
5/10 +Like