Hawkee snippet search

By Callison1 on Jul 27, 2007

You simply put this in remotes and then people can type !hawkee or @hawkee to get the top snippet for all search terms after [!@]hawkee.

on $*:TEXT:/^[!@](hawkee|snippet|code) */Si:#: { 
  if ($sock(hawkee)) .sockclose hawkee
  if ($2 == $null) { halt }
  elseif (!* iswm $1) { set %hawk.style notice $nick }
  elseif (@* iswm $1) { set %hawk.style msg $chan }
  set %hawksearch $replace($2-,$chr(32),+)
  sockopen hawkee www.hawkee.com 80
}
on *:SOCKOPEN:hawkee: {
  sockwrite -nt $sockname GET /snippets/?user_id=&snippet_type=&search_query= $+ %hawksearch $+ &search_type=snippet_title HTTP/1.1 
  sockwrite -nt $sockname Host: www.hawkee.com 
  sockwrite -nt $sockname $crlf 
}
on *:SOCKREAD:hawkee: {
  if ($sockerr) { halt } 
  else {
    var %temp
    sockread %temp
    if (( %hawk.lines == 2 )) {
      set %hawk.result www.hawkee.com $+ $remove($gettok(%temp,2,32),href=',')
      if (( %hawk.result == www.hawkee.com200 )) {
        %hawk.style Error, please try again
        unset %hawk*
        sockclose $sockname
        halt
      }
      var %name = $gettok(%temp,3,32) $gettok(%temp,4,32) $gettok(%temp,5,32)
      set %hawk.name $remove(%name,class='large'>,</a><br>)
    }
    if (( %hawk.lines == 5 )) {
      var %auth = $gettok(%temp,3,32)
      var %hawk.author = $remove(%auth,class='smallest'>,</a>)
      var %date = $gettok(%temp,8,32) $gettok(%temp,9,32) $gettok(%temp,10,32)
      var %hawk.date = $remove(%date,#000000;"><b>,</b></span><br>)
      %hawk.style Top Result for %hawksearch $+ : %hawk.name $+ : %hawk.result submitted by %hawk.author on %hawk.date
      unset %hawk*
      sockclose $sockname
    }
    if (( %hawk.lines != $null )) && (( %hawk.lines < 5 )) { inc %hawk.lines }
    if (( <div style="float: left; width: 500px; margin-bottom: 10px;"> == %temp )) { set %hawk.lines 1 }
  }
}

Comments

Sign in to comment.
T7Davey   -  Sep 09, 2007

I love it!

 Respond  
xDaeMoN   -  Aug 15, 2007

I think the reason why the other hawkee search scripts didn\'t work because of the change of layout. So the authors just need to update the script to get the information in the correct location.

 Respond  
guest598594   -  Aug 15, 2007

good job, the other hawkee search snippets never worked for me, glad theres finally a good one

one suggestion though, when you search something with no results, it doesnt say anything, you should have it say something like Sorry, there are no snippet results for $2-

othere than that, it\'s great 7/10

 Respond  
Callison1   -  Jul 28, 2007

Thanks for the good comments :D

 Respond  
lexie   -  Jul 27, 2007

its well ace script, i like it :)

 Respond  
Callison1   -  Jul 27, 2007

I\'m too un-good (i know it\'s not a word but i can\'t be bothered to think) at scripting to know how to do that ^ =(

 Respond  
Hawkee   -  Jul 27, 2007

Awesome! I love to see scripts that interface with the site. Now somebody needs to design something that combines the comment RSS feeds and this.

 Respond  
napa182   -  Jul 27, 2007

nice Callison1 goood job =)

 Respond  
sharpknife   -  Jul 27, 2007

heh, i was looking for this yesterday and found a version that doesnt work anymore.. nice work ;)

 Respond  
[M]ike   -  Jul 27, 2007

Yeah, mine diplays the name and author ^^

 Respond  
xDaeMoN   -  Jul 27, 2007

It works fine for me here. You might want to add the name and the author of the snippet.

 Respond  
Callison1   -  Jul 27, 2007

Does anyone else have the same problem? I have exactly the same script in my remotes and it works fine for me.

 Respond  
Callison1   -  Jul 27, 2007

That\'s odd, I copied my snippet exactly and it still works for me.

 Respond  
Anti   -  Jul 27, 2007

Well done on your scripting btw great effort

 Respond  
Anti   -  Jul 27, 2007

www.hawkee.comstyle=margin-bottom: Yeah there\'s something going on there i don\'t know how to fix that at all just wanted to get that out in the open i do believe someone has already made a snippet locator thingy..

 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.