Google Definer

By Zmodem on Sep 29, 2008

UPDATE (Nov 02, 2013) - THIS SNIPPET NO LONGER SUPPORTED/OUTDATED. ARCHIVAL USE ONLY. Thank you!

Google Definer is a very primitive snippet that allows you to load the definition for words, from google, into a custom dialog.

Syntax: /gdef

I only say that it's primitive because it's completely command-line-oriented, as well as it returns results in a somewhat plain way. Very handy for people who need definitions!

Enjoy!

;www.google.com
;GET /search?hl=en&safe=off&q=define%3A<WORD1>+<WORD2>+<ETC> HTTP/1.0

alias -l atext did -a gdef 1 $1-
alias -l htmlfree { return $regsubex($$1-,/^[^<]*>|<[^>]*>|<[^>]*$/g,) }
alias gdef if ($1 != $null) { dialog $iif(!$dialog(gdef),-m,-a) gdef gdef | set %googledef $replace($1-,$chr(32),+) | sockclose GoogleDef | sockopen GoogleDef www.google.com 80 }
alias -l between { 
  noop $regex($1,/\Q $+ $2 $+ \E(.*?)\Q $+ $3 $+ \E/gi) 
  return $regml($4) 
}
ON *:SOCKOPEN:GoogleDef: { did -r gdef 1 | atext (Definition of: %googledef $+ ) $+ $crlf | sockwrite -n GoogleDef GET /search?hl=en&safe=off&q=define%3A $+ %googledef HTTP/1.0 | sockwrite -n GoogleDef Host: www.google.com $+ $crlf $+ $crlf }
ON *:SOCKCLOSE:GoogleDef: {
  if ($dialog(gdef)) {
    atext $crlf $+ $crlf $+ $iif(!$did(gdef,1,2),No Definition Found...,Finished!) 
    did -c gdef 1 1 
    unset %googledef
  }
}
ON *:SOCKREAD:GoogleDef:{
  if ($sockerr > 0) { atext No Definition Found $+ $crlf $+ $crlf (ERROR: $sock(GoogleDef).wserr $+ ) | return }
  var %iData
  :gather
  sockread %iData
  if ($sockbr == 0) return
  if (!%iData) %iData = $chr(160)
  var %i = 1, %m = $between(%iData,<li>,<li>,0), %i2 = 1, %m2 = $between(%iData,<li>,<br>,0)
  while (%i <= %m) {
    atext $dorep($htmlfree($between(%iData,<li>,<li>,%i)))
    inc %i
  }
  while (%i2 <= %m2) {
    atext $dorep($htmlfree($between(%iData,<li>,<br>,%i2)))
    inc %i2
  }
  goto gather
}
alias -l dorep return $replace($1-,.html,.html $+ $crlf $+ $crlf,*,$crlf,&quot;,",...,$crlf $+ $crlf)

dialog -l gdef {
  title "GoogleDef"
  size -1 -1 267 200
  option dbu
  edit "", 1, 4 4 259 174, vsbar multi return read
  button "&Close", 2, 83 182 36 15, cancel
  button "&Save As...", 3, 136 182 36 15
}
ON *:DIALOG:gdef:close:0:sockclose gdef | unset %googledef
ON *:DIALOG:gdef:sclick:3: {
  var %f = $qt($sfile($qt($mircdir),Save to:,&Save)), %i = 1, %m = $did(1).lines, %t
  if (%f) {
    if ($isfile(%f)) {
      if ($input(This file already exists. Do you wish to overwrite it?,yn,File Exists)) { write -c %f }
      else { return }
    }
    while (%i <= %m) {
      %t = $did(1,%i)
      write %f $iif(%t,%t,$crlf)
      inc %i
    }
    return $input(Successfully saved to: %t,iok6,Save Complete)
  }
}

Comments

Sign in to comment.
Zmodem   -  Sep 21, 2010

NinjaxAssasin: LoL! Obviously not! :-D

 Respond  
NinjaxAssasin   -  Aug 12, 2010

WTF Invalid parameters: $did (line 119, aliases1.ini) ????
i puut it in remotes

 Respond  
Jace   -  Oct 29, 2008

EL
Comments: 1,205

mIRC Snippet: Google Definer
Posted on Sep 30, 2008 3:55 am
Its cool Z works fine and its useful;p.Well done.`-.-´

I think i gave ya a 8 last time so."Rate it? Or Hate it?...8/10.`-.-´

 Respond  
Zmodem   -  Oct 29, 2008

Appreciated! :-)

 Respond  
Anish   -  Oct 29, 2008

very nice , I like it.

9/10 from /me :)

 Respond  
Zmodem   -  Oct 02, 2008

Thanks, napa!

 Respond  
napa182   -  Oct 02, 2008

nice work Zmodem

 Respond  
Zmodem   -  Oct 01, 2008

Hilarious, well, thanks for all the great words and ratings guys! I appreciate it!

 Respond  
a careful warchild   -  Oct 01, 2008

im crying because everyone makes an alias define and not a !define :(:(:( and i know it works fine :D:D

 Respond  
Jamiie   -  Oct 01, 2008

/me grabs Zmodem's man boobies...

oh.. yeah.. the snippet, it's nice. No errors that I can see for now.

Now time for work.. -.-

8/10+like

 Respond  
Zmodem   -  Sep 30, 2008

I have no idea what you're crying about, acw, it works perfect and it's a great guideline for other people looking to fetch things from websites.

EL: Thanks!

 Respond  
a careful warchild   -  Sep 30, 2008

:'( @ zmodem :(

 Respond  
EL   -  Sep 30, 2008

Its cool Z works fine and its useful;p.Well done.`-.-´

 Respond  
Zmodem   -  Sep 29, 2008

No, this is not going to be made into a !trigger snippet :-)

 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.