Hawkee Snippet Ripper v1.0

By pope on Feb 01, 2009

Tired of finding snippets on here and having to manually copy, paste, and load them? Well Your troubles are over! This is the LAST snippet you will EVER have to copy/paste! Just right click in ANY window and choose HAWKEE. If you have already copied the URL to your clipboard it will be displayed in the prompted dialog, but if not then a URL in the appropirate dialog will be displayed.

To Use:

  1. Open the Script Editor (->Tools ->Script Editor)
  2. Create a NEW file called HAWKEE (From Script Editor: ->File ->New)
  3. Paste in this snippet and hit OK (or ->File ->Save)
  4. Rightclick in any window and click HAWKEE.
  5. Paste the desired snippet URL into the prompted dialog and it automatically downloads the snippet to whatever directory this snippet is saved to. You then have the option to load the snippet.

Comments/bug reports/feedback appreciated! TY!

;Hawkee Snippet Ripper v1.0 script by pope
;PEERCOMMONS chat.peercommons.net 6667
;#scripters.united
;
menu * { 
  HAWKEE: {
    if (hawkee.com/snippet !isin $cb(1)) {
      clipboard www.hawkee.com/snippet/XXX
    }
    set %hawkeepage $cb(1)
    dialog -mo hawkeepage hawkeepage
  }
}
;HAWKEE PAGE DIALOG
dialog hawkeepage {
  title "What Site?"
  size -1 -1 130 42
  option dbu 
  text "Enter The URL To The Snippet Here", 1, 23 5 85 10
  edit $cb(1), 2, 13 14 105 10, autohs
  button "Add", 3, 42  28 20 10, ok
  button "Close", 4, 68 28 20 10, cancel
}
on *:dialog:hawkeepage:edit:2:{
  set %hawkeepage $did(hawkeepage,2).text 
}
on *:dialog:hawkeepage:sclick:3: {
  if (hawkee.com/snippet/ !isin %hawkeepage) {
    dialog -mo invalidadd invalidadd
    halt
  }
  set %next 0
  set %hawkeepage $remove(%hawkeepage,http://,www,hawkee,.,com)
  if ($sock(gethawkee)) {
    .sockclose gethawkee
  }
  sockopen gethawkee www.hawkee.com 80
}
;INVALID PAGE DIALOG
dialog invalidadd {
  title "Invalid Address"
  size -1 -1 90 30
  option dbu 
  text "That's Not A Valid Hawkee Page", 1, 7 5 78 14
  button "Close", 2, 35 15 20 10, cancel
}
;LOAD DIALOG
dialog doneload {
  title "Script Successfully Saved!"
  size -1 -1 65 30
  option dbu 
  text "Load Into Remotes?", 1, 9 5 78 14
  button "Load", 2, 10 15 20 10, ok
  button "Close", 3, 35 15 20 10, cancel
}
on *:dialog:doneload:sclick:*: {
  if ($did == 2) {
    .load -rs $qt($scriptdir $+ %filename $+ .mrc)
    echo -a 4 %filename $+ .mrc Successfully Loaded!
  }
  if ($did == 3) {
    echo -a 4 %filename $+ .mrc Successfully Saved But Not Loaded!
  }
}
;
;SOCKET
on *:SOCKOPEN:gethawkee: {
  echo -a 4Saving Snippet. Download Time Varies Depending On Length Of Snippet...
  sockwrite -nt $sockname GET %hawkeepage HTTP/1.1
  sockwrite -nt $sockname Host: www.hawkee.com
  sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:gethawkee: {
  if ($sockerr) {
    echo -a -a SOCKET ERROR: $sockerr
    halt
  }
  else {
    var %hawkee
    sockread %hawkee
    if (<title> isin %hawkee) {
      set %filename $remove(%hawkee,<title>,- mIRC Code Snippet</title>,",/,\,:,*,?)
    }
    if (<h2> isin %hawkee) {
      tokenize 62 %hawkee
      write -l1 $qt($scriptdir $+ %filename $+ .mrc) ; $+ %filename by $remove($2,</h2) http://www.hawkee.com $+ %hawkeepage
      write -il2 $qt($scriptdir $+ %filename $+ .mrc) ;Downloaded From Hawkee Via Hawkee Snippet Ripper v1.0 http://www.hawkee.com/snippet/5705/
      dialog -mo doneload doneload
      sockclose gethawkee
    }
    if (</textarea isin %hawkee) {
      set %next 2
    }
    if (%next == 1) {
      write $qt($scriptdir $+ %filename $+ .mrc) $replace(%hawkee,&quot;,",&gt;,>,&lt;,<,&amp;,&)
    }
    if ((<textarea isin %hawkee) && (%next != 2)) {
      tokenize 62 %hawkee
      write -c $qt($scriptdir $+ %filename $+ .mrc) xxx
      write $qt($scriptdir $+ %filename $+ .mrc) $replace($2,&quot;,",&gt;,>,&lt;,<,&amp;,&)
      set %next 1
    }
  }
}

Comments

Sign in to comment.
Kirby   -  Feb 27, 2009

I actually use this, lol.
You should replace spaces with _'s ($chr(95)) to the .mrc file name, as well as changing the snippet title a bit when there's a / ($chr(47) in front of the filename.
Because mIRC doesn't recognize those two things, I have to manually delete the snippets and restart the client.

 Respond  
Korvin   -  Feb 02, 2009

why isnt the script done?

 Respond  
pope   -  Feb 02, 2009

so can i get a +1 Blitzjager? haha

 Respond  
Kirby   -  Feb 01, 2009

no u Blitzjager!

 Respond  
Blitzjager   -  Feb 01, 2009

there's always time.
<Kirby`> only 23 minutes
Oh really? :P

My favourite thing about this is that it doesn't save it as scriptx.
There's things I want to reload but I don't want to go through all my scriptxs :(

 Respond  
Kirby   -  Feb 01, 2009

Hastily writing scripts? :p
Personally, I like to take time on scripts and try to perfect them to the limit. :p
There's no rush to writing scripts, there's always time. =)

 Respond  
pope   -  Feb 01, 2009

ty for the input kirby! will incorporate into version 1.1 :)
i just hastily wrote this script bc its pretty much the most useful script idea ive ever had haha

 Respond  
Kirby   -  Feb 01, 2009

This might be my scripting habit, but here are some things that I can suggest that might shorten the length of your script by some.

on *:dialog:hawkeepage:edit:2:{
  set %hawkeepage $did(hawkeepage,2).text 
}
on *:dialog:hawkeepage:sclick:3: {
  if (hawkee.com/snippet/ !isin %hawkeepage) {
    dialog -mo invalidadd invalidadd
    halt
  }
  set %next 0
  set %hawkeepage $remove(%hawkeepage,http://,www,hawkee,.,com)
  if ($sock(gethawkee)) {
    .sockclose gethawkee
  }
  sockopen gethawkee www.hawkee.com 80
}

on *:dialog:doneload:sclick:*: {
  if ($did == 2) {
    .load -rs $qt($scriptdir $+ %filename $+ .mrc)
    echo -a 4 %filename $+ .mrc Successfully Loaded!
  }
  if ($did == 3) {
    echo -a 4 %filename $+ .mrc Successfully Saved But Not Loaded!
  }
}

As you might already know:

on *:dialog:name:event:id: {

name would be $dname, event would be $devent, and id would be $did.

Hence, you can shorten the code that I pasted above into smaller amounts like this:

on *:dialog:*:*:*: {
  if ($dname == hawkeepage) {
    if ($devent == edit) {
      if ($did == 2) { set %hawkeepage $did(hawkeepage,2).text }
    }
    if ($devent == sclick) {
      if ($did == 3) {
        if (hawkee.com/snippet/ !isin %hawkeepage) { dialog -mo invalidadd invalidadd | halt }
        set %next 0 | set %hawkeepage $remove(%hawkeepage,http://,www,hawkee,.,com)
        if ($sock(gethawkee)) { .sockclose gethawkee }
        .sockopen gethawkee www.hawkee.com 80
      }
    }
  }
  if ($dname == doneload) {
    if ($devent == sclick) {
      if ($did == 2) { .load -rs $qt($scriptdir $+ %filename $+ .mrc) | echo -a 4 %filename $+ .mrc Successfully Loaded! }
      if ($did == 3) { echo -a 4 %filename $+ .mrc Successfully Saved But Not Loaded! }
    }
  }
}

Of course, I'm a dialog-nazi so you can ignore me if you want. :P
Just giving you suggestions. ^^

/me rates 7.0 because he hates copying and pasting scripts and then loading them. >:[

Saves me time. =D

 Respond  
pope   -  Feb 01, 2009

yeah i debated that, but decided that it wouldnt work in all instances, so i think i might go with $cb(1) if anything. ty for the suggestion tho! keep 'em commin! :)

 Respond  
TheImrac   -  Feb 01, 2009

Pretty cool, you should add a button to use the current URL of your browser: $url

 Respond  
Aucun50   -  Feb 01, 2009

/me likes name

 Respond  
pope   -  Feb 01, 2009

constructive criticism welcome!!!

 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.