Hawkee Snippet Search 3.0

By _Dean_ on Mar 02, 2011

Screenshots

• Copy and paste it into a new remote page (alt+R)
• Some functions of this Snippet will only work on versions 6.35+

• when loaded, right click on channel, then click on "Hawkee Snippet Search"
• you can search for tags, or snippet names, and click on Search
• to check the snippet code, twice click on the link of the snippet (if you click one time on the link, it will put the link on clipboard )
• You can click on the button "Select Code" to put the code on the clipboard, or click on "Load Code" to load it directly to your remotes
• you can check the snippet info, and click on the snippet link to visit the page

Load code, and select code, just get an error
the Select code will return "* Line too long: $+"
i guess that this bug was fixed on the 6.35, but if you keep getting this message let me know, by the way, the limit of bytes that are stored on the variables on the 7.17 are a limited number, so if you get an script with more than 4000 characters it will probably return an error too, so you have the option to load code, or visit the link

  • UPDATED:
  • Added an option to save to favorites
  • You can select links from the search or add it manually (if you choose to add manually, script will automatically recognize the link and the snippet name)
  • Added an option to see how many like(s) script have
  • Some bugs was fixed, which was allowing ppl to open a socket without a link

-UPDATED:

  • a problem with Hawkee html code was not allowing people to see the entire code, so now its fixed
  • now people can see other people comments
on *:sockopen:sps:{ 
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x = sockwrite -nt $sockname
    %x GET /snippets/search/ $+ %src $+ / HTTP/1.1
    %x HOST: www.hawkee.com
    %x
  }
}

on *:sockread:sps:{
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg)  }
  else {
    var %x 
    sockread %x
    if $regex(%x,/<a href='\/snippet\/(\d+)\/' class='large'>(.+)<\/a><br>/) { 
      $iif($dialog(hcode), did -za hcode 5 http://www.hawkee.com/snippet/ $+ $regml(1) $+ / - $regml(2)) | inc %Results 1
    }
    if (*We couldn't* iswm %x) {
      $iif($dialog(hcode),did -za hcode 5 $gettok(%x,1,46)) | did -ar hcode 16 Done | did -ar hcode 9 Results found: 0 | did -r hcode 13 | tags | sockclose $sockname
    }
    if (</html> isin %x) { 
      sockclose $sockname | did -ar hcode 16 Done | did -ar hcode 9 Results found: %Results | unset %Results
    }
  }
}

on *:sockopen:xa:{ 
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x = sockwrite -nt $sockname
    %x GET /snippet/ $+ %y $+ / HTTP/1.1
    %x HOST: www.hawkee.com
    %x
  }
}

on *:sockread:xa:{
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x 
    sockread %x
    if $regex(%x,/<span class="\w+">/i) {
      did -az hcode 8 $html_tags($char_r($regsubex(%x,/<[^>]+>|\t/g,))) $crlf
    }
    if (*&quot;* iswm %x) && (!$regex(%x,/(?:<br\s\/>|</br>)/)) {
      did -az hcode 8 $html_tags($char_r($regsubex(%x,/<[^>]+>|\t/g,))) $crlf
    }
    if $regex(%x,/<td align=left><b>([a-z]{3}\s[0-9]{2}\54\s[0-9]{4})<\/b><\/td>/i) {
      did -a hcode 12 Posted on: $regml(1)
    }
    if $regex(%x,/<td align=left width=290 style="font-size: 14px"><b>(.+)<\/b> <span style="font-size: 12px;">(.+)<\/span><\/td>/) {
      did -a hcode 15 Score: $regml(1) $regml(2)
    }
    if $regex(%x,/<a href='\/snippets\/user\/\d+\/'>(.+)'s\sSnippets<\/a> >/) {
      did -a hcode 11 Author: $regml(1)
    }
    if $regex(%x,/<a href='\/snippets\/cat\/mirc\/tags\/(.+)\/'>/g) {
      set -u3 %tags %tags $+ $chr(32) $regml(1)
      did -a hcode 14 Tags: $regsubex(%tags,/<[^]+>|\t/g,)
    }
    if $regex(%x,/<span class\='like_link'><b>(\d+)<\/b>\s.*<\/span><br>/) {
      did -ar hcode 26 Like(s): $regml(1)
    }
    if (</form><br> isin %x) {
      sockclose $sockname | did -v hcode 7,17 | did -ar hcode 16 Done | did -ar hcode 13 Script link
    }
  }
}

