Google Dialog Search

By FordLawnmower on May 05, 2009

Image
Google Dialog Search

The dialog is pretty self explanatory. Just type something in the box and click search.
The link boxes are single click with a yes/no $input box.
Links that say things like "video results for", can be clicked to generate more links.

You will find the dialogs under Google Dialog on the channel,status or menubar menu.

Update This post has been trunicated to only include the dialog portion because I decided to make a new search engine with Googles API.
The original code can be found here --> http://pastebin.com/q3ASC3MA
I will post the new Google bot search A.S.A.P.

;Google Script by Ford_Lawnmower irc.mindforge.org #USA
dialog Google_Search {
  title "Google Search"
  size -1 -1 184 248
  option dbu
  edit "", 1, 8 14 130 10, autohs rich
  button "Search", 2, 139 14 37 12
  text "Enter your Search Below", 3, 56 6 73 8
  text "Results:", 4, 82 24 25 8, center
  text "", 5, 1 32 183 24, left
  text "", 6, 1 72 183 24, left
  text "", 7, 1 112 183 24, left
  text "", 8, 1 152 183 24, left
  text "", 9, 1 192 183 24, left
  link "", 10, 1 56 182 16, left
  link "", 11, 1 96 182 16
  link "", 12, 1 136 182 16
  link "", 13, 1 176 182 16
  link "", 14, 1 216 182 16
  button "Close", 15, 144 235 37 12, Cancel
  text "", 16, 0 232 137 16
  box "", 17, 0 28 184 44
  box "", 18, 0 68 184 44
  box "", 19, 0 108 184 44
  box "", 20, 0 148 184 44
  box "", 21, 0 188 184 44
  icon 22, 0 2 47 11
}
On *:Dialog:Google_Search:init:*: {
  if (!$isfile(logo_sm.gif)) { getlogo | .timer 1 2 did -g Google_Search 22 logo_sm.gif }
  else { did -g Google_Search 22 logo_sm.gif }
  google hawkee snippets FordLawnmower
}
On *:Dialog:Google_Search:Close:*: {
  unset GoogleDialog.*
  if ($sock(GoogleDialog)) { sockclose GoogleDialog }
}
On *:Dialog:Google_Search:Sclick:2: {
  if ($did(Google_Search,1).text) {
    var %count = 5
    while (%count <= 14) {
      did -r Google_Search %count
      inc %count
    }
    did -r Google_Search 16
    Google $did(Google_Search,1).text
  }
  else { return }
}
On *:Dialog:Google_Search:Sclick:10-14: {
  if ($did(Google_Search,$did).text) {
    if (http:// isin $left($did(Google_Search,$did).text,7)) {
      if ($input(Are you sure you want to load $did(Google_Search,$did).text $+ ?,y,,,)) { run $did(Google_Search,$did).text }
      else { return }
    }
    else {
      did -r Google_Search 16
      Google $did(Google_Search,$did).text    
    }
  }
  else { return }
}
alias -l Google.timeout {
  echo -gat >Connection Timed Out< Google Script
  Google.clear
}
alias -l Google.clear {
  sockclose Google*
  unset %Google*
  .timer-Google* off
  halt
}
alias -l Google {
  sockclose DialogGoogle
  sockopen DialogGoogle www.google.com 80
  svar DialogGoogle search $replace($1-,$chr(32),+)
}
on *:sockopen:DialogGoogle: {
  sockwrite -nt $sockname GET $+(/search?client=opera&rls=en&q=,$svar($sockname,search),&sourceid=opera&ie=utf-8&oe=utf-8) HTTP/1.1
  sockwrite -n $sockname Host: $sock($sockname).addr
  sockwrite -n $sockname $crlf
}
on *:sockread:DialogGoogle: {
  if ($sockerr > 0) { echo -a >Sock Error< Google | Google.clear }
  else {
    sockread  &Google
    var %count 1
    while ($svar($sockname,count) != 5 && $bintween(&Google,$+(this,$chr(44),$chr(32),'/url?q=),</a>,%count)) {
      tokenize 1 %line $strip($replace($regsubex($v1,/&amp;(.*?)>/i,$chr(1)),<b>,$chr(2),</b>,$chr(2)))
      svar $sockname count $calc($svar($sockname,count) + 1)
      did -a Google_Search $calc(4 + $svar($sockname,count)) $2
      did -a Google_Search $calc(9 + $svar($sockname,count)) $1
      inc %count
    }
  }
}
menu channel,status,menubar {
  Google Dialog:dialog $iif($dialog(Google_Search),-v,-m) Google_Search Google_Search
} 
alias -l bintween {
  var %count = 1, %mark = 0, %mark2 = 0
  while (%count <= $4) {
    if ($bfind($1, %mark2, $2).text) {
      %mark = $calc($bfind($1, %mark2, $2).text + $len($2))
      if ($bfind($1, %mark, $3).text) {
        %mark2 = $bfind($1, %mark, $3).text
      }
      else { return 0 } 
    }
    else { return 0 }
    inc %count
  }
  if ($calc(%mark2 - %mark) > 960) && ($version < 6.32) { return 0 }
  else { return $bvar($1, $iif(%mark > 0,%mark,1), $calc(%mark2 - %mark)).text }
}
alias -l httpstrip {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  return %x
}
Alias -l GetLogo {
  if ($isfile(logo_sm.gif)) { return }
  sockclose GetLogo
  sockopen GetLogo $svar($sockname,logosite) 80
  svar GetLogo logourl /images/logo_sm.gif
  svar GetLogo logopicname logo_sm.gif
}
On *:sockopen:GetLogo:{
  sockwrite -nt $sockname GET $svar($sockname,logourl) HTTP/1.0
  sockwrite -n $sockname Host: $sock($sockname).addr
  sockwrite -n $sockname $crlf  
}
On *:sockread:GetLogo:{
  if (!$sock($sockname).mark) {
    var %GetLogo.var | sockread %GetLogo.var
    if (%GetLogo.var == $null) { sockmark $sockname 1 }
  }
  else {
    sockread &logo 
    bwrite logo_sm.gif -1 -1 &logo
  }
}
alias -l Svar {
  var %sockname $1, %item $2
  if ($isid) {
    if ($regex(Svar,$sock(%sockname).mark,/ $+ %item $+ \x01([^\x01]*)/i)) return $regml(Svar,1)
  }
  else {
    tokenize 124 $2-
    var %count 1
    while (%count <= $0) {
      var %record $($+($,%count),2), %item $gettok(%record,1,32), %value $gettok(%record,2-,32)
      if (!$regex($sock(%sockname).mark,/ $+ %item $+ \x01/i)) sockmark %sockname $+($sock(%sockname).mark,$chr(1),%item,$chr(1),%value)
      else sockmark %sockname $regsubex($sock(%sockname).mark,/( $+ %item $+ \x01[^\x01]*)/i,$+(%item,$chr(1),%value))
      inc %count
    }
  }
}

Comments

Sign in to comment.
FordLawnmower   -  Aug 07, 2010

Sorry Heartbroken :( This script is broken.
I'll fix it a little later this weekend.
I have also removed the bot search from this script and replaced it with this one -->> http://www.hawkee.com/snippet/7465/ <<-- A much better search engine.

 Respond  
Heartbroken   -  Aug 07, 2010

last couple of weeks i have a problem with this :/
Dunno why cus it works realy great before and i appreciated for this to you Ford_Lawnmower realy super scripting.:)

but now it didn't work ..when i try to make a !google search bot shows nuthin when i re-type it noticed me -> - Google in use!!
so i check into bot .on bot's status window wrotes ->

[23:54:59] -> -emule- http://www.google.com.tr/

  • /sockwrite: 'Google#mychanname' not connected (line 95, script31.mrc)

    so i unload -re-load many times and i try to check to wtf is .

i found -> nuthin :P

so pls help meh to find whats happen .huh ?
thnx..

 Respond  
SnoooP   -  Mar 19, 2010

thanks alot :)

 Respond  
FordLawnmower   -  Mar 19, 2010

@SnoooP - You can do a find and replace from the script editor
[find] -- >> ($eval($+(%,$sockname,.count),2) >= 6)
[replace} -> ($eval($+(%,$sockname,.count),2) >= 4)

Choose "replace all" and replace all 3 lines. This will set the results to 3.

 Respond  
SnoooP   -  Mar 19, 2010

FL: How would I go about changing the default output settings, when I use !google it currently gives me 5 results, how would I lower that too, say 3 for example?

 Respond  
FordLawnmower   -  Dec 26, 2009

Your welcome jasonh :) I'm glad you found one that works for you.
Laughing at the book in your avatar :D

 Respond  
