*First: Yes I know I already had a google search post. It has been trunicated to just a dialog search because I felt the dialog was slowing down the bot search and vise-versa. This script was written from scratch to take advantage of some new features of googles api.
*Now: This script will do web, local, video, news, books, images, and patent searches.
Triggers are as follows:
(!trigger for notice user - @trigger for message channel.)
!google = web search
!glocal = local search
!gvideo = video search
!gnews = news search
!gbooks = book search
!gimages = image search
!gpatent = patent search
!ghelp = trigger/syntax help
/google alias flags are as follows:
/google -local = local search
/google -video = video search
/google -news = news search
/google -books = book search
/google -images = image search
/google -patent = patent search
Getting the script running:
First: Copy this code, paste it into a new remote and save it with a unique filename.
Second: Review the Simple Setup portion of the script and make any changes to the script you feel necessary.
Third: Right click the channel or status, scroll to Advanced Google and turn on the script.
Last: Go to each channel that you want to run this script in and type +google .(you must have ops or higher to activate the script in a channel)(Note -google will deactivate the script in a channel.)
Example Output:
20:06:14 @gnews final 4
20:06:15 <Mind|Force> Searching Google........
20:06:16 <Mind|Force> Google Butler did it beats KSU 63-56 to make Final Four http://tinyurl.com/yekmz79
20:06:17 <Mind|Force> Google Butler Goes Home to Indianapolis for Final Four http://tinyurl.com/yd5f2e9
20:06:17 <Mind|Force> Google But on Saturday Butler earned another title: Final Four team. The fifth-seeded Bulldogs defeated second-seeded Kansas State 63-56 in Saturday's West ... http://tinyurl.com/yak2grf
20:06:19 <Mind|Force> Google Butler Beats Kansas State Is First Team to Reach Final Four http://tinyurl.com/ybesm4b
;Advanced Google Search by Ford_Lawnmower irc.Geekshed.net #Script-Help
alias -l GetAdvancedGoogle {
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;Start of Simple Setup;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Change %MaxResults(below) to get a different number of results.(must be a number between 1 and 9)
var %MaxResults 4
;;Change %GoogleLogo(below) to change the logo at the start of each line.(You cannot remove this, only change)
var %GoogleLogo 12G04o08o14g09l04e
;;Change %NameColor(below) to change the color of the results description.(You cannot remove this, only change)
var %NameColor 04
;;Change %LinkColor(below) to change the color of the results link.(You cannot remove this, only change)
var %LinkColor
;;Change %UseTinyURL(below) if you don't want links converted to tinyurl. Valid numbers are: 1 for convert and 0 for don't convert.
var %UseTinyURL 1
;;Change %CountryCode(below) if you want your searches in a different language. Look here if you don't know your code -->> http://xml.coverpages.org/country3166.html
var %CountryCode en
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;Do not leave any of these variables blank!!!;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;End of Setup;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$1-2 Searching Google........
var %sockname $+(AdvancedGoogle,$network,$2,$ticks)
sockopen %sockname ajax.googleapis.com 80
sockmark %sockname $1-2 %MaxResults %GoogleLogo %NameColor %LinkColor %UseTinyURL $+(/ajax/services/search/,$3,?v=1.0&rsz=large&q=,$urlencode($4-),&ql=,%CountryCode,&lr=lang_,%CountryCode)
}
menu Channel,Status {
.$iif($group(#AdvancedGoogle) == On,$style(1)) AdvancedGoogle Trigger
..$iif($group(#AdvancedGoogle) == On,$style(2)) On: .enable #AdvancedGoogle
..$iif($group(#AdvancedGoogle) == Off,$style(2)) Off: .disable #AdvancedGoogle
}
#AdvancedGoogle on
On $*:Text:/^(\+|-|!|@)G(oogle|local|video|news|books|images|patent|help|site).*/Si:#: {
var %action $regml(1), %type $regml(2)
if (%action isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
if (%action == +) {
if ($istok(%AdvancedGoogleChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the AdvancedGoogle script }
else {
.enable #AdvancedGoogle
Set %AdvancedGoogleChanList $addtok(%AdvancedGoogleChanList,$+($network,$chan),32)
.msg $chan $nick has activated the AdvancedGoogle script for $chan .
}
}
else {
if (!$istok(%AdvancedGoogleChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the AdvancedGoogle script }
else {
Set %AdvancedGoogleChanList $remtok(%AdvancedGoogleChanList,$+($network,$chan),1,32)
.msg $chan $nick has deactivated the AdvancedGoogle script for $chan .
}
}
}
elseif (!$timer($+(AdvancedGoogle,$network,$nick))) && ($istok(%AdvancedGoogleChanList,$+($network,$chan),32)) {
.timer $+ $+(AdvancedGoogle,$network,$nick) 1 6 noop
var %method $iif(%action == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%|\+)/),.msg $chan,.notice $nick))
if (%type == help) || (!$2) { AdvancedGoogleHelp %method %action }
elseif (%type == site) { GetAdvancedGoogle %method $replace(%type,oogle,web,site,web) $+(+site:,$2-) }
else { GetAdvancedGoogle %method $replace(%type,oogle,web) $2- }
}
}
#AdvancedGoogle end
alias Google {
if ($istok(-local -video -news -books -images -patent,$1,32)) { GetAdvancedGoogle echo -a $mid($1,2) $2- }
else { GetAdvancedGoogle echo -a web $1- }
}
On *:sockopen:AdvancedGoogle*: {
if (!$sockerr) {
hmake $sockname
hadd $sockname max $gettok($sock($sockname).mark,3,32)
hadd $sockname urlcount 1
hadd $sockname itemcount 1
sockwrite -nt $sockname GET $gettok($sock($sockname).mark,8,32) HTTP/1.1
sockwrite -n $sockname Host: ajax.googleapis.com
sockwrite -n $sockname User-Agent: Opera 9.6
sockwrite -n $sockname $crlf
}
else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
On *:sockread:AdvancedGoogle*: {
if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
else {
sockread &AdvancedGoogle
var %count 1
while ($hget($sockname,max) >= $hget($sockname,urlcount)) && ($bintween(&AdvancedGoogle,"url":",",%count)) {
hadd $sockname $+(url,$hget($sockname,urlcount)) $dehex($ifmatch)
hinc $sockname urlcount
inc %count
}
%count = 1
while ($hget($sockname,max) >= $hget($sockname,itemcount)) && ($bintween(&AdvancedGoogle,"content":",",%count) || $bintween(&AdvancedGoogle,"titlenoformatting":",",%count)) {
hadd $sockname $+(item,$hget($sockname,itemcount)) $replace($fix&#($dehex($ifmatch)),<b>,,</b>,)
hinc $sockname itemcount
inc %count
}
if ($matchtok($hget($sockname,itemcount) $hget($sockname,urlcount),$hget($sockname,max),0,32) > 1) || ($bintween(&AdvancedGoogle,"responseStatus",200,1)) { clearhash }
}
}
On *:sockclose:AdvancedGoogle*: { hfree $+(AdvancedGoogle,$sockname) }
alias -l clearhash {
tokenize 32 $sock($sockname).mark
var %start 1, %matches $hfind($sockname,item[1-9],0,r)
if (%matches) {
while (%start <= %matches) {
if ($7) { Tiny $1-2 $hget($sockname,$+(url,%start)) $4 $+($5,$hget($sockname,$+(item,%start))) $+(,$6,$hget($sockname,$+(url,%start)),) }
else { $1-2 $4 $+($5,$hget($sockname,$+(item,%start))) $+(,$6,$hget($sockname,$+(url,%start)),) }
inc %start
}
}
else { $1-2 $4 Sorry, No results were found for your search. If you are having trouble type !ghelp }
hfree $sockname
sockclose $sockname
return
}
alias -l AdvancedGoogleHelp {
$1-2 Google Triggers are: $+($3,google) $+($3,glocal) $+($3,gvideo) $+($3,gnews) $+($3,gbooks) $+($3,gimages) $+($3,gpatent)
$1-2 Google Searches must include at least one search word: Example $+($3,gnews) Obama
}
alias -l urlencode return $regsubex($1-,/([^a-z0-9])/ig,% $+ $base($asc(\t),10,16,2))
alias -l fix&# { return $replace($regsubex($1-,/&#([0-9]{2});/g,$chr(\t)),",",&,&,·,·,\n,$chr(32)) }
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
}
return $bvar($1, $iif(%mark > 0,%mark,1), $calc(%mark2 - %mark)).text
}
alias -l dehex { return $regsubex($1-,/\\u([a-f0-9]{4})|\%([a-f0-9]{2})/gi,$chr($base(\t,16,10))) }
alias -l Tiny {
var %sockname $+(GTinyUrl,$network,$ticks,$r(1,$ticks))
sockopen %sockname tinyurl.com 80
sockmark %sockname $1-2 $+(/api-create.php?url=,$3) $3 $4-
}
On *:sockopen:GTinyUrl*: {
if (!$sockerr) {
sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
sockwrite -n $sockname Host: tinyurl.com
sockwrite -n $sockname $crlf
}
else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
On *:sockread:GTinyUrl*: {
if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
else {
sockread -f &tiny | var %tiny $bvar(&tiny,1-).text
if ($regex(%tiny,(http://[^\s]*))) {
tokenize 32 $sock($sockname).mark
$1-2 $replace($5-,$4,$regml(1))
sockclose $sockname
return
}
}
}
On *:Unload: { unset %AdvancedGoogleChanList* | hfree -w AdvancedGoogle* }
I had create an addon Google-Search you can download it via this manager
More informations here: http://hawkee.com/snippet/17050/
I still have this working 100% ^West. I don't see any problems scanning the code here. Pls. try loading the code from here to make sure: http://scriptbin.net/view/2bc2b6d3
If this works for you I will update the code here.
Well i try it from your url but still not working man, had an mini-test to on my currently bot i set a timer for msg the command: /timer 1 10 msg #test_chan !google IRC well after this i gone to my bot and using /socklist command to see if the add-on opens the socks the socks have been opened have a look into the socks. ALSO i have try it to an Clean mIRC with not any addons,dlls,aliases and still have this problem, stucking into the Searching.. notice!
SOCKS:
GTinyUrlIRC9302222859544702 tinyurl.com:80 tcp connecting
GTinyUrlIRC9302222885988378 tinyurl.com:80 tcp connecting
GTinyUrlIRC9302222810312678 tinyurl.com:80 tcp connecting
GTinyUrlIRC9302222819507000 tinyurl.com:80 tcp connecting
Also with the /google IRC command the /socklist result was:
GTinyUrlIRC9373864788866108 tinyurl.com:80 (195.66.135.249) tcp active (on: .146.243.84 57084)
GTinyUrlIRC9373864711705585 tinyurl.com:80 (195.66.135.249) tcp active (on: .146.243.84 57085)
NOTE: i am using 7.32 mIRC version!!!!!
It sounds like you have an issue with tinyurl. Perhaps they are blocking you for some reason.
Try changing the var UseTinyURL to 0
;;Change %UseTinyURL(below) if you don't want links converted to tinyurl. Valid numbers are: 1 for convert and 0 for don't convert.
var %UseTinyURL 1
If this works , I can make an edit for you that uses a different link shortener. I have made a few of these because tinyurl is blocked by some countries.
I found an way to work the tinyurl using %UseTinyURL 1 i have just edit an other code and thinking to change and yours so i try and find an way with this code mine is working , check it and if it is working and with yours so you can replace it.
On :sockread:GTinyUrl: {
if ($sockerr) { sockclose $sockname | return }
else {
sockread -f &tiny | var %tiny $bvar(&tiny,1-).text
var %tiny2 = $remove($gettok(%tiny,$numtok(%tiny,32),32),close,$crlf)
if (http://* iswm %tiny2) {
tokenize 32 $sock($sockname).mark
$1-2 $replace($5-,$4,%tiny2)
sockclose $sockname
return
}
}
}
awesome script and I've used on it on my bot for awhile, just a heads up that something has changed in the tinyurl site causing the script to give links to the tinyurl preview link and not the actual link, screenshot here-> http://puu.sh/3ttej.png
@FordLawnmower I finally got to the bottom of this issue. I had hacked the JavaScript to remove the br's because I pass comments through a parser that calls nl2br. This was adding br's to each line of the code within comments, so I explicitly removed them from the code snippet. The side effect was it was also removing br's that should have been in the code. I came up with a solution to run nl2br on text outside the code tags. I wrote this function to solve it, http://www.hawkee.com/snippet/9705/
[11:06am] <~Stewie> @Google google
[11:06am] <&thunderbolt> Searching Google........
[11:06am] <&thunderbolt> Google Find local businesses, view maps and get driving directions in Google Maps. http://tinyurl.com/6z3f3
[11:06am] <&thunderbolt> Google Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking ... http://tinyurl.com/161
[11:06am] <&thunderbolt> Google Google's free online language translation service instantly translates text and web pages. This translator supports: English, Afrikaans, Albanian, Arabic, ... http://tinyurl.com/eay43
[11:06am] <&thunderbolt> Google Google Earth lets you fly anywhere on Earth to view satellite imagery, maps, terrain, 3D buildings, from galaxies in outer space to the canyons of the ocean. http://tinyurl.com/cw4r9 Your amazing. :D
@Stewie1k94 Please get the script from here:: http://pastebin.com/77JFz4uS
The hawkee version will not work because
is being removed from the code boxes on posts here.
It says Searching... then nothing appears, the script needs an update since its from 2010 =]
(Jun-Tue-26)(7:50:30:pm) <07~Ricko> @glocal kids
(Jun-Tue-26)(7:50:31:pm) 03@Pyro Searching Google........
(Jun-Tue-26)(7:50:48:pm) <07~Ricko> @gnews obama
(Jun-Tue-26)(7:50:49:pm) 03@Pyro Searching Google........
Please update it if its not gonna take alot of your time
good job though, 10/10.
How would you make it not use two lines on the bot? I run this on a channel that has a time limit between posts, so messaging "searching google......" and then posting is not feasible. I think the answer is in this line, though I've tried cutting parts of it to no success.
else { $1-2 $4 $+ ($5,$hget($sockname,$+(item,%start))) $+(,$6,$hget($sockname,$+(url,%start)),) }
I think the $1-2 is banded to the text, though I'm not that familiar with mirc -quite- yet.
@commy this version will echo back to your screen: http://pastebin.com/MjX6HV6h
As for calling the script from the same client it is loaded in, you can make a On Input event to handle this but I would just suggest using botserv. (If you are on a network with botserv.)
//bs say # @google words here
You can also just use /google
@poopie You must have ops to turn on the script with +google
The script checks for one of these symbols ~ ! & @
If you don't have one of them when you type +google , the bot will ignore you.
The script will also notice you when you use the !google trigger. It's better to test with the @google trigger.
Try this command from the bots status: /google test
If this is working fine it could just be a matter of having the proper symbol by your nickname.
Also: Any other info you could post would be helpful. IRC type, OS, etc.
@poopie I have this script still working.
Try following these instructions...
Getting the script running:
Sweet, thanks West. I've ran your module, and per your instructions there should be a seperate set of options for the Google module, but I cannot find them anywhere. It's properly loaded, it's working, but there's no dialogue popups for further option tweaking. Nothing in the pop-up for the module installer lets me further config the google module.