alias char_r {
  var %x = $regsubex($1-,/\46\43(\d+)\73/g,$chr(\1))
  return %x
}

alias html_tags {
  var %x = $replace($1-,&lt;,<,&gt;,>,&amp;,&,&quot;,",&nbsp;,$chr(160))
  return %x
}

dialog hcode {
  title "Hawkee Snippet Search 3.0"
  size -1 -1 235 306
  option dbu
  edit "", 1, 9 13 50 10, autohs
  text "Seach for:", 2, 9 4 26 8
  button "Search", 3, 62 12 37 12, default
  box "Search Results", 4, 5 27 226 82
  list 5, 9 35 217 69, size hsbar vsbar
  box "Code", 6, 6 119 227 163
  button "Select code", 7, 11 129 53 12
  edit "", 8, 9 142 219 136, read multi hsbar vsbar
  text "", 9, 168 111 63 8
  text "Snippet Info:", 10, 6 283 40 8
  text "", 11, 6 293 68 8
  text "", 12, 79 283 64 8
  link "", 13, 148 292 34 8
  text "", 14, 148 283 83 8
  text "", 15, 79 293 64 8
  text "", 16, 22 110 114 8
  button "Load Code", 17, 136 129 37 12
  button "Save to Favorites", 18, 109 12 54 12
  button "Open Favorites >>>", 19, 170 12 55 12
  button "Close Favorites <<<", 20, 170 12 55 12
  text "Here you can save your favorites scripts links", 21, 243 27 111 9
  box "Favorites", 22, 242 37 114 161
  list 23, 246 45 105 129, size hsbar vsbar
  button "Del", 24, 311 177 37 12
  button "Add manually", 25, 263 177 37 12
  text "", 26, 192 292 39 8
  box "Comments", 27, 242 200 115 101
  edit "", 28, 244 208 108 90, read multi hsbar vsbar
}

menu channel {
  .Hawkee Snippet Search: dialog $iif($dialog(hcode), -v, -m hcode) hcode
}
on *:dialog:hcode:init:*:{
  did -h hcode 7,17,18,20,24
  $iif(!$exists(favorites.txt), write favorites.txt, loadbuf -o hcode 23 favorites.txt)
  $iif($exists(favorites.txt), did -z hcode 23)
}

on *:dialog:hcode:sclick:*:{
  if ($did == 3) && ($did(1) != $null) {
    $iif($sock(sps), sockclose sps)
    $iif($sock(tags), sockclose tags)
    $iif($sock(xa), sockclose xa)
    sockopen sps www.hawkee.com 80 
    set -u3 %src $replace($did(1).text,$chr(32),+)
    did -r hcode 5,8,9,11,12,13,14,15,16,26,28
    did -a hcode 16 Getting list...
    unset %Tags
  }
  if ($did == 5) {
    clipboard $did(5).seltext
    did -v hcode 18
  }
  if ($did == 7) {
    did -ar hcode 16 Code selected
    var %x 1,%y
    while ($did(hcode, 8, %x).text) { 
      %y = %y $+ $did(hcode, 8, %x).text $crlf
      inc %x 
    }
    clipboard %y
  }
  if ($did == 13) {
    url www.hawkee.com/snippet/ $+ $iif($did(5).seltext,$gettok($did(5).seltext,4,47),$gettok($did(23).seltext,4,47)) $+ /
  }
  if ($did == 17) {
    var %x 1,%z = $replace($gettok($did(5).seltext,2,45),$chr(32),$chr(95)) $+ .mrc
    while ($did(hcode, 8, %x).text) { 
      write %z $did(hcode, 8, %x).text
      inc %x 
    }
    load -rs %z
  }
  if ($did == 18) && ($did(5).seltext) && (!$read(favorites.txt,w,* $+ $did(5).seltext $+ *)) { 
    write favorites.txt $did(5).seltext
    loadbuf -ro hcode 23 favorites.txt
  }
  if ($did == 19) { dialog -rs hcode -1 -1 724 612 | did -h hcode 19 | did -v hcode 20 }
  if ($did == 20) { dialog -rs hcode -1 -1 476 612 | did -h hcode 20 | did -v hcode 19 }
  if ($did == 23) && ($did(23).seltext) { did -v hcode 24 | clipboard $did(23).seltext }
  if ($did == 24) {
    write -dw $+ $qt($did(23).seltext) favorites.txt 
    loadbuf -ro hcode 23 favorites.txt
  }
  if ($did == 25) {
    var %favorites = $input(Here you can add your favorites manually,ey,Add links manually)
    if $regex(%favorites,/http:\/\/www\.hawkee\.com\/snippet\/\d+\//) {
      favorites %favorites
    }
    else { noop $input(You need to put a correct link,w,Warning) | halt }
  }
}
on *:dialog:hcode:dclick:*:{
  if ($did == 5) {
    if (*We couldn't* iswm $did(5).seltext) || (*Tags* iswm $did(5).seltext) { halt }
    else {
      $iif($sock(xa), sockclose xa) 
      sockopen xa www.hawkee.com 80 
      set -u3 %y $gettok($did(5).seltext,4,47)
      $iif($sock(cds),sockclose $v1,sockopen cds www.hawkee.com 80)
      did -r hcode 8,11,12,14,15,16,28
      did -z hcode 28
      did -a hcode 16 Getting code...
    }
  }
  if ($did == 23) && ($did(23).seltext) {
    $iif($sock(xa), sockclose xa) 
    sockopen xa www.hawkee.com 80 
    set -u3 %y $gettok($did(23).seltext,4,47)
    $iif($sock(cds),sockclose $v1,sockopen cds www.hawkee.com 80)
    did -r hcode 8,11,12,14,15,16,28
    did -z hcode 28
    did -a hcode 16 Getting code...
  }
}

on *:load:{
  if ($version < 6.35) {
    echo -a Some functions of this script will only work on 6.35+
  }
}

on *:dialog:hcode:close:*:{
  $iif($sock(sps), sockclose sps)
  $iif($sock(xa), sockclose xa)
  $iif($sock(favorites), sockclose favorites)
  $iif($sock(tags), sockclose tags)
  unset %Tags
}

alias tags {
  $iif($sock(tags), sockclose tags)
  sockopen tags www.hawkee.com 80
}

on *:sockopen:tags:{
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x = sockwrite -n $sockname
    %x GET /snippets/tags HTTP/1.1
    %x HOST: www.hawkee.com
    %x
  }
}

on *:sockread:tags:{
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x
    sockread %x
    if $regex(%x,/<a href='\/snippets\/cat\/mirc\/tags\/\w+\/'>(.+)<\/a>/ig) {
      set %tags %tags $chr(32) $regml(1) | inc %htags 1 
    }
    if (%htags == 20) { sockclose $sockname | $iif($dialog(hcode), did -za hcode 5 Avaliable Tags: %tags) | unset %htags }
  }
}

