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 Error: wrong # args - google.tcl

Support & discussion of released scripts, and announcements of new releases.
Post Reply
E
Esoteric
Voice
Posts: 19
Joined: Mon Apr 11, 2005 1:08 pm

TCL Error: wrong # args - google.tcl

Post by Esoteric »

Hello, I just reinstalled my eggdrop bot and I am having and issue with getting several of my old scripts working. I have installed this on a new server.

My server is gentoo, with the latest version of tcl available in an ebuild. I can't tell you exactly what version I am using.

I get the following error in regards to this line (proc pub:google { nick uhost handle channel arg } {) ...

wrong # args: should be { join nick uhost handle channel arg }

I have tried changing it but still doesn't work, I just get another error. Can anyone help? What is causing this? Something new in TCL?

Thanks
-Erik

The google.tcl file is this:

Code: Select all

# google.tcl v0.2.1
#
# !google keywords - displays the first related website found from google in the channel
# !image keywords  - displays the first related image found on google in the channel
# !file keywords   - displays the first mirror download link found on filemirrors in the channel
#
# by aNa|0Gue - analogue@glop.org - http://www.glop.org/
#
# 04/17/2002 v0.2.1 useragent fix by FAN

package require http

bind pub - !google pub:google
bind pub - !image pub:image
bind pub - !file pub:file

set agent "Mozilla"

proc pub:google { nick uhost handle channel arg } {
 global agent
	if {[llength $arg]==0} {
		putserv "PRIVMSG $channel :hey ! tappes des mots boulet !"
	} else {
		set query "http://www.google.de/search?btnI=&q="
		for { set index 0 } { $index<[llength $arg] } { incr index } {
			set query "$query[lindex $arg $index]"
			if {$index<[llength $arg]-1} then {
				set query "$query+"
			}
		}
		#putserv "PRIVMSG $channel :$query"
                set token [http::config -useragent $agent]
		set token [http::geturl $query]
		puts stderr ""
		upvar #0 $token state
		set max 0
		foreach {name value} $state(meta) {
			if {[regexp -nocase ^location$ $name]} {
				set newurl [string trim $value]
				putserv "PRIVMSG $channel :$newurl"
			}
		}
	}
}

proc pub:image { nick uhost handle channel arg } {
 global agent
	if {[llength $arg]==0} {
		putserv "PRIVMSG $channel :hey ! tappes des mots boulet !"
	} else {
		set query "http://images.google.de/images?btnI=&q="
		for { set index 0 } { $index<[llength $arg] } { incr index } {
			set query "$query[lindex $arg $index]"
			if {$index<[llength $arg]-1} then {
				set query "$query+"
			}
		}
		append query &imgsafe=off
	#	putserv "PRIVMSG $channel :$query"
                set token [http::config -useragent $agent]
		set token [http::geturl $query]
		puts stderr ""
		upvar #0 $token state
		set max 0
		foreach {name value} $state(meta) {
			if {[regexp -nocase ^location$ $name]} {
				set starturl "http://"
				set newurl [string trim $value]
				set newurl [string range $newurl [expr [string first = $newurl]+1] [expr [string first & $newurl]-1]]
				append starturl $newurl
				putserv "PRIVMSG $channel :$starturl"
			}
		}
	}
}

proc pub:file { nick uhost handle channel arg } {
 global agent
	if {[llength $arg]==0} {
		putserv "PRIVMSG $channel :hey ! tappes un nom de fichier boulet !"
	} else {
		set query "http://www.filemirrors.com/find.src?file="
		set query "$query[lindex $arg 0]"
	#	putserv "PRIVMSG $channel :$query"
                set token [http::config -useragent $agent]
		set token [http::geturl $query]
		set html  [http::data $token]
		puts stderr ""
		upvar #0 $token state
		set max 0
	#	foreach {name value} $state(meta) {
	#		putserv "PRIVMSG $channel :$value"
	#	}
	#	putserv "PRIVMSG $channel :$html"
		set result "[lindex $html 1]"
		set result [string range $result [expr [string first = $result]+2] [expr [string first > $result]-2]]
		putserv "PRIVMSG $channel :$result"
	}
}

putlog "Google v0.2.1 - LOADED!"
-Erik
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

have completly restarted your bot with that script?
can you give us the more detailed error from '.set errorInfo'?
have you accidently loaded another google script?
if you have my egghttp port of this script in memory you would encounter the problem because of this line:
pub:google $nick $uhost $hand $chan google $arg
you can easily check this by doing a '.binds pub' in the partyline, if you have a bind to pub to the function pub:google:cmd this would proabably be your problem and you would only have to unbind that (if you dont want to .restart your bot) ^^.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
E
Esoteric
Voice
Posts: 19
Joined: Mon Apr 11, 2005 1:08 pm

Post by Esoteric »

I will give more info as soon as I get home, for now what is your egghttp port? Can you give me a link?

Thanks!
-Erik
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

this is basicly the same idea of script, just a bit optimized and rewritten from the package http which often causes problems to the save and non-blocking egghttp (package is the wrong expression, its just a tcl script providing some functions).
http://forum.egghelp.org/viewtopic.php?t=9207
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
E
Esoteric
Voice
Posts: 19
Joined: Mon Apr 11, 2005 1:08 pm

Post by Esoteric »

Code: Select all

Command bindings:
  TYPE FLGS     COMMAND              HITS BINDING (TCL)
  pub  -|-      !help                   1 pub:help
  pub  -|-      !google                 2 pub:google

I have a lot more binds but that is the only google bind.

.set errorInfo doesn't work...
-Erik
E
Esoteric
Voice
Posts: 19
Joined: Mon Apr 11, 2005 1:08 pm

Post by Esoteric »

I am running egghttp.tcl and your google script and I still get the error

wrong # args: should be "join nick uhost hand chan"
-Erik
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Esoteric wrote:.set errorInfo doesn't work...
then you have probably it disabled in the .conf file ^^

but very strange, if you really checked all I mentioned, I cannot help here.
neither my script neither the script posted above can produce that error as they are, there must be an other script interferring with them (unless you do a .restart, once loaded scripts won't unload just because you removed their source and did a .rehash).
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
E
Esoteric
Voice
Posts: 19
Joined: Mon Apr 11, 2005 1:08 pm

Post by Esoteric »

where is the conf file do I look to enable it ... I can't find it ...

is there anyone else that can help?

it has to be an issue with TCL... what version are you running?
-Erik
User avatar
Linux
Halfop
Posts: 71
Joined: Sun Apr 04, 2004 4:20 pm
Location: Under The Sky

Post by Linux »

De Kus wrote:
Esoteric wrote:.set errorInfo doesn't work...
then you have probably it disabled in the .conf file ^^

but very strange, if you really checked all I mentioned, I cannot help here.
neither my script neither the script posted above can produce that error as they are, there must be an other script interferring with them (unless you do a .restart, once loaded scripts won't unload just because you removed their source and did a .rehash).
Well, restart your bot and load the scripts seperately i.e. 1 by 1 and check out if the problem still there.
I'm an idiot, At least this one [bug] took about 5 minutes to find...
User avatar
Linux
Halfop
Posts: 71
Joined: Sun Apr 04, 2004 4:20 pm
Location: Under The Sky

Post by Linux »

Code: Select all

# by murf
# Commands
# .google keyword(s) <# of results>
# e.g. .google sick 5

# default number of returns
set google_def_num 4

# max number of returns
set google_max 10


set glpubbind .google

set gl_output "NOTICE $nick"

bind pub -|- $glpubbind pub_google

proc pub_google {nick uhost handle chan search} {
  global gl_ouput
  set gl_output "NOTICE $nick"
  if {[llength $search] == 0} {
     puthelp "$gl_output : Whatcha searchin for fool!?"
     return 0
  }
  set url [google_url $search $nick $chan]
  google_getpage $url
  return 0
}

# Google_url #
# Takes input and parses to set the url, returns the url

proc google_url {search nick chan} {
  global google_def_num google_max gl_output
  set google_num [lindex $search end]
  if {[regexp { [0-9]+} $search match $google_num]} {
     if {$google_num > $google_max} { set google_num $google_max }
     set search [lrange $search 0 [expr {[llength $search] - 2}]]
  } else {
     set google_num $google_def_num
  }
  if {$google_num >= 5} { 
     set gl_output "NOTICE $nick"
  } else {
     set gl_output "PRIVMSG $chan"
  }
  regsub -all { } $search {+} search 
  set url "/search?hl=en&num=$google_num&lr=&ie=ISO-8859-1&q=$search"
  return $url
}

# google_getpage #
# gets the webpage and parses for the returns

proc google_getpage {url} {
   global gl_output
## Open socket

   if {[catch {set glsock [socket -async www.google.com 80]} sockerr]} {
      puthelp "NOTICE $nick :$sockerr"
      puthelp "NOTICE $nick :Try again later, look out the window till then!"
      close $glsock
      return 0
   }
   puts $glsock "GET $url"
   flush $glsock
   set i 0
   set j 1 
  set glout [gets $glsock]
  while {[regexp {Dissatisfied with your results?} $glout] == 0} {
     set glout [gets $glsock]	
     incr i
     if {$i >= 150} {
        break
     } 
     if {[regexp {#008000>(.*?) - } $glout match gl_result($j)]} {
        puthelp "$gl_output :$j. http://$gl_result($j)"
        incr j
     }
  }
  close $glsock
  return 0
}
I'm an idiot, At least this one [bug] took about 5 minutes to find...
E
Esoteric
Voice
Posts: 19
Joined: Mon Apr 11, 2005 1:08 pm

Post by Esoteric »

found my issue, it seems that one of my other scripts is corrupting the other scripts ... thanks. now I have to and try to fix the broken script.
-Erik
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

This was paragraph 3 in my first post :P
have you accidently loaded another google script?
PS: a scrip with the proc name "pub:google" is a google script, whatever it does, its related to google...
Last edited by De Kus on Mon Apr 11, 2005 6:44 pm, edited 1 time in total.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
E
Esoteric
Voice
Posts: 19
Joined: Mon Apr 11, 2005 1:08 pm

Post by Esoteric »

it wasn't another google script ... it was another script with the same proc name ... screwed things up.
-Erik
Post Reply