WowWiki World of Warcraft Wiki Search

By FordLawnmower on Sep 10, 2009

Image
I made this script at the request of Scofield.
This script searches wowwiki.com for results and returns them to the channel/user.
The syntax is !wowwiki search words here or @wowwiki search words here.
The ! trigger will notice the user and the @ trigger will message the channel if the user has halfops or higher.
There is also an alias /wowwiki search words here.

To use: Load into the remotes on your bot, right click the channel or status screen, click wowwiki and turn the trigger on.

;WowWiki Search Script by Ford_Lawnmower -- irc.mindforge.org #USA-Chat
menu Channel,Status {
  .$iif($group(#wowwiki) == On,$style(1)) WowWiki Trigger
  ..$iif($group(#wowwiki) == On,$style(2)) On: .enable #wowwiki
  ..$iif($group(#wowwiki) == Off,$style(2)) Off: .disable #wowwiki
}
#wowwiki off
On $*:Text:/^(!|@)wowwiki.*/Si:#: {
  if ($timer($+(wowwiki,$network,$nick))) { return }
  .timer $+ $+(wowwiki,$network,$nick) 1 4 noop
  var %method $iif($regml(1) == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/),.msg $chan,.notice $nick))
  if (!$2) { %method Please provide at least one search term. Syntax !wowwiki search name | return }
  wowwikiS %method $2-
}
#wowwiki end
alias wowwiki { wowwikiS echo -a $1- }
alias -l wowwikiS {
  var %sockname $+(wowwikiS,$network,$2,$ticks)
  sockopen %sockname www.wowwiki.com 80
  sockmark %sockname $1-2 $+(/Special:Search/,$replace($3-,$chr(32),_))
}
On *:sockopen:wowwiki*: {
  if (!$sockerr) {
    sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
    sockwrite -n $sockname Host: www.wowwiki.com
    sockwrite -n $sockname Pragma: No-Cache
    sockwrite -n $sockname $crlf
  }
  else { echo -st socket error $nopath($script) }
}
On *:sockread:wowwikiS*: {
  if ($sockerr) { echo -st socket error $nopath($script) }
  else {
    var %wowwikiS | sockread %wowwikiS
    if ($regex(%wowwikiS,/Location: http://www.wowwiki.com(.*)/)) {
      wowwikiR $gettok($sock($sockname).mark,1-2,32) $regml(1) 0
      sockclose $sockname
    }
  }
}
On *:sockclose:wowwiki*: { $gettok($sock($sockname).mark,1-2,32) Sorry No results found for your Search }
alias -l wowwikiR {
  var %sockname $+(wowwikiR,$network,$2,$ticks)
  sockopen %sockname www.wowwiki.com 80
  sockmark %sockname $1-
}
On *:sockread:wowwikiR*: {
  if ($sockerr) { echo -st socket error $nopath($script) }
  else {
    var %wowwikiR | sockread %wowwikiR
    if (<p> isin %wowwikiR) { sockmark $sockname $puttok($sock($sockname).mark,$calc($gettok($sock($sockname).mark,4,32) + 1),4,32) }
    if ($gettok($sock($sockname).mark,4,32)) && ($replace($remove($gettok($sock($sockname).mark,3,32),/),_,$chr(32)) isin $httpstrip($nocite(%wowwikiR))) { 
      Put $gettok($sock($sockname).mark,1-2,32) $v2 $+(,http://www.wowwiki.com,$gettok($sock($sockname).mark,3,32))
      sockclose $sockname
      return
    }
  }
}
alias -l nocite {
  var %x, %i = $regsub($1-,/\Q<span class="citelink\E.*\Q</span>\E/g,$null,%x) | return %x
}
alias -l httpstrip { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x) | return $replace($remove(%x,&#91;citation needed&#93;),&amp;,&) }
alias -l Put {
  if (!$regex($1,/(\.|^)(msg|notice|echo)$/Si)) || (!$3) { echo -st **Put error** Syntax /Put msg #channel text - or - /Put notice nickname text  | return }
  tokenize 32 $regsubex($1-,/([$\|%\[\]\}\{][^\s]*)/g,$+($chr(2),$chr(2),\t))
  var %tokens $0, %Tstart 3, %Dtimer 1500
  if ($timer($+(Put,$2,$network)).secs) { %Dtimer = $calc($v1 * 1000) }  
  while ($len($($+($,%Tstart,-,%tokens),2)) > 430) {
    dec %tokens
    if ($len($($+($,%Tstart,-,%tokens),2)) <= 430) {
      .timer -m 1 %Dtimer $1-2 $($+($,%Tstart,-,%tokens),2))
      inc %Dtimer 1500
      %Tstart = $calc(%tokens + 1)
      %tokens = $0
    }
  }
  .timer -m 1 %Dtimer $1-2 $($+($,%Tstart,-,%tokens),2))
  .timer $+ $+(Put,$2,$network) -m 1 $calc(%Dtimer + 1500) noop 
}

Comments

Sign in to comment.
FordLawnmower   -  Mar 28, 2010

Thanks montague :)

 Respond  
montague   -  Mar 28, 2010

http://bit.ly/aDmAYR <3 Jane McGonigal: Gaming can make a better world

+1 like 10/10 rate, tyvm FordLawnmower :D

 Respond  
GlobalAnomaly   -  Sep 10, 2009

Ew World Of Warcraft ~_~

 Respond  
Cracker200   -  Sep 10, 2009

NVM SORRY LOL

 Respond  
Cracker200   -  Sep 10, 2009

Um... i don't mean to be a part pooper but look


[04:14:05:AM] <+shanker> !wowwiki Love
[04:14:09:AM] -DustBot- Sorry No results found for your Search
[04:14:11:AM] <+shanker> hm
[04:14:15:AM] <+shanker> !wowwiki Amor
[04:14:17:AM] -DustBot- Sorry No results found for your Search
[04:14:18:AM] <+shanker> 5FÚCK OF
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.