alias favorites {
  $iif($sock(favorites), sockclose favorites)
  sockopen favorites www.hawkee.com 80
  set -u5 %favorites $$1
}

on *:sockopen:favorites:{
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x = sockwrite -n $sockname
    %x GET /snippet/ $+ $gettok(%favorites,4,47) $+ / HTTP/1.1
    %x HOST: www.hawkee.com
    %x
  }
}

on *:sockread:favorites:{
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x 
    sockread %x
    if $regex(%x,/<title>(.+)\s-\s.*<\/title>/i) {
      $iif(!$read(favorites.txt,w,* $+ %favorites $+ *), write favorites.txt %favorites - $regml(1))
      loadbuf -ro hcode 23 favorites.txt
    }
  }
}

on *:sockopen:cds:{
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x = sockwrite -n $sockname
    %x GET /snippet/ $+ %y $+ / HTTP/1.1
    %x HOST: www.hawkee.com
    %x
  }
}
on *:sockread:cds:{
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x
    sockread %x
    if $regex(%x,/<b><a href='.*'>(.+)<\/a><\/b>/) {
      $iif($dialog(hcode),did -a hcode 28 • $regml(1) wrote: $crlf)
    }
    if $regex(%x,/(?:\11{4})?(.+)(?:<br>|<br\s\/>)/) {
      var %y = $regml(1)
      $iif($dialog(hcode),did -a hcode 28 $html_tags($char_r($regsubex(%y,/<[^>]*>|\t/g,))) $crlf)
    }
    if (*div comments* iswm %x) {
      sockclose cds 
    }
  }
}

