All pastes #418933 Raw Edit

Unnamed

public text v1 · immutable
#418933 ·published 2007-03-31 22:56 UTC
rendered paste body
alias -l c1 return $+($chr(3),14,$1-,)
alias -l c2 return $+($chr(3),07,$1-,)
alias -l c3 return $+($chr(3),04,$1-,)
on $*:TEXT:/^[!@]cla(ns|n)/Si:#:{
  if ($2- == $null) { 
    if ($left($1,1) == @) { msg $chan 7[14Clan7]14 Please enter a name to search for. | halt }
    elseif ($left($1,1) == !) { notice $nick 7[14Clan7]14 Please enter a name to search for. | halt }
  } 
  else {
    inc %s
    set $+(%,return.,%s) $iif($left($1,1) == @, msg $chan, notice $nick)
    set $+(%,clan.,%s) $2-
    sockopen $+(clan.,%s) www.runehead.com 80
  }
}
on *:SOCKOPEN:clan.*: {
  var %s = $gettok($sockname,2,46)
  sockwrite -nt $sockname GET /clans/search.php?search= $+ %clan. [ $+ [ %s ] ] $+ &searchtype=exact HTTP/1.1
  sockwrite -nt $sockname Host: www.runehead.com
  sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:clan.*: {
  var %s = $gettok($sockname,2,46)
  if ($sockerr) {
    %return. [ $+ [ %s ] ] 7[14Clan7]14 Socket error, please notify my owner.
    halt
  }
  var %read
  sockread %read
  if ($regex(results,%read,/<p>No results were found for the <b>exact</b> search <b>(.*)</b/)) {
    %return. [ $+ [ %s ] ] 7[14Clan7] $+ $c1 The name $c2 $+ %clan. [ $+ [ %s ] ] $c1 $+ could not be found in any clan on $c2 $+ www.runehead.com/clans
    unset $+(%,clan.*)
    unset $+(%,return.,*)
    sockclose $+(clan.,%s)
  }
  if ($regex(results,%read,/<p>The <b>exact<\/b> search <b>(.*)<\/b> returned <b>(\d+)/)) {
    if ($regml(results,2) >= 3) {
      %return. [ $+ [ %s ] ] 7[14Clan7]14 $c1 $+ There were $c2 $+ $regml(results,2) $c1 $+ result(s) found for: $c2 $+  %clan. [ $+ [ %s ] ] $+ . 14Showing the first three results.
    }
    else {
    %return. [ $+ [ %s ] ] 7[14Clan7]14 $c1 $+ There were $c2 $+ $regml(results,2) $c1 $+ result(s) found for: $c2 $+  %clan. [ $+ [ %s ] ]   }
  }
  if ($regex(clan,%read,/<td style='width:90px; border-color:#404040;'><a href='(.*)'>(.*)</a></td>/)) { 
    inc $+(%,clan.count.,%d)
    if ($($+(%,clan.count.,%d),2) >= 4) {
      halt
      unset $+(%,clan.*)
      unset $+(%,return.,*)
      sockclose $+(clan.,%s)
    }
    else {
    %return. [ $+ [ %s ] ] 7[14Clan7]14 $c2 $+ %clan. [ $+ [ %s ] ] $+ $c1 is currently in the clan: $c2 $+ $regml(clan,2) $+ ! }
  }
  if (</html> isin %read) {
    unset $+(%,clan.*)
    unset $+(%,return.,*)
    sockclose $+(clan.,%s)
  }
}