Hey guys ,I've been using a script made by Gecko321 from hawkee's that calls info from a website and displays it into your active window on
irc but I'd like to add a few things to it and haven't really a clue where to start.

Click to reveal..


http://www.hawkee.com/snippet/9429/

Code:
alias -l DoTime {
  if (!$1) { tokenize 32 $Ctime }
  else { Return $AscTime($1,hh:nn:ss tt) }
}

alias -l striphtml {
  IF ($1) {
    VAR %strip,%opt = <> $remove($1-,> <,><,$chr(9)) <>,%n = 2
    WHILE ($gettok($gettok(%opt,%n,62),1,60)) {
      %strip = %strip $ifmatch
      INC %n
    }
    RETURN %strip
  }
}

alias pre {
  if ($1) { %chan = $1 }
  if ($sock(pre)) { sockclose pre }
  sockopen pre www.orlydb.com 80
}

on *:sockopen:pre: {
  %PreOld = %PreNew
  if ($sockerr > 0) return
  sockwrite -n $sockname GET / HTTP/1.0
  sockwrite -n $sockname Host: www.orlydb.com $+ $crlf
  sockwrite -n $sockname $crlf
  %temp = 0
}

on *:sockread:pre:{
  if ($sockerr) { return }
  var %tvdata
  sockread %tvdata
  if ($striphtml(%tvdata) != $null) {

    if (%Temp < 4) {
      if ("info" isin %tvdata) { %file = $striphtml($mid(%tvdata,$calc($pos(%tvdata,>,2) + 1),$pos(%tvdata,</,1))) }
      if (%time && %section && %release && %temp = 3) {
        %PreNew = %time %section %release %file
        %temp = 5
      }
      if ("timestamp" isin %tvdata) { %time = $striphtml($mid(%tvdata,$calc($pos(%tvdata,>,1) + 1),$pos(%tvdata,</,1))) | inc %temp }
      if ("section" isin %tvdata) { %section = $striphtml($mid(%tvdata,$calc($pos(%tvdata,>,2) + 1),$pos(%tvdata,</,1))) | inc %temp }
      if ("release" isin %tvdata) { %release = $striphtml($mid(%tvdata,$calc($pos(%tvdata,>,1) + 1),$pos(%tvdata,</,1))) | inc %temp }
    }

    if (<a href="/toggleheader"> isin %tvdata) { 
      %Temp = 0 
      tokenize 32 %tvdata 
      %ServerTime = $2-3
      var %a = $calc(($Ctime(%ServerTime) - $Ctime) / 3600)
      var %b = $Round(%a,0)
      %TimeDif = $calc(%b * 3600)
      tokenize 32 %PreNew
      if (%PreNew != %PreOld) {
        $iif(%chan,msg %chan,echo -a) (PRE) ( $+ $3 $+ ) $mid($4,1,$Calc($pos($4,-,$pos($4,-,0))-1)) $iif($5,( $+ $5 $+ )) $replace($7,f,$chr(32) $+ File $+ $iif($remove($7,f) > 1,s)) ( $+ $mid($4,$calc($pos($4,-,$pos($4,-,0)) +1 )) $+ )
      }
      sockclose pre
      unset %time %section %release %file %ServerTime %temp2 %temp %chan
    }
  }
}


Ok tried to add an ON JOIN with timer to the script but for what ever reason it never showed the results after that so I took it out.

Code:
 
ON *:JOIN:#: {
 if ($Network == SOME_NETWORK) && (# == #SOME_CHAN) {
 timer1 0 5 /pre
 }
}


Basically this is what I' after as an end result:

1. Command to turn the script on/off (something like !pre off | !pre on)
2. I'd like it to msg to chan instead of echoing to -a.
3. I like to add a timer so that I don't have to type it into the chan to start the script each time I connect.
4. Check to see if I'm connected to the network before starting the timer.
5. If I'm disconnected from the network, halt the timer until I re connect and am back in the chan
6. The site has a search box so I would like to have added a search function within the chan (something like !search BlahBlah) and display say last 5 results.
7. Add in a little color for (PRE) and the categories.

Hope that all makes sense and isnt asking too much. You guys have helped me in the passed so hoping you can come through once again, TIA

D00M

Last edited by D00M; 19/09/13 02:29 PM.