Comments

Sign in to comment.
_Dean_   -  Oct 29, 2011

-UPDATED:

  • a problem with Hawkee html code was not allowing people to see the entire code, so now its fixed
  • now people can see other people comments
  • click on button "open favorites" to see other people comments
  • the comments section its in beta test yet
 Respond  
sok   -  Apr 22, 2011

Oga :) Good work!

 Respond  
irchainscriptz   -  Apr 01, 2011

yup awsome indeed!!!

 Respond  
Vegitha   -  Apr 01, 2011

awesome script

 Respond  
IllogicTC   -  Mar 26, 2011

Hey it does. However, when checking another script which contains the text structure "stuff:here", it seems to work fine. Awkward.

 Respond  
Conscious   -  Mar 26, 2011

http://www.hawkee.com/snippet/7044/

veiw that snippet with it, it mucks up on line 2. (may be more, idk)

 Respond  
Callumlord   -  Mar 26, 2011

Just what I have been looking for. Thanks Dean!!! :):):):):)

 Respond  
IllogicTC   -  Mar 25, 2011

Edited to reflect latest updates and still keep those darned little "Check Latest" buttons :P.

 Respond  
_Dean_   -  Mar 23, 2011

i think that do separated sockets its better and ppl can understand it, mix too much sockets in just one event, will confuse sometimes, and doing things separated looks like more organized, if you want to change it just go to the socket name and do it, instead looking for a lot of commands

 Respond  
_Dean_   -  Mar 23, 2011
  • UPDATED:
  • Added an option to save to favorites
  • You can select links from the search or add it manually (if you choose to add manually, script will automatically recognize the link and the snippet name)
  • Added an option to see how many like(s) script have
  • Some bugs was fixed, which was allowing ppl to open a socket without a link
 Respond  
_Dean_   -  Mar 21, 2011

Thanks dude i will update it soon with new updates

 Respond  
IllogicTC   -  Mar 21, 2011

Updated comment-posted snippet ^^^ to reflect changes and updates made by Dean. Dean, if you would like, you can take my whole snippet there. All I did was malform your original socket "sps" to create the other two sockets, and added three buttons, it is still primarily your work.

 Respond  
_Dean_   -  Mar 19, 2011

updated
now if you dont have any results,
script will suggest you some avaliable tags

a bug fixed on the double click of the list 5
it was allowing to open a socket if there was no result

 Respond  
IllogicTC   -  Mar 19, 2011
;Hawkee Snippet Grabber by _Dean_

on *:sockopen:sps:{ 
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x = sockwrite -nt $sockname
    %x GET /snippets/search/ $+ %src $+ / HTTP/1.1
    %x HOST: www.hawkee.com
    %x
  }
}

on *:sockread:sps:{
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg)  }
  else {
    var %x 
    sockread %x
    if $regex(%x,/<a href='\/snippet\/(\d+)\/' class='large'>(.+)<\/a><br>/) { 
      $iif($dialog(hcode), did -za hcode 5 http://www.hawkee.com/snippet/ $+ $regml(1) $+ / - $regml(2)) | inc %Results 1
    }
    if (*We couldn't* iswm %x) {
      $iif($dialog(hcode),did -za hcode 5 $gettok(%x,1,46)) | did -ar hcode 16 Done | did -ar hcode 9 Results found: 0 | did -r hcode 13 | tags | sockclose $sockname
    }
    if (</html> isin %x) { 
      sockclose $sockname | did -ar hcode 16 Done | did -ar hcode 9 Results found: %Results | unset %Results
    }
  }
}

on *:sockopen:spslatest:{
  if ($sockerr) { did -ar hcode 16 ERROR: $sock(spslatest).wsmsg }
  else {
    var %x = sockwrite -nt $sockname
    %x GET /mirc/snippets/ HTTP/1.1
    %x HOST: www.hawkee.com
    %x
  }
}