jasonh   -  Dec 26, 2009

thanks for the script, it works. i modified it so it msg'd the person instead.
less annoying in a channel that way sometimes

 Respond  
FordLawnmower   -  Aug 01, 2009

It should work just like google Xaric. Although I don't use boolean expressions much.
Thanks for the like/rating Xaric :)
Thanks eyiezinc :)

 Respond  
Xaric   -  Aug 01, 2009

will this work with inurl insite "blah" + and - parameters?

10/10 +like

 Respond  
eyiezinc   -  May 07, 2009

its ok now FordLawnmower.its only got error when i`m using mirc ver 6.17.I like it nice work FordLawnmower.9/10

 Respond  
FordLawnmower   -  May 06, 2009

Your welcome greenlanter420 :)

 Respond  
greenlanter420   -  May 06, 2009

thanks nice script the bot search replaced my outdated google script with this keep up the good work 9/10

 Respond  
FordLawnmower   -  May 06, 2009

@greenlanter420 -- You can do a find and replace from the script editor
[find] -- >> ($eval($+(%,$sockname,.count),2) >= 6)
[replace} -> ($eval($+(%,$sockname,.count),2) >= 4)

Choose replace all and replace all 3 lines. This will set the results to 3.

 Respond  
FordLawnmower   -  May 06, 2009

Thanks PATX :)
@eyiezinc Can you elaborate on how you got that error, what your search was, etc. Also your version of mIRC. That error will only be produced with a call to $bvar for more than 960 characters in versions of mirc older than 6.32.
I've tested this script repeatedly with mIRC 6.21, with no problems other than the occasional inconsistency, caused by Youtube link blocks ;/
Any information you can give me eyiezinc, will be appreciated :)
It is my intention to make this script work equally as well with older versions of mirc.

I found the bug, reproduced it and added a fix. I got the same error from the default search with mIRC 6.30. Added this line.

if ($calc(%mark2 - %mark) > 960) && ($version < 6.32) { return 0 }

A line over 960 would never match a search result so I just nulled it with Zero :)

 Respond  
greenlanter420   -  May 06, 2009

how can I set the amount of replies for the channel functions so it only does like the top 3 instead of 5

 Respond  
PATX   -  May 06, 2009

i love it. as i do all of your snippets.

 Respond  
eyiezinc   -  May 06, 2009

i got this error ->>> * String too long: $bvar (line 216, script2.url).anyway good idea Ford_Lawnmower.

 Respond  
FordLawnmower   -  May 05, 2009

Thanks p0d :)

 Respond  
p0d   -  May 05, 2009

I like it nice work Ford =)

 Respond  
FordLawnmower   -  May 05, 2009

Yea, slacker, the dialogs are a bit useless but if I didn't make any then someone would complain about that so... I use them though. Much faster than a browser search.

 Respond  
Kirby   -  May 05, 2009

Ah yes, the Twitter.

 Respond  
FordLawnmower   -  May 05, 2009

Thanks kirby. If you are talking about the popup menu, it's the same one you suggested when I first started posting here. I don't change much ;/
Thanks Aucun50 :)

 Respond  
slacker   -  May 05, 2009

abit usesless id rather open up the net but w/e

 Respond  
Aucun50   -  May 05, 2009

Looks great as all your dialogs do, the scripting is nice and neat was looking though it and didn't understand half of it :)

 Respond  
Kirby   -  May 05, 2009

Works fine, nice to see use of binary variables.

But that menu looks familiar...

 Respond  
FordLawnmower   -  May 05, 2009

Yep, I parsed most of the Big Link groups like that out to get more results.
I tried to anyway. Google's pages are crazy complicated to parse.

 Respond  
Kirby   -  May 05, 2009

When I looked up Hawkee using the dialog, it didn't return the first item.
What should be returning as the first item is: > Hawkee Technology Social Network
mIRC script resource site with scripting tips, articles and downloads.
http://www.hawkee.com/

 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.