mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2007
Posts: 280
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2007
Posts: 280
Hi,

it is possible to read lines (and show/msg them) from an internet file? (.txt or .php). And replace (for this example) test between [ and ] with (<text between>) ?

Example:
File: http://www.bihappy.eu/b.php

<MyName> !twitter
<BotName> [23-12-2009/10:26:08] wesdegroot: Up To Go To June AWAY!
(showing first line)

<MyName> !twitter 3
<BotName> [23-12-2009/10:26:08] wesdegroot: Up To Go To June AWAY!
<BotName> [23-12-2009/08:25:43] wesdegroot: Programmeer Tijd laugh
<BotName> [23-12-2009/08:16:58] wesdegroot: Oeh Wakeuptime www.BiHappy.eu Is Sleeping I See shocked
showing first 3 lines, or when request 2, first 2 lines, but not more than 6

<MyName> !twitter all
<BotName> [23-12-2009/10:26:08] wesdegroot: Up To Go To June AWAY!
<BotName> [23-12-2009/08:25:43] wesdegroot: Programmeer Tijd laugh
<BotName> [23-12-2009/08:16:58] wesdegroot: Oeh Wakeuptime www.BiHappy.eu Is Sleeping I See shocked
<BotName> [22-12-2009/22:41:27] wesdegroot: make love, not war www.bihappy.eu
<BotName> [22-12-2009/17:30:14] wesdegroot: Klote Internet valt weg
<BotName> [22-12-2009/16:24:22] wesdegroot: Happy #Xmas And A Happy #NewYear!
(showing all results on b.php)

The things he msg'd (in example) are lines from the file (http://www.bihappy.eu/b.php)

Could someone help me?:)


Squee whenever a squee squee's. Squee whenever a squee does not squee.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Untested as I'm at work and can't run mIRC to test anything. Replace both occurences of #yourchan with your channel name. Note that I haven't worked much with binary variables and there may be a better method than what I did using them... or what I did may not even work. But this should get you started even if it isn't perfect.

Also note that this assumes you will always have 6 lines available to display from that page. It has no "protection" for having fewer lines.

Code:
on *:text:!twitter*:#yourchan: {
  set %twitter.value $iif(!$1,1,$iif($1 == all,6,$1))
  if (%twitter.value !isnum 1-6) { msg $chan Error: Use !twitter, !twitter # (# can be a number 1 to 6), or !twitter all | halt }
  sockopen Twitter www.bihappy.eu 80
}

on *:sockopen:twitter: {
  sockwrite -n $sockname GET /b.php HTTP/1.0
  sockwrite -n $sockname Host: www.bihappy.eu
  sockwrite -n $sockname $crlf
}

on *:sockread:twitter: { 
  sockread &twitter
  if ($bfind(&twitter,1,<a href=)) {
    var %cnt = 1, %start = 1, %end = $bfind(&twitter,1,<br>)
    while (%cnt <= %twitter.value) {
      msg #yourchan $htmlfree($bvar(&twitter,%start,%end))
      inc %cnt
      var %start = $calc(%end + 4), %end = $bfind(&twitter,%cnt,<br>)
    }
  }
}

alias -l htmlfree {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $replace(%x, ,$chr(32))
  return %x
}


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2007
Posts: 280
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2007
Posts: 280
Well, I've tried it. Just seems to msg everytime the errorline.
Tried to edit it, but that didn't work out

Last edited by DuXxXieJ; 02/01/10 07:40 PM.

Squee whenever a squee squee's. Squee whenever a squee does not squee.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Again, not able to test... I need to remember to check this forum while I'm not at work. smile

Try this for the first part of the script and see if it works.

Code:
on *:text:!twitter*:#yourchan: {
  set %twitter.value $1
  if (%twitter.value == $null) { set %twitter.value 1 }
  elseif (%twitter.value == all) { set %twitter.value 6 }
  if (%twitter.value !isnum 1-6) { msg $chan Error: Use !twitter, !twitter # (# can be a number 1 to 6), or !twitter all | halt }
  sockopen Twitter www.bihappy.eu 80
}


Should have worked with the $iif's, but maybe I had something wrong there. If this still won't work, try removing the 2 IF and 1 ELSEIF lines in this. That will at least get you past the error checking to make sure the rest is working for you and then we can figure out the rest.

If you want to test the original, change SET in the first part of the original script to SET -s (insert -s in there). That will display what's being set there, blank should become 1, all should become 6, and 1-6 should remain as-is. That will give you an idea where the problem is and I'll try to remember to check that tonight as well.


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2007
Posts: 280
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2007
Posts: 280
Well, still won't work. Even when I remove the IF and ELSEIF lines. It's also trying to set the value to the first word. But shouldn't that be the second one? (the 'all, <number' part?).



Squee whenever a squee squee's. Squee whenever a squee does not squee.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Sorry about that... here you are (tested):

Code:
on *:text:!twitter*:#botstorage: {
  set %twitter.value $2
  if (%twitter.value == $null) { set %twitter.value 1 }
  elseif (%twitter.value == all) { set %twitter.value 6 }
  if (%twitter.value !isnum 1-6) { msg $chan Error: Use !twitter, !twitter # (# can be a number 1 to 6), or !twitter all | halt }
  sockopen Twitter www.bihappy.eu 80
}

on *:sockopen:twitter: {
  sockwrite -n $sockname GET /b.php HTTP/1.0
  sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)
  sockwrite -n $sockname Host: www.bihappy.eu
  sockwrite -n $sockname Accept-Language: en-us
  sockwrite -n $sockname Accept: */* $+ $crlf $+ $crlf
}

on *:sockread:twitter: { 
  sockread -fn &twitter
  if ($bfind(&twitter,1,<a href=)) {
    var %cnt = 1, %start = 1, %end = $bfind(&twitter,1,<br>)
    while (%cnt <= %twitter.value) {
      msg #botstorage $htmlfree($bvar(&twitter,%start,$calc(%end - %start)).text)
      inc %cnt
      var %start = $calc(%end + 4), %end = $bfind(&twitter,%start,<br>)
    }
  }
}

alias -l htmlfree {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  return %x
}



Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard