Googlism

By FordLawnmower on Oct 04, 2010

Script requested by Paranoia.
This script will return results from Googlism.com to irc channel/notice.

Getting Started:

  • Copy the code
  • Paste to a new remote
  • Save with a unique file name
  • Type +googlism (from a client with Ops) in each channel you want the script on in.
  • Note -googlism turns it back off

Triggers/Syntax:

  • @ & !
  • @ will message the channel if the user has halfops or higher.
  • ! will notice the user.
    Valid Triggers:
  • !gwho @gwho
  • !gwhat @gwhat
  • !gwhere @gwhere
  • !gwhen @gwhen
  • Example:: !gwhat fire

Example Output::
21:58:11 <!Ford_Lawnmower> @gwho mad max
21:58:13 mad max is an mp3 player for newton messagepads 2000 and 2100< => mad max is a life size training dummy designed and constructed for professional use to improve accurate technics in martial arts< => mad max is the plausability< => mad max is especially notable because it is poised between our industrialized world and total regression to< => mad max is an australian movie made in 1979

Note
Colors/delimiter can be changed in setup. See the top of the screen.
There is also a master on/off switch on the right click menu

;Googlism by Ford_Lawnmower irc.geekshed.net #Script-Help
menu Channel,Status {
  .$iif($group(#Googlism) == On,$style(1)) Googlism Trigger
  ..$iif($group(#Googlism) == On,$style(2)) On: .enable #Googlism
  ..$iif($group(#Googlism) == Off,$style(2)) Off: .disable #Googlism
}
#Googlism on
On $*:Text:/^(\+|-|!|@)G(ooglism|wh(o|at|en|ere))\s?(.*)/Si:#: {
;;;;;;;;;;;;;;;;;;;;;;;;;Setup Start;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Change %delim if you want a different delimiter
  var %delim 09«••09»
;;Change %textcolor to change the text color  
  var %textcolor 04
;;Change %maxresults for more or less results  
  var %maxresults 10
;;;;;;;;;;;;;;;;;;;;;;;;;;End Setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
  var %action $regml(1), %searchtext $regml(4)
  var %searchdir $+($replacex($regml(3),o,/who_is/,at,/what_is/,en,/when_is/,ere,/where_is/),$left($NoIsWas($regml(4)),1),/,$urlencode($NoIsWas($regml(4))),/))
  if (%action isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
    if (%action == +) {
      if ($istok(%GooglismChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the Googlism script }
      else { 
        .enable #Googlism
        Set %GooglismChanList $addtok(%GooglismChanList,$+($network,$chan),32)
        .msg $chan $nick has activated the Googlism script for $chan .
      }
    }
    else {
      if (!$istok(%GooglismChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the Googlism script }
      else { 
        Set %GooglismChanList $remtok(%GooglismChanList,$+($network,$chan),1,32)
        .msg $chan $nick has deactivated the Googlism script for $chan . 
      }
    }
  }
  elseif (!$timer($+(Googlism,$network,$nick))) && ($istok(%GooglismChanList,$+($network,$chan),32)) {
    .timer $+ $+(Googlism,$network,$nick) 1 6 noop
    var %method $iif(%action == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/),.msg $chan,.notice $nick))
    if (%searchtext) GetGooglism %method %searchdir %delim %textcolor %maxresults 0
    else %method %textcolor Please provide some search terms!!
  }
}
#Googlism end
alias Googlism { GetGooglism echo -a $1- }
alias -l GetGooglism {
  $1-2 Searching........
  var %sockname $+(Googlism,$network,$2,$ticks)
  sockopen %sockname www.googlism.com 80
  sockmark %sockname $1-
}
On *:sockopen:Googlism*: {
  if (!$sockerr) {
    sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
    sockwrite -n $sockname Host: www.googlism.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:Googlism*: {
  if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  else {
    var %Googlism | sockread %Googlism
    if ($gettok($sock($sockname).mark,7,32) >= $gettok($sock($sockname).mark,6,32) || (</html> isin %Googlism)) {
      tokenize 32 $sock($sockname).mark
      put $1-2 $5 $iif($8-,$v1,Nothing Found)
      sockclose $sockname
      return
    }
    elseif ($regex(%Googlism,/Googlism for:.*<b>(.*)</p>/)) {
      $gettok($sock($sockname).mark,1-2,32) $gettok($sock($sockname).mark,5,32) $regml(1)
      sockclose $sockname
      return
    }
    elseif ($regex(%Googlism,/Googlism for:.*<br>(.*)<br\s\/>/)) {
      tokenize 32 $sock($sockname).mark
      sockmark $sockname $1-6 1 $+($5,$replace($regml(1),$chr(9), ,&quot;,"))
    }
    elseif ($gettok($sock($sockname).mark,7,32)) {
      tokenize 32 $sock($sockname).mark
      if (%Googlism == <p>) {
        put $1-2 $5 $iif($8-,$v1,Nothing Found)
        sockclose $sockname
        return        
      }
      else { sockmark $sockname $1-6 $calc($7 + 1) $+($8-,$4,$5,$remove($replace(%Googlism,$chr(9), ,&quot;,"),<br />)) }
    }
  }
}
alias -l NoIsWas {
  tokenize 32 $strip($1)
  return $iif($istok(is was,$1,32),$2-,$1-)
}
alias -l urlencode return $regsubex($replace($1-,$chr(32),_),/([^a-z0-9_])/ig,% $+ $base($asc(\t),10,16,2))
alias -l Put {
  if (!$regex($1,/(\.|^)(msg|notice|echo)$/Si)) || (!$3) { echo -st **Put error** Syntax /Put msg #channel text - or - /Put notice nickname text  | return }
  tokenize 32 $regsubex($1-,/([$\|%\[\]\}\{][^\s]*)/g,$+($chr(2),$chr(2),\t))
  var %tokens $0, %Tstart 4, %Dtimer 1500
  if ($timer($+(Put,$2,$network)).secs) { %Dtimer = $calc($v1 * 1000) }  
  while ($len($($+($,%Tstart,-,%tokens),2)) > 430) {
    dec %tokens
    if ($len($($+($,%Tstart,-,%tokens),2)) <= 430) {
      .timer -m 1 %Dtimer $1-3 $($+($,%Tstart,-,%tokens),2))
      inc %Dtimer 1500
      %Tstart = $calc(%tokens + 1)
      %tokens = $0
    }
  }
  .timer -m 1 %Dtimer $1-3 $($+($,%Tstart,-,%tokens),2))
  .timer $+ $+(Put,$2,$network) -m 1 $calc(%Dtimer + 1500) noop 
}

Comments

Sign in to comment.
SteveLee   -  Apr 06, 2016

thanks for the code

 Respond  
dma   -  Mar 30, 2016

all i get is searching........

 Respond  
RIcko   -  Jun 27, 2012

Works great, thank you for the update!

but the results are a bit too much >.<

 Respond  
MashhitDK   -  Jun 26, 2012

That did the trick... don't get them here any more anyways...
Thanks for the quick "update" @FordLawnmower

 Respond  
FordLawnmower   -  Jun 26, 2012

Try getting the code from here: http://pastebin.com/1V7RGFjf
It seems that hawkee is replacing the
in the code box so it doesn't get replaced in the actual script.
You can also fix it by replacing line 86:

else { sockmark $sockname $1-6 $calc($7 + 1) $+($8-,$4,$5,$remove($replace(%Googlism,$chr(9), ,&quot;,"),)) }

With the correct line:

 else { sockmark $sockname $1-6 $calc($7 + 1) $+($8-,$4,$5,$remove($replace(%Googlism,$chr(9), ,&quot;,"),<br />)) }

Edit***** Ignore the code replacement above, as it also removed the
from there.
Please just use the pastebin. http://pastebin.com/1V7RGFjf

Extra
added . This edit is getting ugly ;/

 Respond  
RIcko   -  Jun 26, 2012

Yes, that's what i meant, its adding
to the results

 Respond  
MashhitDK   -  Jun 26, 2012

I get the same as Ricko just tried it on test terminal... also get all the
in between replys

 Respond  
FordLawnmower   -  Jun 26, 2012

I'm not really clear on the problem here: I'm getting this:

[13:57:28] <@Ford_Lawnmower> @gwho mad max
[13:57:29] Searching........
[13:57:30] mad max is an mp3 player for newton messagepads 2000 and 2100«»mad max is a life size training dummy designed and constructed for professional use to improve accurate technics in martial arts«»mad max is the plausability«»mad max is especially
[13:57:31] notable because it is poised between our industrialized world and total regression to«»mad max is an australian movie made in 1979«»mad max is tremendously exciting«»mad max is a state of the art catamaran«»mad max is just
[13:57:33] sensational«»mad max is a strange film«»mad max is so much more exciting and compelling than the first half

 Respond  
RIcko   -  Jun 26, 2012

@gwho mad max
03@Pyro [-] mad max is a life size training dummy designed and constructed for professional use to improve accurate technics in martial arts
[-]04mad max is the plausability

What's wrong with the
?

 Respond  
Dark|   -  Nov 20, 2010

AweSome ;D

 Respond  
FordLawnmower   -  Oct 05, 2010

You're welcome MashhitDK :)
Thanks for the comment :)

 Respond  
MashhitDK   -  Oct 05, 2010

Just wanted to say thanks...

Looks good...

  • So I think I'm gonna use it for My bot... <3

Nice work :D

 Respond  
FordLawnmower   -  Oct 05, 2010

Updated::
Changed Default delimiter.
Changed Default results to 10.
Fixed second line color issue.
Fixed some " bugs.

 Respond  
Paranoia   -  Oct 05, 2010

Looks great! Thanks!

 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.