All pastes #462223 Raw Edit

Anonymous

public text v1 · immutable
#462223 ·published 2007-04-28 03:48 UTC
rendered paste body
#ClanLookup off
on *:text:!clan *:#:{
  /BotFloodProtection $nick
  /set %csearch.chan $chan
  /set %csearch.nick $2-
  /set %csearch.targnick $nick
  /set %csearch.display $iif(($left($1,1) == $chr(42)) && (%publiccommands == on),.msg $chan,.notice $nick)
  if ($sock(clansearch)) { /sockclose search }
  /sockopen clansearch runehead.com 80
}
#ClanLookup end

on *:sockopen:clansearch:{
  sockwrite -nt $sockname GET /clans/search.php?search= $+ $replace(%csearch.nick,$chr(32),$chr(43)) $+ &searchtype=exact HTTP/1.1
  sockwrite -nt $sockname Host: runehead.com
  sockwrite -nt $sockname $crlf $crlf 
}

on *:sockread:clansearch:{
  /var %cstatus  
  sockread %cstatus
  if ($SockErr) { /msg %csearch.chan Sorry an error occured. | /closeclansocket $sockname csearch }
  else {
    if ( *'ml.php?clan=*'>*</a></td> iswm %cstatus ) { .notice %csearch.targnick %csearch.nick is in $htmlfree(%cstatus) }
    if (</html> iswm %cstatus ) { /closeclansocket $sockname csearch }
    if (*No results were found for the* iswm %cstatus ) { .notice %csearch.targnick Sorry %csearch.nick is not in the Runehead database. | /closeclansocket $sockname csearch }
  }
}

;##########################################################
;##                         Other                        ##
;##########################################################

alias -l closeclansocket {
  /sockclose clansearch
  /unset %csearch.*
}

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