Top

RandomFunFacts.com Socket


mIRC Code
+ 0 likes
Please Register to submit score.
Bookmark and Share
Average Score  0.0 (of 0 scores)
Date Added  Jun 15, 2009
Last Updated  Jun 15, 2009
Tags  fact  facts  fun  random  sock  sockclose  socket  sockopen 

Introduction

My second working socket script, trying to keep it simple but fun to use. Tell me how you like it!

Syntax: `fact
(Feel free to change the syntax to whatever, "`fact" is probably taken already >_>)

Grab the Code

on *:text:`fact*:#: {
if ($sock(funfact)) .sockclose funfact
set %chan $chan
sockopen funfact www.randomfunfacts.com 80
}
on *:SOCKOPEN:funfact: {
sockwrite -nt $sockname GET / HTTP/1.1
sockwrite -nt $sockname Host: www.randomfunfacts.com
sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:funfact: {
if ($sockerr) {
msg %chan Socket Error: $sockname $+ . Error code: $sockerr Please inform $me of this error message.
halt
}
else {
var %sockreader
sockread %sockreader
if (*<td bordercolor="#FFFFFF"><font face="Verdana" size="4"><strong>* iswm %sockreader-2) {
noop $regex(%sockreader,/<i>(.*?)<\/i>/Si)
set %funfact $regml(1)
msg %chan %funfact
unset %sockreader*
unset %chan
sockclose $sockname
}
if ($len($remove(%sockreader,$chr(9),$chr(32))) > 0) {
var %x = 1
while (%x > -1) {
if ($len(%sockreader [ $+ [ $iif(%x != 0,$+(-,%x)) ] ]) <= 850) set %sockreader [ $+ [ $+(-,$calc(%x + 1)) ] ] %sockreader [ $+ [ $iif(%x != 0,$+(-,%x)) ] ]
dec %x
}
}
}
}
 

Comments

  (2)  RSS
napa182
Comments: 1,455
 
mIRC Snippet:  RandomFunFacts.com Socket
Posted on Jun 15, 2009 3:56 pm
it almost looks like you are useing some messed up socket maker to make these. =/

no need for all them vars an whatnot you could have just done this

Code:
on $*:text:/^@fact$/iS:#: { if (!$($+(%,factsflood,$nick),2)) { set -u3 $+(%,factsflood,$nick) on | if ($sock(fact)) .sockclose fact | sockopen fact www.randomfunfacts.com 80 | sockmark fact # } }
on *:sockopen:fact: { sockwrite -nt $sockname GET / HTTP/1.1 | sockwrite -nt $sockname Host: $+(www.randomfunfacts.com,$str($crlf,2)) }
on *:sockread:fact: {
  var %fact | sockread %fact
  if ($regex(%fact,/<i>(.+)<\/i>/)) { msg $sock(fact).mark $regml(1) | sockclose fact }
}
zak123
Comments: 10
 
mIRC Snippet:  RandomFunFacts.com Socket
Posted on Jun 15, 2009 7:22 pm
Im not using a socket CREATOR, just a template, I dont know what I can abbreviate just yet, so once I get the hang of it I should be in the clear.

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom