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.

TCL of google no longer works .. By FordLawnmower

Help for those learning Tcl or writing their own scripts.
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

TCL of google no longer works .. By FordLawnmower

Post by Arnold_X-P »

:( this tcl worked well but since last week stopped working
http://hawkee.com/snippet/7681/

Code: Select all

##############################################################################################
##  ## Advanced Google.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help  ##  ##
##############################################################################################
##  ## To use this script you must set channel flag +google (ie .chanset #chan +google) ##  ##
##############################################################################################
##############################################################################################
##  ##                             Start Setup.                                         ##  ##
##############################################################################################
## Change the character between the "" below to change the command character/trigger.       ##
set googlecmdchar "!"
proc google {nick host hand chan type search} {
  if {[lsearch -exact [channel info $chan] +google] != -1} {
## Change the country code between the "" below to change the language of your results.     ##
    set googlectry "en"
## Change the number between the "" below to change the number of results returned.         ##
    set googlemax "3"
## Change the characters between the "" below to change the logo shown with each result.    ##
    set googlelogo "\002\0032g\0034o\0038o\00314g\0039l\0034e\002\003"
## Change the format codes between the "" below to change the color/state of the text.      ##
    set textf "\0034"
## Change the format codes between the "" below to change the color/state of the links.     ##
    set linkf "\003\037"
##############################################################################################
##  ##                           End Setup.                                              ## ##
##############################################################################################
    set googlesite ajax.googleapis.com
    set googleurl /ajax/services/search/${type}?v=1.0&rsz=large&q=${search}&ql=${googlectry}&lr=lang_${googlectry}
    if {[catch {set googlesock [socket -async $googlesite 80]} sockerr]} {
      putlog "$googlesite $googleurl $sockerr error"
      return 0
      } else {
      puts $googlesock "GET $googleurl HTTP/1.0"
      puts $googlesock "Host: $googlesite"
      puts $googlesock "User-Agent: Opera 9.6"
      puts $googlesock ""
      flush $googlesock
      while {![eof $googlesock]} {
        set googlevar " [gets $googlesock] "
        set googlelink [regexp -all -nocase -inline {\"url\":\"([^\"]*)\"} $googlevar]
        set googledesc [regexp -all -nocase -inline {\"title\":\"([^\"]*)\"} $googlevar]
        if {$googledesc != "" && $googlelink != ""} {
          for {set x 1} {$x <= [expr 2 * $googlemax]} {incr x 2} {
            if {[lindex $googledesc $x] != "" && [lindex $googlelink $x] != ""} {
             putserv "PRIVMSG $chan :$googlelogo $textf[dehex [lindex $googledesc $x]] $linkf[dehex [lindex $googlelink $x]]" 
            }
          }
        }
      }
      close $googlesock
      return 0 
    }
  }
}
proc asc {chr} {
  scan $chr %c asc
  return $asc
}
proc chr {asc} { return [format %c $asc] }
proc hex {decimal} { return [format %x $decimal] }
proc decimal {hex} { return [expr 0x$hex] }
proc dehex {string} {
  set string [subst [regsub -nocase -all {\\u([a-f0-9]{4})} [noeval $string] {[format %c [decimal \1]]}]]
  set string [subst [regsub -nocase -all {\%([a-f0-9]{2})} [noeval $string] {[format %c [decimal \1]]}]]
  set string [subst [regsub -nocase -all {\&#([0-9]{2});} [noeval $string] {[format %c \1]}]]
  set string [string map {" \" · · & & <b> \002 </b> \002} $string]
  return $string
}
proc noeval {string} {
  return [string map {[ \\[ ] \\] $ \\$ ( \\( ) \\)} $string]
}
proc urlencode {string} {
  regsub -all {^\{|\}$} $string "" string
  return [subst [regsub -nocase -all {([^a-z0-9])} $string {%[format %x [scan "\\&" %c]]}]]
}
proc googleweb {nick host hand chan args} { google $nick $host $hand $chan "web" [urlencode $args] }
proc googlelocal {nick host hand chan args} { google $nick $host $hand $chan "local" [urlencode $args] }
proc googlevideo {nick host hand chan args} { google $nick $host $hand $chan "video" [urlencode $args] }
proc googlenews {nick host hand chan args} { google $nick $host $hand $chan "news" [urlencode $args] }
proc googlebook {nick host hand chan args} { google $nick $host $hand $chan "books" [urlencode $args] }
proc googleimage {nick host hand chan args} { google $nick $host $hand $chan "images" [urlencode $args] }
proc googlepatent {nick host hand chan args} { google $nick $host $hand $chan "patent" [urlencode $args] }
bind pub - ${googlecmdchar}google googleweb
bind pub - ${googlecmdchar}glocal googlelocal
bind pub - ${googlecmdchar}gvideo googlevideo
bind pub - ${googlecmdchar}gnews googlenews
bind pub - ${googlecmdchar}gbook googlebook
bind pub - ${googlecmdchar}gimage googleimage
bind pub - ${googlecmdchar}gpatent googlepatent
setudef flag google
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
C
CP1832
Halfop
Posts: 68
Joined: Thu Oct 09, 2014 4:03 pm

Post by CP1832 »

Yeah, I was using it too and stopped working as the google API (that most google scripts used) is no longer working. Does anyone know any functional google scripts?
C
CP1832
Halfop
Posts: 68
Joined: Thu Oct 09, 2014 4:03 pm

Post by CP1832 »

Regarding the google API change, I found this script (http://digdilem.org/irc/index.cgi?entry=2617142644) and modified the FordLawnmower script to work with the new google API. This is the Xchat script with the new google API.

Code: Select all

#
# google.tcl - X-Chat TCL script that implements a public !google command
# 
#	prerequisites:
#		You need to have
#
#		+	TCL 8.5 (http://www.tcl.tk/) and
#		+	TCLLib 1.15 (http://tcllib.sourceforge.net/)
#
#		installed.
#		You also need a Google API key and a Google Search Id.
#
# installation:
#		Put google.tcl into startup scripts folder
#
#		+	on Windows the folder usually is	"C:\Users\[Your User Name]\AppData\Roaming\X-Chat 2"
#		+	on Linux the folder usually is		"~/.xchat2/"
#
#		and setup the configuration below.
#
#	usage:
#		If someone (including you) types
#
#			!google My Search Terms
#
#		into a channel or a private message
#		this script will respond with the first
#		search results found.
#		By default only the first 3 results are shown
#		but this can be configured.
#

#################
# configuration #
#################

set API_KEY		"YOUR_GOOGLE_API_KEY"
set SEARCH_ID	"YOUR_GOOGLE_SEARCH_ID"
set MAX_RESULTS 3

###################
# !google command #
###################

package require http
package require tls
package require json

# need https for google rest api
::http::register https 443 ::tls::socket

# search request queue
set google_queue {}

# say to user or channel
proc google_say { target data } {
	command "msg $target $data"
}

# enqueue cmd to be executed
proc google_enqueue { cmd } {
	global google_queue
	lappend google_queue $cmd
}

# called every second to handle enqueued commands
proc google_hook { } {
	global google_queue
	if { [ llength $google_queue ] > 0 } {
		set cmd [ lindex $google_queue 0 ]
		set google_queue [ lrange $google_queue 1 end ]
		eval $cmd
	}
}

# send the result to dest if it is a channel. otherwise send it to src
proc google_result { target data } {
	google_say $target "Search Results:"
	global MAX_RESULTS
	for { set i 0 } { $i < $MAX_RESULTS } { incr i } {
		set title [ dict get [ lindex [ dict get $data items ] $i ] title ]
		set link  [ dict get [ lindex [ dict get $data items ] $i ] link ]
		set index [ expr $i + 1 ]
		google_say $target "\[$index\] $title"
		google_say $target "\[$index\] $link"
	}
}

# perform google search request
proc google_request { target query } {
	global API_KEY SEARCH_ID
	set token [ ::http::geturl "https://www.googleapis.com/customsearch/v1?[::http::formatQuery alt json key $API_KEY cx $SEARCH_ID q $query]" ]
	set body [ ::http::data $token ]
	::http::cleanup $token
	set json [ ::json::json2dict $body ]
	google_result $target $json
}

# schedule a google search query
proc google_query { target query } {
	google_enqueue [ list google_request $target $query ]
}

# create !google command
on !google omega {
	splitsrc
	if { [ string index $_dest 0 ] eq "#" } {
		google_query $_dest $_rest
	} else {
		google_query $_nick $_rest
	}
	complete EAT_NONE
}

# also handle your commands
on XC_UCHANMSG omega {
	set target [ channel ]
	set data [ lindex $_raw 2 ]
	set first [ lindex $data 0 ]
	if { ( $first eq "!google" ) && ( [ llength $data ] > 1 ) } {
		google_query $target [ lrange $data 1 end ]
	}
	complete EAT_NONE
}

# start hook
timer -repeat 1 google_hook
print "!google command version 1.1 started."
And this is how the script ended.

Code: Select all

##############################################################################################
##  ## Advanced Google.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help  ##  ##
##############################################################################################
##  ## To use this script you must set channel flag +google (ie .chanset #chan +google) ##  ##
##############################################################################################

package require http
package require json

if {[catch {package require tls}]} {
set httpsSupport false
} else {
set httpsSupport true
}
set url "www.googleapis.com/customsearch/v1?"
if {$httpsSupport} {
::http::register https 443 [list ::tls::socket -request 1 -require 0 -ssl3 1 -tls1 1]
set url https://$url
} else { set url http://$url }

##############################################################################################
##  ##                             Start Setup.                                         ##  ##
##############################################################################################
## Change the country code between the "" below to change the language of your results.     ##
set googlectry "en"
## Change the number between the "" below to change the number of results returned.         ##
set googlemax "1"
set API_KEY	""
set SEARCH_ID	""
##############################################################################################
##  ##                           End Setup.                                              ## ##
##############################################################################################

proc googleweb {nick host hand chan type search} {
		global googlectry googlemax API_KEY SEARCH_ID url
        if {$search == ""} {puthelp "PRIVMSG $chan :Error: <search> is empty"; return 1 }
		if {$type == ""} { 
	set googleurl $url[::http::formatQuery alt json key $API_KEY cx $SEARCH_ID hl $googlectry q $search]
	} else { set googleurl $url[::http::formatQuery alt json key $API_KEY cx $SEARCH_ID hl $googlectry q $search searchType $type] }
		if {[catch {http::geturl $googleurl -timeout 5000} sockerr]} {
			puthelp "privmsg $chan :Timeout connecting to Google: $sockerr"
			return 1
		} elseif {[http::ncode $sockerr] != 200 || ![string equal [http::status $sockerr] "ok"]} {
			puthelp "privmsg $chan :Error querying Google: [http::ncode $sockerr] -> [http::status $sockerr]"
			http::cleanup $sockerr
			return 1
		} else {
			set data [http::data $sockerr]
			http::cleanup $sockerr
			set json [ ::json::json2dict $data ]
			for { set i 0 } { $i < $googlemax } { incr i } {
				set title ""
				set link ""
				catch { set title [ dict get [ lindex [ dict get $json items ] $i ] title ] }
				catch { set link  [ dict get [ lindex [ dict get $json items ] $i ] link ] }
				set index [ expr $i + 1 ]
				if {[string length $title] && [string length $link]} {
					putserv "PRIVMSG $chan :$title $link"
				} else {
					puthelp "PRIVMSG $chan :Google found no results"
				}
			}
		}
return 1
}

proc google {nick host hand chan text} { googleweb $nick $host $hand $chan "" $text}
proc gimage {nick host hand chan text} { googleweb $nick $host $hand $chan image $text}

foreach bind [binds google] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
foreach bind [binds gimage] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}

bind pub - .google google
bind pub - .gimage gimage

putlog "Google script loaded"
If you don't have the json package, you can add json.tcl to your scripts folder as follows:

Code: Select all

#
#   JSON parser for Tcl.
#
#   See http://www.json.org/ && http://www.ietf.org/rfc/rfc4627.txt
#
#   Total rework of the code published with version number 1.0 by
#   Thomas Maeder, Glue Software Engineering AG
#
#   $Id: json.tcl,v 1.5 2009/12/10 17:48:12 andreas_kupries Exp $
#

if {![package vsatisfies [package provide Tcl] 8.5]} {
    package require dict
}

package provide json 1.1

namespace eval json {
    # Regular expression for tokenizing a JSON text (cf. http://json.org/)

    # tokens consisting of a single character
    variable singleCharTokens { "{" "}" ":" "\\[" "\\]" "," }
    variable singleCharTokenRE "\[[join $singleCharTokens {}]\]"

    # quoted string tokens
    variable escapableREs { "[\\\"\\\\/bfnrt]" "u[[:xdigit:]]{4}" }
    variable escapedCharRE "\\\\(?:[join $escapableREs |])"
    variable unescapedCharRE {[^\\\"]}
    variable stringRE "\"(?:$escapedCharRE|$unescapedCharRE)*\""

    # (unquoted) words
    variable wordTokens { "true" "false" "null" }
    variable wordTokenRE [join $wordTokens "|"]

    # number tokens
    # negative lookahead (?!0)[[:digit:]]+ might be more elegant, but
    # would slow down tokenizing by a factor of up to 3!
    variable positiveRE {[1-9][[:digit:]]*}
    variable cardinalRE "-?(?:$positiveRE|0)"
    variable fractionRE {[.][[:digit:]]+}
    variable exponentialRE {[eE][+-]?[[:digit:]]+}
    variable numberRE "${cardinalRE}(?:$fractionRE)?(?:$exponentialRE)?"

    # JSON token
    variable tokenRE "$singleCharTokenRE|$stringRE|$wordTokenRE|$numberRE"


    # 0..n white space characters
    set whiteSpaceRE {[[:space:]]*}

    # Regular expression for validating a JSON text
    variable validJsonRE "^(?:${whiteSpaceRE}(?:$tokenRE))*${whiteSpaceRE}$"
}


# Validate JSON text
# @param jsonText JSON text
# @return 1 iff $jsonText conforms to the JSON grammar
#           (@see http://json.org/)
proc json::validate {jsonText} {
    variable validJsonRE

    return [regexp -- $validJsonRE $jsonText]
}

# Parse JSON text into a dict
# @param jsonText JSON text
# @return dict (or list) containing the object represented by $jsonText
proc json::json2dict {jsonText} {
    variable tokenRE

    set tokens [regexp -all -inline -- $tokenRE $jsonText]
    set nrTokens [llength $tokens]
    set tokenCursor 0
    return [parseValue $tokens $nrTokens tokenCursor]
}

# Throw an exception signaling an unexpected token
proc json::unexpected {tokenCursor token expected} {
     return -code error "unexpected token \"$token\" at position $tokenCursor; expecting $expected"
}

# Get rid of the quotes surrounding a string token and substitute the
# real characters for escape sequences within it
# @param token
# @return unquoted unescaped value of the string contained in $token
proc json::unquoteUnescapeString {token} {
    set unquoted [string range $token 1 end-1]
    return [subst -nocommands -novariables $unquoted]
}

# Parse an object member
# @param tokens list of tokens
# @param nrTokens length of $tokens
# @param tokenCursorName name (in caller's context) of variable
#                        holding current position in $tokens
# @param objectDictName name (in caller's context) of dict
#                       representing the JSON object of which to
#                       parse the next member
proc json::parseObjectMember {tokens nrTokens tokenCursorName objectDictName} {
    upvar $tokenCursorName tokenCursor
    upvar $objectDictName objectDict

    set token [lindex $tokens $tokenCursor]
    incr tokenCursor

    set leadingChar [string index $token 0]
    if {$leadingChar eq "\""} {
        set memberName [unquoteUnescapeString $token]

        if {$tokenCursor == $nrTokens} {
            unexpected $tokenCursor "END" "\":\""
        } else {
            set token [lindex $tokens $tokenCursor]
            incr tokenCursor

            if {$token eq ":"} {
                set memberValue [parseValue $tokens $nrTokens tokenCursor]
                dict set objectDict $memberName $memberValue
            } else {
                unexpected $tokenCursor $token "\":\""
            }
        }
    } else {
        unexpected $tokenCursor $token "STRING"
    }
}

# Parse the members of an object
# @param tokens list of tokens
# @param nrTokens length of $tokens
# @param tokenCursorName name (in caller's context) of variable
#                        holding current position in $tokens
# @param objectDictName name (in caller's context) of dict
#                       representing the JSON object of which to
#                       parse the next member
proc json::parseObjectMembers {tokens nrTokens tokenCursorName objectDictName} {
    upvar $tokenCursorName tokenCursor
    upvar $objectDictName objectDict

    while true {
        parseObjectMember $tokens $nrTokens tokenCursor objectDict

        set token [lindex $tokens $tokenCursor]
        incr tokenCursor

        switch -exact $token {
            "," {
                # continue
            }
            "\}" {
                break
            }
            default {
                unexpected $tokenCursor $token "\",\"|\"\}\""
            }
        }
    }
}

# Parse an object
# @param tokens list of tokens
# @param nrTokens length of $tokens
# @param tokenCursorName name (in caller's context) of variable
#                        holding current position in $tokens
# @return parsed object (Tcl dict)
proc json::parseObject {tokens nrTokens tokenCursorName} {
    upvar $tokenCursorName tokenCursor

    if {$tokenCursor == $nrTokens} {
        unexpected $tokenCursor "END" "OBJECT"
    } else {
        set result [dict create]

        set token [lindex $tokens $tokenCursor]

        if {$token eq "\}"} {
            # empty object
            incr tokenCursor
        } else {
            parseObjectMembers $tokens $nrTokens tokenCursor result
        }

        return $result
    }
}

# Parse the elements of an array
# @param tokens list of tokens
# @param nrTokens length of $tokens
# @param tokenCursorName name (in caller's context) of variable
#                        holding current position in $tokens
# @param resultName name (in caller's context) of the list
#                   representing the JSON array
proc json::parseArrayElements {tokens nrTokens tokenCursorName resultName} {
    upvar $tokenCursorName tokenCursor
    upvar $resultName result

    while true {
        lappend result [parseValue $tokens $nrTokens tokenCursor]

        if {$tokenCursor == $nrTokens} {
            unexpected $tokenCursor "END" "\",\"|\"\]\""
        } else {
            set token [lindex $tokens $tokenCursor]
            incr tokenCursor

            switch -exact $token {
                "," {
                    # continue
                }
                "\]" {
                    break
                }
                default {
                    unexpected $tokenCursor $token "\",\"|\"\]\""
                }
            }
        }
    }
}

# Parse an array
# @param tokens list of tokens
# @param nrTokens length of $tokens
# @param tokenCursorName name (in caller's context) of variable
#                        holding current position in $tokens
# @return parsed array (Tcl list)
proc json::parseArray {tokens nrTokens tokenCursorName} {
    upvar $tokenCursorName tokenCursor

    if {$tokenCursor == $nrTokens} {
        unexpected $tokenCursor "END" "ARRAY"
    } else {
        set result {}

        set token [lindex $tokens $tokenCursor]

        set leadingChar [string index $token 0]
        if {$leadingChar eq "\]"} {
            # empty array
            incr tokenCursor
        } else {
            parseArrayElements $tokens $nrTokens tokenCursor result
        }

        return $result
    }
}

# Parse a value
# @param tokens list of tokens
# @param nrTokens length of $tokens
# @param tokenCursorName name (in caller's context) of variable
#                        holding current position in $tokens
# @return parsed value (dict, list, string, number)
proc json::parseValue {tokens nrTokens tokenCursorName} {
    upvar $tokenCursorName tokenCursor

    if {$tokenCursor == $nrTokens} {
        unexpected $tokenCursor "END" "VALUE"
    } else {
        set token [lindex $tokens $tokenCursor]
        incr tokenCursor

        set leadingChar [string index $token 0]
        switch -exact $leadingChar {
            "\{" {
                return [parseObject $tokens $nrTokens tokenCursor]
            }
            "\[" {
                return [parseArray $tokens $nrTokens tokenCursor]
            }
            "\"" {
                # quoted string
                return [unquoteUnescapeString $token]
            }
            "t" -
            "f" -
            "n" {
                # bare word: true, false or null
                return $token
            }
            default {
                # number?
                if {[string is double -strict $token]} {
                    return $token
                } else {
                    unexpected $tokenCursor $token "VALUE"
                }
            }
        }
    }
}

proc json::dict2json {dictVal} {
    # XXX: Currently this API isn't symmetrical, as to create proper
    # XXX: JSON text requires type knowledge of the input data
    set json ""

    dict for {key val} $dictVal {
	# key must always be a string, val may be a number, string or
	# bare word (true|false|null)
	if {0 && ![string is double -strict $val]
	    && ![regexp {^(?:true|false|null)$} $val]} {
	    set val "\"$val\""
	}
    	append json "\"$key\": $val," \n
    }

    return "\{${json}\}"
}

proc json::list2json {listVal} {
    return "\[$[join $listVal ,]\]"
}

proc json::string2json {str} {
    return "\"$str\""
}
Last edited by CP1832 on Mon Jun 06, 2016 2:31 pm, edited 4 times in total.
C
CP1832
Halfop
Posts: 68
Joined: Thu Oct 09, 2014 4:03 pm

Post by CP1832 »

BTW, I forgot to mention that you have to create a google custom search account to get your API key and search ID here.
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

Google.tcl for eggdrop by Ford_Lawnmower
Activation error:
partyline
[21:57] <Arnold_X-P> .chanset #tcls +google
[21:57] <JulieTh> Error trying to set +google for #tcls, invalid mode.

error2 : [21:59] <JulieTh> [21:55:46] Tcl error [google]: invalid command name "checkUser"
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Restart your bot cos it seems you get stuff from previous script.
Once the game is over, the king and the pawn go back in the same box.
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

and restart and does not work and I tried it also in my windrop and gives me the same error.

to use it in my other windrop I have in my other pc and I generated the same error .. in Google.tcl by Ford_Lawnmower

in partyline;
23:37] <Arnold_X-P> .chanset #tcls +google
[23:37] <JulieTh> Error trying to set +google for #tcls, invalid mode.

error in google.tcl - X-Chat
# create !google command
on !google omega {

and

on XC_UCHANMSG omega {
set target [ channel ]
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

CP1832 TCL that put not work because it lacks
setudef flag google

Google.tcl for eggdrop by Ford_Lawnmower
Activation error:
partyline
[21:57] <Arnold_X-P> .chanset #tcls +google
[21:57] <JulieTh> Error trying to set +google for #tcls, invalid mode.



and it gives me that error, but something else missing from the tcl..

someone please can review the tcl :? :? :? :? :? :?
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

You'll want to start here

Code: Select all

##############################################################################################

proc googleweb {nick host hand chan type search} {
      if {![checkUser $nick $chan]} {return}
and change this to

Code: Select all

##############################################################################################
setudef flag google

proc googleweb {nick host hand chan type search} {
      if {![checkUser $nick $chan] && ![channel get $chan google]} {return}
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

##############################################################################################

proc googleweb {nick host hand chan type search} {
if {![checkUser $nick $chan]} {return}


adding and replacing.......

##############################################################################################
setudef flag google

proc googleweb {nick host hand chan type search} {
if {![checkUser $nick $chan] && ![channel get $chan google]} {return}

###############################################
###############################################

in partyline
[11:10] <Arnold_X-P> .chanset #tcls +google
[11:10] <JulieTh> Successfully set modes { +google } on #tcls.
[11:10] <Arnold_X-P> .save
[11:10] <JulieTh> [11:10:47] #Sedition# save
[11:10] <JulieTh> Saving user file...

in channel

[11:10] <Arnold_X-P> .google

in partyline error tcl
[11:10] <JulieTh> [11:10:12] Tcl error [google]: invalid command name "checkUser"


in channel

[11:11] <Arnold_X-P> .google tcl

in partyline error tcl
[11:11] <JulieTh> [11:17:12] Tcl error [google]: invalid command name "checkUser"
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

Arnold_X-P wrote: in partyline error tcl
[11:10] <JulieTh> [11:10:12] Tcl error [google]: invalid command name "checkUser"
You can just change

Code: Select all

proc googleweb {nick host hand chan type search} {
if {![checkUser $nick $chan]} {return}
to

Code: Select all

proc googleweb {nick host hand chan type search} {
if {![channel get $chan google]} {return}
The checkUser procedure is from another script, which I found here, which is used to act as a throttle/flood-limiter and stop people doing !google over and over, CP1832 doesn't seemed to have included it.
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

no longer gives error.....
[11:46] <Arnold_X-P> .google
[11:46] <@JulieTh> Error querying Google: 403 -> ok


but I see another detail, when the question is so:
<Arnold_X-P> .google
my bot should not answer
<@JulieTh> Error: <búsqueda> está en blanco
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
C
CP1832
Halfop
Posts: 68
Joined: Thu Oct 09, 2014 4:03 pm

Post by CP1832 »

Get_A_Fix wrote:The checkUser procedure is from another script, which I found here, which is used to act as a throttle/flood-limiter and stop people doing !google over and over, CP1832 doesn't seemed to have included it.
Indeed, the checkuser script does that. I had added the checkuser to the old script to prevent flooding and I forgot to leave it out when I posted the resulting script. I have edited the TCL code removing that line.
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

hi CP1832

set API_KEY ""
set SEARCH_ID ""

for the key to work you have to have an id and key on google
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
C
CP1832
Halfop
Posts: 68
Joined: Thu Oct 09, 2014 4:03 pm

Post by CP1832 »

Arnold_X-P wrote:hi CP1832

set API_KEY ""
set SEARCH_ID ""

for the key to work you have to have an id and key on google
Indeed, you have to get your own ID and KEY here.
Arnold_X-P wrote:but I see another detail, when the question is so:
<Arnold_X-P> .google
my bot should not answer
<@JulieTh> Error: <búsqueda> está en blanco
I added the below line to avoid empty queries to google. If you want to query google anyway, erase or comment this line.

Code: Select all

if {$search == ""} {puthelp "PRIVMSG $chan :Error: <search> is empty"; return 1 }
Post Reply