mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 2 1 2
#129198 04/09/05 11:44 AM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Change echo to msg, changed the if tests to ignore empty lines instead of sending a - sign.
Do enable floodprotection, because 2 requests will get you killed from the server.

Code:
  while (($sockbr) && (!$sockerr)) {
    if (%bot == $null) sockmark $sockname 1
    elseif ($sock($sockname).mark) [color:blue]msg[/color] %untarget %bot
    sockread %bot
  }

#129199 04/09/05 12:10 PM
Joined: Aug 2005
Posts: 32
R
r_alien Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Aug 2005
Posts: 32
Here is my current code:

Code:
on *:text:!sabdetails*:*: {
 set %un $2
 set %untarget $target
 sockopen bot 192.168.1.2 6080
} 

alias bot sockopen bot 192.168.1.2 6080
on *:sockopen:bot: { 
  sockwrite -n bot GET /s3h/getdetails.php?name= $+ %un HTTP/1.1
  sockwrite -n bot Host: 192.168.1.2
  sockwrite -n bot User-Agent: Omg dont block this T_T I love you!!!! :P
  sockwrite -n bot $str($crlf,2)
} 
on 1:sockread:bot: {
  if ($sockerr > 0) return
  sockread %bot
  while (($sockbr) && (!$sockerr)) {
    if ($sock($sockname).mark) msg %untarget $iif(%bot != $null,%bot,-)
    elseif (%bot == $null) sockmark $sockname 1
    sockread %bot
  }
}


I sometimes get these as well:

Quote:
* /sockopen: 'bot' socket in use (line 4, sabreport.mrc)


Is that because i need flood protection? Or is it because i need to close the socket? And how do it? :S

#129200 04/09/05 12:20 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Replace line 4 with..

Code:
if (!$sock(bot)) sockopen bot 192.168.1.2 6080


-Andy

#129201 04/09/05 12:46 PM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
You can only do one request at a time with this script. You do not need to close the socket normally, it should happen automatically once the entire page is transmitted.

Add this as second line so that you can see (echo -> only you see it) when a request is done when a previous was still underway. The floodprotection is needed because of the amount of data, you can normally send about once message each second (or 2) without being flooded off, if you type more/faster, the server might kick you for flooding. This can happen because of one long page, or many shorter pages, or a short page + very active chatting, or ...

if ($sock(bot)) { echo $target Request denied, previous entry not finished yet. | return }

#129202 04/09/05 12:58 PM
Joined: Aug 2005
Posts: 32
R
r_alien Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Aug 2005
Posts: 32
Thanks for that, that is solved, but when someone puts in a nonexistant user, the PHP file gives this:

Quote:
--- Sorry, no details for Nonexistantuser ---


But the IRC Script isn't sending that? How would i get it to send those? :P

#129203 04/09/05 01:58 PM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
If you can edit the PHP script: send a line break after that line.

Now I'm wondering, do you get ALL output when the user exists? Or is the last line missing too?
If that's the case, it's because /sockread %bot only reads a line if it ends in $crlf. If there's no line break, nothing is read... Use /sockread -f %bot to force the read, even if it doesn't end in a line break. This might give partial lines sometimes (a line split over 2 lines), but everything should be displayed...

#129204 04/09/05 09:53 PM
Joined: Aug 2005
Posts: 32
R
r_alien Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Aug 2005
Posts: 32
Thanks for that Kelder! :P Yes the last line wasn't coming through on the existant user search, but i just added a line break after it. Same with the non existant user, because that's easier, and quicker, and results in no down time! :P

Thanls for all your help everyone.

Page 2 of 2 1 2

Link Copied to Clipboard