on *:sockread:spslatest:{
  if ($sockerr) { did -ar hcode 16 ERROR: $sock(spslatest).wsmsg }
  else {
    var %x
    sockread %x
    if $regex(%x,/<a href='\/snippet\/(\d+)\/' class='large'>(.+)<\/a><br>/) {
      $iif($dialog(hcode), did -za hcode 5 http://www.hawkee.com/snippet/ $+ $regml(1) $+ / - $regml(2)) | inc %Results 1
    }
    if (*We couldn't* iswm %x) {
      $iif($dialog(hcode),did -za hcode 5 $gettok(%x,1,46)) | did -ar hcode 16 Done | did -ar hcode 9 Results found: 0 | did -r hcode 13 | sockclose $sockname
    }
    if (</html> isin %x) {
      sockclose $sockname | did -ar hcode 16 Done | did -ar hcode 9 Results found: %Results | unset %Results
    }
  }
}

on *:sockopen:spsprevious:{
  if ($sockerr) { did -ar hcode 16 ERROR: $sock(spsprevious).wsmsg }
  else {
    var %x = sockwrite -nt $sockname
    %x GET /mirc/snippets/?&orderby=Date&p= $+ %hcode_latest HTTP/1.1
    %x HOST: www.hawkee.com
    %x
  }
}

on *:sockread:spsprevious:{
  if ($sockerr) { did -ar hcode 16 ERROR: $sock(spsprevious).wsmsg }
  else {
    var %x
    sockread %x
    if $regex(%x,/<a href='\/snippet\/(\d+)\/' class='large'>(.+)<\/a><br>/) {
      $iif($dialog(hcode), did -za hcode 5 http://www.hawkee.com/snippet/ $+ $regml(1) $+ / - $regml(2)) | inc %Results 1
    }
    if (*We couldn't* iswm %x) {
      $iif($dialog(hcode),did -za hcode 5 $gettok(%x,1,46)) | did -ar hcode 16 Done | did -ar hcode 9 Results found: 0 | did -r hcode 13 | sockclose $sockname
    }
    if (</html> isin %x) {
      sockclose $sockname | did -ar hcode 16 Done | did -ar hcode 9 Results found: %Results | unset %Results
    }
  }
}

on *:sockopen:xa:{ 
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x = sockwrite -nt $sockname
    %x GET /snippet/ $+ %y $+ / HTTP/1.1
    %x HOST: www.hawkee.com
    %x
  }
}

on *:sockread:xa:{
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x 
    sockread %x
    if $regex(%x,/<span class="\w+">/i) {
      did -az hcode 8 $html_tags($char_r($regsubex(%x,/<[^>]+>|\t/g,))) $crlf
    }
    if (*&quot;* iswm %x) && (!$regex(%x,/(?:<br\s\/>|</br>)/)) {
      did -az hcode 8 $html_tags($char_r($regsubex(%x,/<[^>]+>|\t/g,))) $crlf
    }
    if $regex(%x,/<td align=left><b>([a-z]{3}\s[0-9]{2}\54\s[0-9]{4})<\/b><\/td>/i) {
      did -a hcode 12 Posted on: $regml(1)
    }
    if $regex(%x,/<td align=left width=290 style="font-size: 14px"><b>(.+)<\/b> <span style="font-size: 12px;">(.+)<\/span><\/td>/) {
      did -a hcode 15 Score: $regml(1) $regml(2)
    }
    if $regex(%x,/<a href='\/snippets\/user\/\d+\/'>(.+)'s\sSnippets<\/a> >/) {
      did -a hcode 11 Author: $regml(1)
    }
    if $regex(%x,/<a href='\/snippets\/cat\/mirc\/tags\/(.+)\/'>/g) {
      set -u3 %tags %tags $+ $chr(32) $regml(1)
      did -a hcode 14 Tags: $regsubex(%tags,/<[^]+>|\t/g,)
    }
    if $regex(%x,/<span class\='like_link'><b>(\d+)<\/b>\s.*<\/span><br>/) {
      did -ar hcode 26 Like(s): $regml(1)
    }
    if (</form><br> isin %x) {
      sockclose $sockname | did -v hcode 7,17 | did -ar hcode 16 Done | did -ar hcode 13 Script link
    }
  }
}

alias char_r {
  var %x = $regsubex($1-,/\46\43(\d+)\73/g,$chr(\1))
  return %x
}

