GoogleTool
Posted by unkNown
Monday, October 31, 2005
Description: All of the functionality of Google and more in a fast dialog'd interface.
GoogleTool is an all-in-one Google search solution. You can search or access any link on the Google homepage directly from the dialog. You can use the alias to submit a search string to Google without using the dialog box. There is a built in !Google bot for searches by people in your channel (by MEiJ) with a quick interface built into GoogleTool.
SCREENSHOT: http://unknown.staticservers.com/mirc/googlepic.gif
Changelog:
11/7/05 - Changed urls to open in a new window instead of one already open.
GoogleTool is an all-in-one Google search solution. You can search or access any link on the Google homepage directly from the dialog. You can use the alias to submit a search string to Google without using the dialog box. There is a built in !Google bot for searches by people in your channel (by MEiJ) with a quick interface built into GoogleTool.
SCREENSHOT: http://unknown.staticservers.com/mirc/googlepic.gif
Changelog:
11/7/05 - Changed urls to open in a new window instead of one already open.
; GoogleTool v1.0
;
; by unkNown
; unknown@staticservers.com
; #staticservers | #counter-strike on GameSurge.net IRC
;
; Type /google to open the googlesearch dialog box.
; You can also type /google <search string> and it will bypass the dialog and search directly.
; Similarly, you can type /googleimg <search string> and it will search images directly.
; This script incorporates the following script for bot functionality:
;
; !Google Search v0.4
; by: MEiJ
; email: meij101@hotmail.com
;
; No sense re-inventing a very good wheel.
; This script downloads google.bmp one time only
; from my webspace for use as the background in the dialog.
; Just an FYI.
dialog googlesearch {
size 300 200 500 300
title "GoogleTool"
button "Personalized Home", 1, 400 10 100 15
icon 2, 0 0 500 300, " $+ $mircdir $+ google.bmp $+ ", noborder
edit "", 3, 102 175 300 25, autohs limit 255
button "Google Search", 4, 132 200 120 25
button "I'm Feeling Lucky", 5, 252 200 120 25
button "Web", 6, 80 155 50 15
button "Images", 7, 130 155 50 15
button "Groups", 8, 180 155 50 15
button "News", 9, 230 155 50 15
button "Froogle", 10, 280 155 50 15
button "Local", 11, 330 155 50 15
button "More »", 12, 380 155 50 15
button "Advanced Search", 13, 405 190 95 15
button "Preferences", 14, 405 205 95 15
button "Language Tools", 15, 405 220 95 15
button "Search Images", 18, 190 200 120 25
text "Google bot:", 16, 2 230 58 15
edit "", 19, 5 275 60 20, disabled
button "enable bot", 20, 68 250 60 20
button "disable bot", 21, 5 250 60 20
button "Settings", 24, 68 275 60 20
button "Close GoogleTool", 99, 365 270 130 25, ok
}
dialog google.alert {
size -1 -1 400 100
title "Alert"
text %google.alertmsg, 70, 50 35 300 30, center
button "OK", 71, 150 75 100 20, ok
}
on 1:dialog:googlesearch:init:0: {
did -b googlesearch 6
did -bh googlesearch 18
did -t googlesearch 4
did -f googlesearch 3
if (%google.bot.status == $null) { set %google.bot.status stopped }
did -o googlesearch 19 1 %google.bot.status
if (%google.bot.status == stopped) { did -b googlesearch 21 | did -e googlesearch 20 }
if (%google.bot.status == running) { did -b googlesearch 20 | did -e googlesearch 21 }
}
on 1:dialog:google.alert:init:0: { .timergoogle.alertto -o 1 2 dialog -k google.alert }
on 1:dialog:googlesearch:sclick:*: {
if ($did == 1) { url -an http://www.google.com/url?sa=p&pref=ig&pval=2&q=http://www.google.com/ig | did -f googlesearch 3 }
if ($did == 4) { url -an http://www.google.com/search?hl=en&q= $+ $replace($did(googlesearch,3).text,$chr(32),+) | did -r googlesearch 3 | did -f googlesearch 3 }
if ($did == 5) { url -an http://www.google.com/search?hl=en&q= $+ $replace($did(googlesearch,3).text,$chr(32),+) $+ &btnI $+ $chr(37) $+ 27m+Feeling+Lucky | did -r googlesearch 3 | did -f googlesearch 3 }
if ($did == 6) {
did -bh googlesearch 18
did -e googlesearch 7
did -vet googlesearch 4
did -ev googlesearch 5
did -b googlesearch 6
did -f googlesearch 3
}
if ($did == 7) {
did -bh googlesearch 4
did -bh googlesearch 5
did -e googlesearch 6
did -b googlesearch 7
did -vet googlesearch 18
did -f googlesearch 3
}
if ($did == 8) { url -an http://groups.google.com/grphp?hl=en&tab=wg&q= | did -f googlesearch 3 }
if ($did == 9) { url -an http://news.google.com/nwshp?hl=en&tab=wn | did -f googlesearch 3 }
if ($did == 10) { url -an http://froogle.google.com/frghp?hl=en&tab=wf | did -f googlesearch 3 }
if ($did == 11) { url -an http://www.google.com/lochp?hl=en&tab=wl | did -f googlesearch 3 }
if ($did == 12) { url -an http://www.google.com/intl/en/options | did -f googlesearch 3 }
if ($did == 13) { url -an http://www.google.com/advanced_search?hl=en | did -f googlesearch 3 }
if ($did == 14) { url -an http://www.google.com/preferences?hl=en | did -f googlesearch 3 }
if ($did == 15) { url -an http://www.google.com/language_tools?hl=en | did -f googlesearch 3 }
if ($did == 18) { url -an http://images.google.com/images?svnum=10&hl=en&lr=&q= $+ $replace($did(googlesearch,3).text,$chr(32),+) $+ &btnG=Search | did -fr googlesearch 3 }
if ($did == 20) { set %google.bot.status running | did -o googlesearch 19 1 %google.bot.status | did -e googlesearch 21 | did -b googlesearch 20 | did -f googlesearch 3 | g.ini active on }
if ($did == 21) { set %google.bot.status stopped | did -o googlesearch 19 1 %google.bot.status | did -e googlesearch 20 | did -b googlesearch 21 | did -f googlesearch 3 | g.ini active off }
if ($did == 24) { googlesettings }
if ($did == 99) { unset %google.* }
}
alias opend { $iif($dialog($1),dialog -v $1 $1,dialog -md $1 $1) }
alias google {
if ($1 != $null) { url -an http://www.google.com/search?hl=en&q= $+ $replace($1-,$chr(32),+) | halt }
if ($sock(googlecon)) sockclose googlecon
if ($file(google.bmp) == $null) { google.alert Downloading google.bmp (first load only) | sockopen googlecon unknown.staticservers.com 80 | .timergetgoogleimgto -o 1 2 getgoogleimgto | halt }
getgoogleimgto
}
alias googleimg { url -an http://images.google.com/images?svnum=10&hl=en&lr=&q= $+ $1-,$chr(32),+) $+ &btnG=Search }
alias getgoogleimgto { if ($sock(googlecon)) sockclose googlecon | opend googlesearch }
alias google.alert { set %google.alertmsg $1- | opend google.alert }
on *:sockopen:googlecon: { sockwrite -n googlecon GET http://unknown.staticservers.com/google.bmp HTTP/1.1 | sockwrite -n googlecon Host: $ip $+ $crlf $+ $crlf | sockmark googlecon google.com }
on *:sockread:googlecon: {
if ($gettok($sock($sockname).mark,2,32)) { sockread &b | while ($sockbr) { bwrite google.bmp -1 -1 &b | sockread &b }
if ($sock($sockname).rcvd >= $gettok($sock($sockname).mark,1,32)) { sockclose $sockname } }
else { var %c | sockread %c | if (-Length: isin %c) sockmark $sockname $gettok(%c,2,32) | if (!%c) sockmark $sockname $sock($sockname).mark 1 }
}
;##############################
;#!Google Search v0.4
;# by: MEiJ
;# email: meij101@hotmail.com
;##############################
;###
;Events
;###########
;on *:LOAD: { .echo -ta [^B]!Google Search[^B] v0.4 successfully loaded, type [^B]/google[^B] to set it up. }
;on *:UNLOAD: { .echo -ta [^B]!Google Search[^B] v0.4 successfully unloaded. }
on *:TEXT:*:#: {
if ($1 == $g.ini(trigger)) && ($g.check($chan,$iif($network,$network,$server))) && ($g.ini(active) == on) {
if (!$2) {
g.add $nick [^B]!Google Search[^B] v0.4 by MEiJ <meij101@hotmail.com> EFnet/NewNet, #sCRiPTs @ NewNet
g.add $nick Useage: $g.ini(trigger) [-dn] <search> eg: $g.ini(trigger) -dn10 mIRC
g.add $nick Flags: -nN will return up to N results, -d will return results with descriptions, -dnN will return N results with descriptions
}
elseif ($2) && ($left($2,1) != $chr(45)) {
var %s = $+(g.,$md5($+($ticks,$ctime,$nick)))
sockopen %s google.com 80
sockmark %s $+($g.mode($nick,$chan),~,-,~,1,~,$replace($2-,$chr(32),$chr(43)))
}
elseif ($3) && ($left($2,1) == $chr(45)) {
var %s = $+(g.,$md5($+($ticks,$ctime,$nick)))
if ($left($2,3) == -dn) { sockopen %s google.com 80 | sockmark %s $+($g.mode($nick,$chan),~,d~,$right($2,$calc($len($2) - 3)),~,$replace($3-,$chr(32),$chr(43))) }
elseif ($2 == -d) { sockopen %s google.com 80 | sockmark %s $+($g.mode($nick,$chan),~,d,~,1,~,$replace($3-,$chr(32),$chr(43))) }
elseif ($left($2,2) == -n) { sockopen %s google.com 80 | sockmark %s $+($g.mode($nick,$chan),~,-,~,$right($2,$calc($len($2) - 2)),~,$replace($3-,$chr(32),$chr(43))) }
}
}
}
on *:SOCKOPEN:g.*: {
sockwrite -nt $sockname GET $+(/search?hl=en&ie=UTF-8&oe=UTF-8&q=,$gettok($sock($sockname).mark,4-,126),&num=,$iif($gettok($sock($sockname).mark,3,126) > 10,10,$gettok($sock($sockname).mark,3,126))) HTTP/1.0
sockwrite -nt $sockname Accept-Language: en-us
sockwrite -nt $sockname User-Agent: Mozilla/??
sockwrite -nt $sockname Host: $iif($ip,$ip,127.0.0.1)
sockwrite -nt $sockname Connection: Keep-Alive
sockwrite -t $sockname $str($crlf,2)
}
on *:SOCKREAD:g.*: {
if ($sockerr > 0) return
:nextread
sockread -n &v
if ($sockbr == 0) sockread &v
var %i 1
while (%i <= $bvar(&v,0)) {
tokenize 32 $bvar(&v,%i,800).text
if (% [ $+ [ $sockname ] $+ ] .u) { tokenize 32 $+(% [ $+ [ $sockname ] $+ ] .u,$1-) | unset % [ $+ [ $sockname ] $+ ] .u }
if (</html> isin $1-) { g.close $sockname }
elseif ($left($1,1) != <) && (% [ $+ [ $sockname ] $+ ] .d) {
set % [ $+ [ $sockname ] $+ ] .d % [ $+ [ $sockname ] $+ ] .d $gettok($remove($replace($1-,<b>,[^B],</b>,[^B]),<br>),-1,62)
if ($right($1-,4) != <br>) { if (d isin $gettok($sock($sockname).mark,2,126)) { g.add $gettok($sock($sockname).mark,1,126) Desc: $g.replace(% [ $+ [ $sockname ] $+ ] .d) } | unset % [ $+ [ $sockname ] $+ ] .d }
}
elseif (p class=g> isin $1-) {
if (% [ $+ [ $sockname ] $+ ] .u) { var %j 1 } | else { var %j = $g.bsearch($1-) }
var %l 1
while (%l <= $gettok(%j,0,44)) {
var %z = $gettok($1-,$+($gettok(%j,%l,44),-),60)
if (</a> !isin %z) { set % [ $+ [ $sockname ] $+ ] .u %z }
elseif ($right(%z,4) == <br>) { set % [ $+ [ $sockname ] $+ ] .d $gettok($remove($replace(%z,<b>,[^B],</b>,[^B]),<br>),-1,62) }
elseif ($right(%z,4) != <br>) {
if ($gettok($g.bsearch($1-),0,44) != 1) { set % [ $+ [ $sockname ] $+ ] .u %z }
elseif (<font size=-1 == $gettok($remove($replace(%z,<b>,[^B],</b>,[^B]),<br>),-2,62)) { var %t = $gettok($remove($replace(%z,<b>,[^B],</b>,[^B]),<br>),-1,62) }
elseif ($count(%z,$chr(60)) != $count(%z,$chr(62))) && ($right(%z,1) != >) { set % [ $+ [ $sockname ] $+ ] .u %z }
elseif (<font size=-1> !isin %z) { set % [ $+ [ $sockname ] $+ ] .u %z }
}
if (</a> isin %z) && (!% [ $+ [ $sockname ] $+ ] .u) {
g.add $gettok($sock($sockname).mark,1,126) Result: $g.replace($+([^B],$gettok($gettok($remove(%z,<b>,</b>),3,62),1,60),[^B])) - $chr(91) $remove($gettok($gettok(%z,2,62),1,60),a href=) $chr(93)
if (%t) && (d isin $gettok($sock($sockname).mark,2,126)) { g.add $gettok($sock($sockname).mark,1,126) Desc: $g.replace(%t) }
}
inc %l
}
}
inc %i 800
}
}
;###
;Aliases
;###########
alias googlesettings { dialog -m google g.main }
alias g.replace { return $replace($1-,>,>,<,<,&,&) }
alias g.bsearch { var %i 1 | while ($gettok($1-,%i,60)) { if ($gettok($gettok($1-,%i,60),1,62) == $+(p class=g)) { var %j = $iif(%j,$+(%j,$chr(44),%i),%i) } | inc %i } | return $iif(%i == 1,0,%j) }
alias g.mode { if ($g.ini(mode) == chan) { return $2 } | elseif ($g.ini(mode) == msg) { return $+(.,$1) } | else { return $1 } }
alias g.check { if ($g.ini(all) == on) { return $true } | var %n = $g.ini(. [ $+ [ $2 ] ]),%i 1 | while (%i <= $gettok(%n,0,44)) { if ($1 == $gettok(%n,%i,44)) { return $true } | inc %i } }
alias g.cmb.a { var %i 1 | while (%i <= $gettok($g.ini($3),0,44)) { did -a $1 $2 $gettok($g.ini($3),%i,44) | inc %i } }
alias g.cmb.g { var %i 1 | while ($did($1,$2,%i).text) { var %j = $+($iif(%j,$+(%j,$chr(44))),$did($1,$2,%i).text) | inc %i } | return %j }
alias g.ini { if ($isid) { return $readini($scriptdir!google.set,n,google,$1) } | elseif ($2) { writeini $+(",$scriptdir,!google.set,") google $1 $2- } | else { remini $+(",$scriptdir,!google.set,") google $1 } }
alias g.close { sockclose $1 | unset % [ $+ [ $1 ] $+ ] * }
alias g.add { set %queue.g. [ $+ [ $calc($g.info(0) + 1) ] ] $1- | if (!$timer(g)) { .timerg 0 2 .g.say } }
alias g.info { if ($1 isnum) { if (%queue.g. [ $+ [ $1 ] ]) && ($1 > 0) { return %queue.g. [ $+ [ $1 ] ] } | elseif ($1 == 0) { return $var(%queue.g.*) } } }
alias g.say {
var %i 1
if (%queue.g. [ $+ [ %i ] ]) {
tokenize 32 %queue.g. [ $+ [ %i ] ]
if ($left($1,1) == $chr(35)) { .msg $1- } | elseif ($left($1,1) == $chr(46)) { .msg $remove($1,.) $2- } | else { .notice $1- }
unset %queue.g. [ $+ [ %i ] ] | var %h $calc(%i + 1)
while (%queue.g. [ $+ [ %h ] ]) { set %queue.g. [ $+ [ $calc(%h - 1) ] ] %queue.g. [ $+ [ %h ] ] | unset %queue.g. [ $+ [ %h ] ] | inc %h }
}
else { .timerg off }
}
;###
;Menus
;###########
menu menubar {
GoogleTool:google
}
;###
;Dialogs
;###########
dialog g.main {
title "!Google Search v0.4 - Setup"
size -1 -1 154 120
option dbu
combo 1, 0 9 75 80, size
combo 2, 78 9 75 80, size
button "Done", 3, 59 111 37 8, ok cancel
text "Mode:", 4, 1 100 16 8
combo 5, 17 98 58 39, size drop
text "Trigger:", 6, 79 100 20 8
edit "", 7, 99 98 54 11
button "Add", 8, 0 88 16 9
button "Rem", 9, 17 88 16 9
button "Add", 10, 78 88 16 9
button "Rem", 11, 95 88 16 9
check "All", 12, 136 88 17 10
text "Networks", 13, 25 1 24 7
text "Channels", 14, 103 1 23 7
button "Proxy Settings", 15, 114 111 39 8, disable
check "Bot Active", 16, 1 110 36 10
}
on *:DIALOG:google:*:*: {
if ($devent == init) {
did -ra $dname 7 $iif($g.ini(trigger),$g.ini(trigger),!google)
if ($g.ini(active) == on) || (!$g.ini(active)) { did -c $dname 16 } | else { did -b $dname 1,2,5,7,12,8,9,10,11 }
if ($g.ini(all) == on) || (!$g.ini(all)) { did -c $dname 12 | did -b $dname 1,2,8,9,10,11 }
did -a $dname 5 Channel | did -a $dname 5 Notice | did -a $dname 5 Private Message
if ($g.ini(mode) == notice) { did -c $dname 5 2 } | elseif ($g.ini(mode) == msg) { did -c $dname 5 3 } | else { did -c $dname 5 1 }
g.cmb.a $dname 1 networks
if ($g.ini(networks)) { did -r $dname 2 | g.cmb.a $dname 2 $+(.,$did($dname,1,1)) | did -c $dname 1 1 }
}
if ($devent == sclick) {
if ($did == 12) { if ($did($dname,12).state == 1) { g.ini all on | did -b $dname 1,2,8,9,10,11 } | else { g.ini all off | did -e $dname 1,2,8,9,10,11 } }
if ($did == 16) { if ($did($dname,16).state == 1) { g.ini active on | did -e $dname 1,2,5,7,12,8,9,10,11 } | else { g.ini active off | did -b $dname 1,2,5,7,12,8,9,10,11 } }
if ($did == 5) { if ($did($dname,5,1).seltext == Channel) { g.ini mode chan } | elseif ($did($dname,5).seltext == Notice) { g.ini mode notice } | else { g.ini mode msg } }
if ($did == 1) && ($did($dname,1).sel isnum) { did -r $dname 2 | g.cmb.a $dname 2 $+(.,$did($dname,1,$did($dname,1).sel)) }
if ($did == 8) && (!$did($dname,1).sel) && ($did($dname,1).text) { did -a $dname 1 $did($dname,1).text | did -c $dname 1 $did($dname,1).lines | g.ini networks $g.cmb.g($dname,1) | did -r $dname 2 | g.cmb.a $dname 2 $g.ini($did($dname,1,$did($dname,1).lines)) }
if ($did == 9) && ($did($dname,1).sel isnum) { did -d $dname 1 $did($dname,1).sel | if ($did($dname,1).lines == 0) { g.ini networks } | else { g.ini networks $g.cmb.g($dname,1) } | did -r $dname 2 }
if ($did == 10) && (!$did($dname,2).sel) && ($did($dname,2).text) && ($did($dname,1).seltext) { did -a $dname 2 $iif($left($did($dname,2).text,1) != $chr(35),$+($chr(35),$did($dname,2).text),$did($dname,2).text) | did -c $dname 2 $did($dname,2).lines | g.ini $+(.,$did($dname,1).seltext) $g.cmb.g($dname,2) }
if ($did == 11) && ($did($dname,2).sel isnum) { did -d $dname 2 $did($dname,2).sel | if ($did($dname,2).lines == 0) { g.ini $+(.,$did($dname,1).seltext) } | else { g.ini $+(.,$did($dname,1).seltext) $g.cmb.g($dname,2) } }
}
if ($devent == close) {
if ($did($dname,7).text) { g.ini trigger $did($dname,7).text }
if ($did($dname,12).state == 1) { g.ini all on } | else { g.ini all off }
if ($did($dname,16).state == 1) { g.ini active on } | else { g.ini active off }
}
}