Frage zu TCL script für nen Windrop

Seite 1 von 1 - Forum: Coding Stuff auf overclockers.at

URL: https://www.overclockers.at/coding-stuff/frage_zu_tcl_script_fuer_nen_windrop_155355/page_1 - zur Vollversion wechseln!


dethspank schrieb am 28.12.2005 um 18:30

Also ich hab nen windrop (eggdrop) laufen und will dort ein google script laufen lassn das mir aber dauernd folgenden fehler ausgibt

tcl error [pub_google] can't find "nick": no such variable


hier der source code:


Code:
## default number of returns

set google_def_num 4

## max number of returns

set google_max 10

## public bind 

set glpubbind .google

set gl_output "NOTICE $nick"
##########binds######################
bind pub -|- $glpubbind pub_google

##########Procs######################

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 [url]http://www.google.com[/url] 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. [url]http://[/url]$gl_result($j)"
        incr j
     }
  }
  close $glsock
  return 0
}


CitizenX schrieb am 28.12.2005 um 18:55

proc pub_google zeile - gehört da nicht auch $ hin


dethspank schrieb am 28.12.2005 um 19:38

nein


dethspank schrieb am 29.12.2005 um 18:35

niemand der mir helfen kann??


watchout schrieb am 29.12.2005 um 20:26

hm, ich hab keine Erfahrung mit TCL, aber in

Code:
proc google_getpage {url} {
kommt kein "nick" vor, daher liegt wohl nahe dass du darin auch kein "nick" verwenden kannst oder?


dethspank schrieb am 29.12.2005 um 21:18

ich glaub das is ne andere abfrage eben und hat mit der ausgabe an sich wenig zutun sondern is eine teil prozedur


watchout schrieb am 29.12.2005 um 21:33

keine Ahnung was du schreibst - wieso "glaubst" du?

Wie auch immer - was ich so von der Sprache seh' muss man globale variablen (was scheinbar "nick" ist) mit dem keyword "global" in einer Procedure lokalisieren, nick wurde aber weder übergeben noch lokalisiert.


dethspank schrieb am 30.12.2005 um 16:14

und was wär dein vorschlag?


watchout schrieb am 30.12.2005 um 19:25

na genau das Gegenteil zu dem was geschrieben hab - entweder du übergibst nick oder du lokalisierst nick




overclockers.at v4.thecommunity
© all rights reserved by overclockers.at 2000-2024