alias html_tags {
  var %x = $replace($1-,&lt;,<,&gt;,>,&amp;,&,&quot;,",&nbsp;,$chr(160))
  return %x
}

dialog hcode {
  title "Hawkee Snippet Search 3.0"
  size -1 -1 235 306
  option dbu
  edit "", 1, 9 16 50 10, autohs
  text "Seach for:", 2, 9 7 26 8
  button "Search", 3, 62 15 32 12, default
  box "Search Results", 4, 5 30 226 82
  list 5, 9 38 217 69, size hsbar vsbar
  box "Code", 6, 6 122 227 163
  button "Select code", 7, 11 132 53 12
  edit "", 8, 9 145 219 136, read multi hsbar vsbar
  text "", 9, 168 114 63 8
  text "Snippet Info:", 10, 6 286 40 8
  text "", 11, 6 296 68 8
  text "", 12, 79 286 64 8
  link "", 13, 148 295 34 8
  text "", 14, 148 286 83 8
  text "", 15, 79 296 64 8
  text "", 16, 22 113 114 8
  button "Load Code", 17, 136 132 37 12
  button "Save to Favorites", 18, 109 2 50 10
  button "Open Favorites", 19, 109 22 50 10
  button "Close Favorites", 20, 109 12 50 10
  text "Here you can save your favorites scripts links", 21, 243 27 111 9
  box "Favorites", 22, 242 37 114 161
  list 23, 246 45 105 129, size hsbar vsbar
  button "Del", 24, 311 177 37 12
  button "Add manually", 25, 263 177 37 12
  text "", 26, 192 295 39 8
  box "Comments", 27, 242 200 115 101
  edit "", 28, 244 208 108 90, read multi hsbar vsbar
  button "Check Latest", 99, 179 3 50 12
  button "<<", 100, 179 19 12 12, disable
  button ">>", 101, 217 18 12 12, disable
}

menu channel {
  .Hawkee Snippet Search: dialog $iif($dialog(hcode), -v, -m hcode) hcode
}
on *:dialog:hcode:init:*:{
  did -h hcode 7,17,18,20,24
  $iif(!$exists(favorites.txt), write favorites.txt, loadbuf -o hcode 23 favorites.txt)
  $iif($exists(favorites.txt), did -z hcode 23)
}

on *:dialog:hcode:sclick:*:{
  if ($did == 3) && ($did(1) != $null) {
    $iif($sock(sps), sockclose sps)
    $iif($sock(tags), sockclose tags)
    $iif($sock(xa), sockclose xa)
    sockopen sps www.hawkee.com 80 
    set -u3 %src $replace($did(1).text,$chr(32),+)
    did -r hcode 5,8,9,11,12,13,14,15,16,26,28
    did -a hcode 16 Getting list...
    unset %Tags
  }
  if ($did == 5) {
    clipboard $did(5).seltext
    did -v hcode 18
  }
  if ($did == 7) {
    did -ar hcode 16 Code selected
    var %x 1,%y
    while ($did(hcode, 8, %x).text) { 
      %y = %y $+ $did(hcode, 8, %x).text $crlf
      inc %x 
    }
    clipboard %y
  }
  if ($did == 13) {
    url www.hawkee.com/snippet/ $+ $iif($did(5).seltext,$gettok($did(5).seltext,4,47),$gettok($did(23).seltext,4,47)) $+ /
  }
  if ($did == 17) {
    var %x 1,%z = $replace($gettok($did(5).seltext,2,45),$chr(32),$chr(95)) $+ .mrc
    while ($did(hcode, 8, %x).text) { 
      write %z $did(hcode, 8, %x).text
      inc %x 
    }
    load -rs %z
  }
  if ($did == 18) && ($did(5).seltext) && (!$read(favorites.txt,w,* $+ $did(5).seltext $+ *)) { 
    write favorites.txt $did(5).seltext
    loadbuf -ro hcode 23 favorites.txt
  }
  if ($did == 19) { dialog -rs hcode -1 -1 724 612 | did -h hcode 19 | did -v hcode 20 }
  if ($did == 20) { dialog -rs hcode -1 -1 476 612 | did -h hcode 20 | did -v hcode 19 }
  if ($did == 23) && ($did(23).seltext) { did -v hcode 24 | clipboard $did(23).seltext }
  if ($did == 24) {
    write -dw $+ $qt($did(23).seltext) favorites.txt 
    loadbuf -ro hcode 23 favorites.txt
  }
  if ($did == 25) {
    var %favorites = $input(Here you can add your favorites manually,ey,Add links manually)
    if $regex(%favorites,/http:\/\/www\.hawkee\.com\/snippet\/\d+\//) {
      favorites %favorites
    }
    else { noop $input(You need to put a correct link,w,Warning) | halt }
  }
  if ($did == 99) {
    $iif($sock(spslatest), sockclose spslatest)
    sockopen spslatest www.hawkee.com 80
    did -r hcode 5,8,9,11,12,14,15,16
    did -a hcode 16 Getting latest snippets...
    did -e hcode 101
    set %hcode_latest 0
  }
  if ($did == 100) {
    dec %hcode_latest
    if (%hcode_latest > 0) {
      $iif($sock(spsprevious), sockclose spsprevious)
      sockopen spsprevious www.hawkee.com 80
    }
    else {
      did -b hcode 100
      $iif($sock(spslatest), sockclose spslatest)
      sockopen spslatest www.hawkee.com 80
    }
    did -r hcode 5,8,9,11,12,14,15,16
    did -a hcode 16 Getting next 25 snippets...
  }
  if ($did == 101) {
    inc %hcode_latest
    did -e hcode 100
    $iif($sock(spsprevious), sockclose spsprevious)
    sockopen spsprevious www.hawkee.com 80
    did -r hcode 5,8,9,11,12,14,15,16
    did -a hcode 16 Getting previous 25 snippets...
  }
}
on *:dialog:hcode:dclick:*:{
  if ($did == 5) {
    if (*We couldn't* iswm $did(5).seltext) || (*Tags* iswm $did(5).seltext) { halt }
    else {
      $iif($sock(xa), sockclose xa) 
      sockopen xa www.hawkee.com 80 
      set -u3 %y $gettok($did(5).seltext,4,47)
      $iif($sock(cds),sockclose $v1,sockopen cds www.hawkee.com 80)
      did -r hcode 8,11,12,14,15,16,28
      did -z hcode 28
      did -a hcode 16 Getting code...
    }
  }
  if ($did == 23) && ($did(23).seltext) {
    $iif($sock(xa), sockclose xa) 
    sockopen xa www.hawkee.com 80 
    set -u3 %y $gettok($did(23).seltext,4,47)
    $iif($sock(cds),sockclose $v1,sockopen cds www.hawkee.com 80)
    did -r hcode 8,11,12,14,15,16,28
    did -z hcode 28
    did -a hcode 16 Getting code...
  }
}

on *:load:{
  if ($version < 6.35) {
    echo -a Some functions of this script will only work on 6.35+
  }
}

on *:dialog:hcode:close:*:{
  $iif($sock(sps), sockclose sps)
  $iif($sock(xa), sockclose xa)
  $iif($sock(favorites), sockclose favorites)
  $iif($sock(tags), sockclose tags)
  unset %Tags
}

alias tags {
  $iif($sock(tags), sockclose tags)
  sockopen tags www.hawkee.com 80
}

on *:sockopen:tags:{
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x = sockwrite -n $sockname
    %x GET /snippets/tags HTTP/1.1
    %x HOST: www.hawkee.com
    %x
  }
}

on *:sockread:tags:{
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x
    sockread %x
    if $regex(%x,/<a href='\/snippets\/cat\/mirc\/tags\/\w+\/'>(.+)<\/a>/ig) {
      set %tags %tags $chr(32) $regml(1) | inc %htags 1 
    }
    if (%htags == 20) { sockclose $sockname | $iif($dialog(hcode), did -za hcode 5 Avaliable Tags: %tags) | unset %htags }
  }
}

