Hawkee snippet search

By Lindrian on Oct 06, 2007

This is a simple tool to search (all) of the snippets on the site.
Simply type /hawkee and wait for the result.
I made this while I was bored, it was a pain in the butt to make the regex work properly, the site was literally a bitch to parse.

I tried to make it seperetate for each section, but that didnt work ( for some reason) and i coudnt bother to keep trying, I was also going to make one to retrive the codes from the main site, but as the code on the main site (snippets) is on huge line, ~2k in len (line too long errors) i had some problems, but i'll fix it sooner or later, just need more time.

Until then, enjoy this (simple) one.

; Syntax: /hawkee <snippet to search for>
on *:sockopen:hawkee: {
  if ($sockerr) {
    echo -a Error connecting: $sock($sockname).wsmsg
    sockclose hawkee
  else {
    sockwrite -n $sockname GET %hawkee.site HTTP/1.1
    sockwrite -n $sockname Host: www.hawkee.com
    sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8)
    sockwrite -n $sockname $crlf
on *:sockread:hawkee: {
  var %x
  sockread %x
  if ($regex(%x,/&nbsp;\x28(\d+)\x29<\/td>/i)) && (!%all) %all = $regml(1)
  if ($regex(%x,/<span class='shop_largest' id='score_'>(.*?)<\/span>/i)) %score = $regml(1)
  if ($regex(%x,/<a href='(.*?)'.*?>(.*?)<\/a>.*?</)) {
    if ($regml(2) != Home) {
      %z = $calc(%z + 1)
      if (%z == 1) {
        %link = $regml(1)
        %name = $regml(2)
      elseif (%z == 2) {
        %user = $regml(2)
        %t = $calc(%t + 1)
        if (%score > %ls) { 
          %ls = %score 
          %p = %t 
        set $+(%,hawkee.match.,%t) $iif($len(%t) == 1,0) $+ %t $+ . Title: %name Score: %score Author: %user Link: http://www.hawkee.com $+ %link
        set %hawkee.result 1
        unset %name %user %score %z
on *:sockclose:hawkee: {
  if (!%hawkee.result) echo -a Sorry, there was no match for $qt(%hawkee.search) $+ ...
  else {
    var %x = 1, %h = $var(%hawkee.match.*,0)
    while ($var(%hawkee.match.*,%x).value) {
      var %i = $v1
      echo -a $iif($gettok(%i,1,46) == %p && %t != 1,04 $+ %i - (Top rated!),%i)
      inc %x
    echo -a 
    echo -a Search for $qt(%hawkee.search) produced %h result(s) on page one $+ $iif(%h != %all,$chr(44) out of a total of %all matches. - Visit this site for all results: http://www.hawkee.com $+ %hawkee.site,.)
  unset %hawkee.* %t %p %all %z %ls
alias hawkee {  
  if ($sock(hawkee)) .sockclose hawkee
  if ($1) {
    set %hawkee.search $1-
    set %hawkee.site /snippets/?search_query= $+ $htmlfrm(%hawkee.search)
    set %ls 0.0
    sockopen hawkee www.hawkee.com 80
    echo -a Looking for snippets matching $qt($1-) $+ ... Please hold.
    echo -a 
  else echo -a You must specify something to search for! Use the following syntax: /hawkee <snippet>, eg: /hawkee mass modes
alias htmlfrm {
  var %i = 1,%r
  while (%i <= $len($1-)) {
    if ($mid($1-,%i,1) isalnum) %r = %r $+ $v1
    else %r = %r $+ % $+ $base($asc($mid($1-,%i,1)),10,16,2)
    inc %i
  return %r
alias h hawkee $1-
alias hawk h $1-


Sign in to comment.
Cheiron   -  Apr 07, 2009

very nice script and works well.. would be nice to either have it respond to a trigger and private message the nick in question the results or message the channel the results instead of using echo for self view

Lindrian   -  Feb 15, 2008

Thanks Hondax707 :)

HoNdAx707   -  Feb 14, 2008

really helpful so i dont gotta open IE :P

Lindrian   -  Feb 14, 2008

Updated the script a bit, remade a few regexes that i bothered, removed the html alias, added a bunch of new features, test it out, i find it very usful myself now! :)

Lindrian   -  Feb 14, 2008

Should be fixed.
the \w+ in the regex was w+, since hawkee tends to strip \"\\\" for some reason (backslashes)

guest598594   -  Feb 14, 2008

doesn\'t show the scores


  1. Name: Hawkee snippet search Score: Author: Lindrian Link: http://www.hawkee.com/snippet/3359/
napa182   -  Dec 06, 2007

he\'s so special i see the short bus picking him up... =P

F*U*R*B*Y*   -  Dec 05, 2007

yes he is special, he can bump a topic thats what 3 months old??? really special..........

Lindrian   -  Dec 05, 2007

Yes, you sure are... \"special\"...

bps19882006   -  Dec 05, 2007

lol im special lmaooooo

guest598594   -  Oct 09, 2007

yea, i changed it to an on input, so i guess that screwed it up somehow

Lindrian   -  Oct 09, 2007

mountaindew: I cant reproduce that error. It\'s prob your mirc, or u have a malformed code with missmatching brackets disturbing.

RubixCube   -  Oct 08, 2007

Nice job. everything seemed to work fine for me.

guest598594   -  Oct 08, 2007

w/e i type in it either leads to bps19882006 every time, or it says nothing, and either way, it says \"top unknown command\"

Scakk   -  Oct 08, 2007

That would explain it then ^_^

Lindrian   -  Oct 08, 2007

Only the first page, yes. I didn\'t make it switch page...

Scakk   -  Oct 07, 2007

Does it default at finding 15? I search for \" dialog \" and it only showed 15. When I search on the site itself I get 48. I have 6 snippets that have \" dialog \" in the title and none of them were found.

Lindrian   -  Oct 07, 2007

Thanks :)

Godzilla   -  Oct 07, 2007

People, now don\'t start a fall on hawkee snippet search after 8ball ^^

Well, nice job mate :)

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.