|
Joined: May 2011
Posts: 9
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: May 2011
Posts: 9 |
Can't believe the difficulty I'm having finding a working Google search script. The current one I have from mircscripts.org often returns a parser error. Is there any place else I could find one, or perhaps someone has one they would like to share? Thanks.
|
|
|
|
Joined: Aug 2010
Posts: 2
Bowl of petunias
|
Bowl of petunias
Joined: Aug 2010
Posts: 2 |
Hi thats easy as I found 2 for you from FordLawnmowerFirst: 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 <Ford> @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.mindforge.org #USA-Chat
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).*/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 }
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 *:sockread: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)),",",&,&) }
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 $+(/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 {
var %Tiny | sockread %Tiny
if ($regex(%Tiny,/<blockquote><b>(.*)<\/b><br><small>/i)) {
tokenize 32 $sock($sockname).mark
$1-2 $replace($5-,$4,$regml(1))
sockclose $sockname
return
}
}
}
On *:Unload: { unset %AdvancedGoogleChanList* | hfree -w AdvancedGoogle* } Google SearchThis snippet will retrieve the first search result for a query off of Google and execute a command on it. ; Tye @ DALnet, Undernet ; tye at mirc . net ; ; This snippet will retrieve the first search result for a query off of Google and execute a command on it. ; Copy this code into your remotes (Alt+R) ; ; /googlesearch alias query ; Results will be passed to command alias googlesearch { var %x = 1 while ($sock($+(google,%x))) inc %x sockopen $+(google,%x) www.google.com 80 sockmark $+(google,%x) $1- } ON *:SOCKOPEN:google*: { if ($sockerr) { var %cmd = $gettok($sock($sockname).mark,1,32) %cmd Socket error $sockerr return } sockwrite -n $sockname GET $+(/search?q=,$phex($gettok($sock($sockname).mark,2-,32)),&btnI=I%27m+Feeling+Lucky HTTP/1.0) sockwrite $sockname $crlf } on *:SOCKREAD:google*: { var %f, %cmd, %result %cmd = $gettok($sock($sockname).mark,1,32) if ($sockerr) { %cmd Socket error $sockerr return } while (1) { sockread %f if (!$sockbr) break if (<A HREF="*">here</a>. iswm %f) { %result = $gettok(%f,2,34) sockclose $sockname break } elseif (HTTP/1.0 200 OK = %f) { %result = There are no results. sockclose $sockname break } } if (%result) { %cmd %result } } alias google { googlesearch google2 $1- } alias google2 { echo $colour(info) -a *** Google search: $1- } ; !google query in a channel will message the channel with the results. alias google3 { msg %google3 Google search: $1- | unset %google3 } on *:TEXT:!google *:#: { set %google3 $chan googlesearch google3 $2- } ; Convert some text to hexadecimal form alias phex { var %x = 1, %s = $len($1), %r, %w while (%x <= %s) { %w = $mid($1,%x,1) if ($asc(%w) = 32) { %r = $+(%r,+) } elseif ($asc(%w) !isnum 65-90) && ($asc(%w) !isnum 97-122) && ($asc(%w) !isnum 48-57) { %r = $+(%r,%,$base($asc(%w),10,16,2)) } else { %r = $+(%r,%w) } inc %x } return %r }
|
|
|
|
Joined: May 2011
Posts: 9
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: May 2011
Posts: 9 |
Neither of these are working First one won't display any results at all. Second snippet returns Socket 4 error. Anybody else have a script? My old Google search script would at least work some of the time even though I would get a lot of parser errors, however now it will not return any results.
|
|
|
|
Joined: Nov 2009
Posts: 295
Fjord artisan
|
Fjord artisan
Joined: Nov 2009
Posts: 295 |
Guess I'll be a nice guy. This is a basic google script I made. It's triggered with !g (search stuff) You can trigger the script yourself You can also use /g (search stuff) and it will echo the results to only you It only returns 1 result, it doesn't do math or any extra features the google website does, it only does basic results create a variable %chan_whitelist with a list of chans separated by spaces for chans you wish to have the script work in, Ex: %chan_whitelist #pball #lladq If you want it to work in all chans remove the line "if (!$istok(%chan_whitelist,$chan,32)) halt" There is a limit of 1 search every 5 seconds for spam protection, that can be changed in this line "else set -u5 %googlespam 1" by editing -u# to a different number
/*
[Addon]
Script=google.com
Version=
Author=pball
Desc=
For=Mirc
Date=10-05-11
[script]
*/
on *:TEXT:!g *:#: google_start $chan $$2-
on *:input:*: if (!$ctrlenter) && (!$inpaste) && ($left($1,1) != $readini(mirc.ini,text,commandchar) || $1 != /msg || $1 != /me) && ($1 == !g) google_start $chan $$2-
alias g {
google_start nchan $$1-
}
alias google_start {
if (!$istok(%chan_whitelist,$chan,32)) return
if (%googlespam) halt
else set -u5 %googlespam 1
if ($1 != nchan) set %google.chan $v1
set %google.url /custom?hl=en&client=pub-4099951843714863&cof=FORID%3A1%3BGL%3A1%3BS%3Ahttp%3A%2F%2Fwww.hyperwords.net%2F%3BL%3Ahttp%3A%2F%2Fwww.hyperwords.net%2Fhy-for-google.gif%3BLH%3A100%3BLW%3A100%3BLBGC%3AFFFFFF%3BLP%3A1%3BLC%3A%230033cc%3BVLC%3A%23333333%3BGALT%3A%23999999%3B&q= $+ $web_input($2-) $+ &btnG=Search
sockopen google www.google.com 80
}
on *:SOCKOPEN:google:{
sockwrite -nt $sockname GET %google.url HTTP/1.1
sockwrite -nt $sockname HOST: www.google.com
sockwrite -n $sockname
}
on *:SOCKREAD:google: {
if ($sockerr > 0) { echo -a Error while reading from $sockname $+ . | echo -a Error # $+ $sockerr occurred. | return }
sockread %google.read
while ($sockbr) {
if ($regex(g,%google.read,/<a class="l" href="(.*?)".*?">(.*?)</a></h2>.*?<span class="s">(.*?)</span><br>/)) {
$iif(%google.chan,msg $v1,echo -a) 7Result: $parsehtml($regml(g,2)) 7Link: $parsehtml($regml(g,1))
$iif(%google.chan,msg $v1,echo -a) 7Description: $parsehtml($regml(g,3))
set -l %done 1
}
sockread %google.read
if (%done) { sockclose google | unset %google.* }
}
}
alias -l web_input { return $replacex($1-,?,$+(%,3F),@,$+(%,40),#,$+(%,23),$,$+(%,24),%,$+(%,25),^,$+(%,5E),&,$+(%,26),+,$+(%,2B),=,$+(%,3D),`,$+(%,60),[,$+(%,5B),],$+(%,5D),\,$+(%,5C),$chr(123),$+(%,7B),$chr(125),$+(%,7D),|,$+(%,7C),$chr(59),$+(%,3B),',$+(%,27),:,$+(%,3A),",$+(%,22),$chr(44),$+(%,2C),/,$+(%,2F),<,$+(%,3C),>,$+(%3E),$chr(32),$+(%,20)) }
alias -l parsehtml {
set -l %temp $regsubex($1,/<[^>]+[>$]>?/g,)
while (($regex(%temp,/&#(\d+);/)) && ($regml(1) isnum 32-255)) set -l %temp $replacex(%temp,$+(&#,$regml(1),;),$chr($regml(1)))
while (($regex(%temp,/&#x(.*?);/)) && ($base($regml(1),16,10) isnum 32-255)) set -l %temp $replacex(%temp,$+(&#x,$regml(1),;),$chr($base($regml(1),16,10)))
set -l %finished $replacex(%temp, ,$chr(160),",",·,·,<,<,>,>,&,&,–,–,é,$chr(233))
return %finished
}
No guarantees on this working forever, but with the particular method this uses it shouldn't change and stop working much hopefully. Just message me here if the script stops working.
Last edited by pball; 08/11/11 08:03 PM.
|
|
|
|
|