alias favorites {
  $iif($sock(favorites), sockclose favorites)
  sockopen favorites www.hawkee.com 80
  set -u5 %favorites $$1
}

on *:sockopen:favorites:{
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x = sockwrite -n $sockname
    %x GET /snippet/ $+ $gettok(%favorites,4,47) $+ / HTTP/1.1
    %x HOST: www.hawkee.com
    %x
  }
}

on *:sockread:favorites:{
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x 
    sockread %x
    if $regex(%x,/<title>(.+)\s-\s.*<\/title>/i) {
      $iif(!$read(favorites.txt,w,* $+ %favorites $+ *), write favorites.txt %favorites - $regml(1))
      loadbuf -ro hcode 23 favorites.txt
    }
  }
}

on *:sockopen:cds:{
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x = sockwrite -n $sockname
    %x GET /snippet/ $+ %y $+ / HTTP/1.1
    %x HOST: www.hawkee.com
    %x
  }
}
on *:sockread:cds:{
  if ($sockerr) { $iif($dialog(hcode), did -ra hcode 16 ERROR: $sock($sockname).wsmsg) }
  else {
    var %x
    sockread %x
    if $regex(%x,/<b><a href='.*'>(.+)<\/a><\/b>/) {
      $iif($dialog(hcode),did -a hcode 28 • $regml(1) wrote: $crlf)
    }
    if $regex(%x,/(?:\11{4})?(.+)(?:<br>|<br\s\/>)/) {
      var %y = $regml(1)
      $iif($dialog(hcode),did -a hcode 28 $html_tags($char_r($regsubex(%y,/<[^>]*>|\t/g,))) $crlf)
    }
    if (*div comments* iswm %x) {
      sockclose cds 
    }
  }
}

