This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

can this respod to nick ...

Old posts that have not been replied to for several years.
Locked
l
lsn
Voice
Posts: 25
Joined: Mon Jul 19, 2004 8:11 am

can this respod to nick ...

Post by lsn »

i got this google script

Code: Select all

bind pub - .google pub_google

set google(MAX) 10

set google(deny_CHANS) {
  "#chan1"
  "#chan2"
}

package require http


proc pub_google {nick uhost hand chan arg} {
  global google
  if {[lsearch [string tolower $google(deny_CHANS)] [string tolower $chan]]!="-1"} {
    return 0
  }
  if {$arg==""} {
    putserv "PRIVMSG $chan :$nick Usage: !google <search terms> \[-c1(Results to return)\] \[-a(Boolean And)\]"
    return 0
  }
  set type as_oq
  set results 1
  foreach flag $arg {
    if {$flag=="-a"} { set type as_q ; continue } else {
      if {[regexp -- {-c[0-9]*} $flag]} {
	set results [string range $flag 2 end]
        continue
      }
    }
    lappend search $flag
  }
  if {$results>$google(MAX)} {
    putnot $nick "Max results allowed is \002$google(MAX)\002, omitting extra"
    set results $google(MAX)
  }
  search_google $chan $results $type $search
}



proc search_google {chan results type search} {
  regsub -all " " $search "+" search
  set url http://www.google.com/search?$type=$search&num=$results
  http::config -useragent "Mozilla/5.0"
  set conn [http::geturl $url -headers "Referer http://www.google.com"]
  set data [http::data $conn]
  set count 0
  set lcount 0
  regsub -all .*<div> $data "" data
  regsub -all <div> $data <br> data
  regsub -all <br> $data \002 data
  foreach line [split $data \002] {
    incr lcount
#    putlog "$lcount: $line"
    if {$count==$results} { break }
    set line2 "" ; set line1 ""
    if {[regexp {(.*)<p [^>]*>(.*)} $line match line1 line2]} {
      if {$line2==""} { break }
      set description ""
      set desc ""
      regsub -all {<[^>]*>} $line2 "" description
      if {$description!=""} {
        set desc "($description)"
      }
      foreach word $line2 {
	if {[string match href=http://* [string tolower $word]]} {
	  regsub -all {>[^<]*|<[^<]*|href=} $word "" word
	  if {$results>1} {
  	    putserv "PRIVMSG $chan :Result([expr $count + 1]): \002$word\002 $desc"
	  } else { putserv "PRIVMSG $chan :Result: \00304\002$word\002\003 \00302$desc\003" }
          incr count 1
	  break
	}
      }
    }
  }
  if {$count!=$results} {
    putserv "PRIVMSG $chan :Only could find \00302\002$count\002 results\003"
  }
}
can be made to respond to person who give the .google command ?

:mrgreen:
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: can this respod to nick ...

Post by user »

change "$chan" to "$nick" in

Code: Select all

search_google $chan $results $type $search
Have you ever read "The Manual"?
Locked