Same as original snippet post, with the addition of a "check latest" button =P. Also, after selecting check latest, you can use the "<<" and ">>" buttons to search through snippets on previous pages.

 Respond  
MoshMage   -  Mar 08, 2011

Glad i could help :)

 Respond  
_Dean_   -  Mar 07, 2011

instead this you gave me a good idea, i will update it soon

 Respond  
MoshMage   -  Mar 07, 2011

Nice one mate! You could, tho. Add a feature to "latest in mIRC home" too. OR will it retrieve the newest snippets/scripts IF the search string is empty?

 Respond  
blackvenomm666   -  Mar 05, 2011

i was just suggesting from what the other person up ^^^ there said bout the edit box. i didnt test the code as of yet since i've mostly been on here with a wii console so no way to really test it so i didnt realise that was what you did.

 Respond  
_Dean_   -  Mar 05, 2011

Aucun50, i dont see why make hard things when u can solve it using simple things, i will keep updating it, since Hawkee gave me a tip about it, i know that Hawkee site its under some changes, Thanks for comment dude

blackvenomm666, in fact, your advice, do the same thing as this original one, look, it will be returned into an editbox, and everyone can copy single lines from there, or just select it, i understood what u mean, and Thanks for tip

 Respond  
blackvenomm666   -  Mar 04, 2011

dean as for your changing the list to an edit box that could work but i would just add an edit box and set it so if people double click on the one line they want from the list it sets it to an edit box either in the main dialog or opens a new one that just has the edit box and it sets the line to that.

 Respond  
Aucun50   -  Mar 04, 2011

Nice snippet, seen a few of these around before but they never keep up to date. I like your simple regex and dialog. I've tried to make sockets that paste code into dialogs before but no success as I don't know how, have to look this over later.

 Respond  
_Dean_   -  Mar 03, 2011

Thanks for score, Thanks for everyone that gave it a score and liked it =)

 Respond  
blackvenomm666   -  Mar 03, 2011

i must say i think this is one of your better snippets 7.0

 Respond  
sok   -  Mar 03, 2011

nice

 Respond  
_Dean_   -  Mar 03, 2011

Thanks dude

 Respond  
Sorasyn   -  Mar 03, 2011

Nice snippet, I attempted one of these a long time ago, but I didn't have enough knowledge of sockets then to complete it. Good to see one floating around. :)

By the way what is your native tongue? Gaps in your English suggest it's not your first language. :P

 Respond  
_Dean_   -  Mar 02, 2011

updated, now with the edit instead list, added the -t switch on the sockwrite
i added a on dialog close event, to close the sockets if is openned

 Respond  
Jethro   -  Mar 02, 2011

You should include the -t switch for your sockwrite, because if a code a user searches for consists of the & in the beginning of a string, you don't want mIRC to process it as a binary variable. There are quite a few of snippets here are binary specific and have the & in them.

 Respond  
_Dean_   -  Mar 02, 2011

Thanks for say that, i will fix some parts yet, as i said this is more a beta version, i know that Hawkee is changing code sometimes

Conscious, about your question, im working in some bug fixes yet, i already thought in put an editbox instead list

 Respond  
Hawkee   -  Mar 02, 2011

I wouldn't match against anything like class='large', td, tr, etc. I would only match against the href, title and pre which are less likely to change. It's very likely anything specific like the classes and table cells will change in the future and break this code.

 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.